From 58c306dafd3583515ad0977514333d3d54d636c4 Mon Sep 17 00:00:00 2001 From: Yutousama <583819556@qq.com> Date: Thu, 19 Apr 2018 14:43:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=83=AD=E6=9B=B4=E4=BE=9D?= =?UTF-8?q?=E8=80=90=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/yutou/jianrmg_v2/basemodel/Test.java | 64 ++++++++++++- .../Adapters/ModListRecyclerAdapter.java | 5 +- .../Adapters/ModRecyclerAdapter.java | 10 +- .../Adapters}/ReModListAdapter.java | 3 +- .../mglistmodel}/views/ModActivity.java | 10 +- .../mglistmodel}/views/ModListActivity.java | 7 +- MgListModel/src/main/java/views/Test.java | 92 ------------------- .../resmodl/ExampleInstrumentedTest.java | 26 ------ .../res/layout/activity_download_list.xml | 6 ++ ResModl/src/main/res/layout/activity_mod.xml | 2 +- .../jianrmg_v2/resmodl/ExampleUnitTest.java | 17 ---- .../Adapters/MyItemGridViewAdapter.java | 12 +++ .../usermodel/Views/DownloadListActivity.java | 67 ++++++++++++++ 13 files changed, 173 insertions(+), 148 deletions(-) rename MgListModel/src/main/java/{views => com/yutou/jianrmg_v2/mglistmodel/Adapters}/ReModListAdapter.java (96%) rename MgListModel/src/main/java/{ => com/yutou/jianrmg_v2/mglistmodel}/views/ModActivity.java (97%) rename MgListModel/src/main/java/{ => com/yutou/jianrmg_v2/mglistmodel}/views/ModListActivity.java (94%) delete mode 100644 MgListModel/src/main/java/views/Test.java delete mode 100644 ResModl/src/androidTest/java/com/yutou/jianrmg_v2/resmodl/ExampleInstrumentedTest.java create mode 100644 ResModl/src/main/res/layout/activity_download_list.xml delete mode 100644 ResModl/src/test/java/com/yutou/jianrmg_v2/resmodl/ExampleUnitTest.java create mode 100644 UserModel/src/main/java/com/jianrmg_v2/usermodel/Views/DownloadListActivity.java diff --git a/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/Test.java b/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/Test.java index 07cc63a..2256781 100644 --- a/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/Test.java +++ b/BaseModel/src/main/java/com/yutou/jianrmg_v2/basemodel/Test.java @@ -1,5 +1,6 @@ package com.yutou.jianrmg_v2.basemodel; +import android.content.Intent; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.app.AppCompatActivity; @@ -8,16 +9,77 @@ import android.view.MotionEvent; import android.widget.LinearLayout; import com.yutou.jianrmg_v2.basemodel.Data.AppData; +import com.yutou.jianrmg_v2.basemodel.Tools.Log; import Interfaces.BaseActivityInterface; import dalvik.system.DexClassLoader; -public class Test extends AppCompatActivity{ +import com.yutou.jianrmg_v2.resmodl.R; + +public class Test extends AppCompatActivity { + private BaseActivityInterface activityInterface; + private LinearLayout main_layut; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); + setContentView(R.layout.activity_base); setTitle(R.string.app_name); + main_layut = findViewById(R.id.main_layut); + activityInterface = (BaseActivityInterface) getIntent().getSerializableExtra("activity"); + Intent intent = getIntent(); + Log.i("测试", (activityInterface == null) + ""); + activityInterface.onCreate(savedInstanceState, main_layut, this, intent); + } + + @Override + protected void onRestart() { + activityInterface.onRestart(); + super.onRestart(); + } + + @Override + protected void onPause() { + activityInterface.onPause(); + super.onPause(); + } + + @Override + protected void onResume() { + activityInterface.onResume(); + super.onResume(); + } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + boolean tmp = activityInterface.onKeyDown(keyCode, event); + if (tmp) { + return tmp; + } + return super.onKeyDown(keyCode, event); + } + + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { + boolean tmp = activityInterface.onKeyUp(keyCode, event); + if (tmp) { + return tmp; + } + return super.onKeyUp(keyCode, event); + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + boolean tmp = activityInterface.onTouchEvent(event); + if (tmp) + return tmp; + return super.onTouchEvent(event); + } + + @Override + protected void onDestroy() { + activityInterface.onDestroy(); + super.onDestroy(); } } diff --git a/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/Adapters/ModListRecyclerAdapter.java b/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/Adapters/ModListRecyclerAdapter.java index 891f0f2..9600471 100644 --- a/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/Adapters/ModListRecyclerAdapter.java +++ b/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/Adapters/ModListRecyclerAdapter.java @@ -10,14 +10,15 @@ import com.alibaba.fastjson.JSON; import com.nostra13.universalimageloader.core.ImageLoader; import com.yutou.jianrmg_v2.basemodel.Data.AppData; import com.yutou.jianrmg_v2.basemodel.Data.MAppMg; +import com.yutou.jianrmg_v2.basemodel.Test; import com.yutou.jianrmg_v2.basemodel.views.BaseActivity; +import com.yutou.jianrmg_v2.mglistmodel.views.ModListActivity; import com.yutou.jianrmg_v2.resmodl.R; import com.yutou.jianrmg_v2.basemodel.Tools.Utils; import cn.lemon.view.adapter.BaseViewHolder; import cn.lemon.view.adapter.RecyclerAdapter; -import views.Test; /** @@ -73,7 +74,7 @@ public class ModListRecyclerAdapter extends RecyclerAdapter { getContext().startActivity(intent); }else{ Intent intent = new Intent(getContext(), Test.class); - intent.putExtra("activityName", "ModListActivity"); + intent.putExtra("activity", new ModListActivity()); intent.putExtra("mg", JSON.toJSONString(data)); getContext().startActivity(intent); } diff --git a/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/Adapters/ModRecyclerAdapter.java b/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/Adapters/ModRecyclerAdapter.java index b7e6e5d..9eb9a1d 100644 --- a/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/Adapters/ModRecyclerAdapter.java +++ b/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/Adapters/ModRecyclerAdapter.java @@ -14,13 +14,17 @@ import com.alibaba.fastjson.JSON; import com.nostra13.universalimageloader.core.ImageLoader; import com.yutou.jianrmg_v2.basemodel.Data.AppData; import com.yutou.jianrmg_v2.basemodel.Data.TMod; +import com.yutou.jianrmg_v2.basemodel.Test; +import com.yutou.jianrmg_v2.basemodel.Tools.Log; +import com.yutou.jianrmg_v2.mglistmodel.views.ModActivity; +import com.yutou.jianrmg_v2.mglistmodel.views.ModListActivity; import com.yutou.jianrmg_v2.resmodl.R; import com.yutou.jianrmg_v2.basemodel.Tools.Utils; -import views.ModActivity; + import cn.lemon.view.adapter.BaseViewHolder; import cn.lemon.view.adapter.RecyclerAdapter; -import views.Test; + /** @@ -80,7 +84,7 @@ public class ModRecyclerAdapter extends RecyclerAdapter { public void onItemViewClick(TMod data) { super.onItemViewClick(data); Intent intent=new Intent(getContext(), Test.class); - intent.putExtra("activityName","ModActivity"); + intent.putExtra("activity",new ModActivity()); intent.putExtra("mod", JSON.toJSONString(data)); getContext().startActivity(intent); } diff --git a/MgListModel/src/main/java/views/ReModListAdapter.java b/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/Adapters/ReModListAdapter.java similarity index 96% rename from MgListModel/src/main/java/views/ReModListAdapter.java rename to MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/Adapters/ReModListAdapter.java index 9f8f3e3..2dd9698 100644 --- a/MgListModel/src/main/java/views/ReModListAdapter.java +++ b/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/Adapters/ReModListAdapter.java @@ -1,4 +1,4 @@ -package views; +package com.yutou.jianrmg_v2.mglistmodel.Adapters; import android.content.Context; import android.content.Intent; @@ -12,6 +12,7 @@ import android.widget.TextView; import com.alibaba.fastjson.JSON; import com.nostra13.universalimageloader.core.ImageLoader; import com.yutou.jianrmg_v2.basemodel.Data.TMod; +import com.yutou.jianrmg_v2.basemodel.Test; import com.yutou.jianrmg_v2.resmodl.R; import com.yutou.jianrmg_v2.basemodel.Tools.Utils; diff --git a/MgListModel/src/main/java/views/ModActivity.java b/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/views/ModActivity.java similarity index 97% rename from MgListModel/src/main/java/views/ModActivity.java rename to MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/views/ModActivity.java index 1847d35..5a1f992 100644 --- a/MgListModel/src/main/java/views/ModActivity.java +++ b/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/views/ModActivity.java @@ -1,4 +1,4 @@ -package views; +package com.yutou.jianrmg_v2.mglistmodel.views; import android.app.Activity; import android.content.Context; @@ -24,6 +24,7 @@ import com.yutou.jianrmg_v2.basemodel.Data.TModtag; import com.yutou.jianrmg_v2.basemodel.Interfaces.HttpInterface; import com.yutou.jianrmg_v2.basemodel.Network.HttpApi; import com.yutou.jianrmg_v2.basemodel.Network.HttpUtils; +import com.yutou.jianrmg_v2.mglistmodel.Adapters.ReModListAdapter; import com.yutou.jianrmg_v2.resmodl.R; import com.yutou.jianrmg_v2.basemodel.Tools.Log; import com.yutou.jianrmg_v2.basemodel.Tools.ModUtils; @@ -32,6 +33,7 @@ import com.yutou.jianrmg_v2.basemodel.Tools.Utils; import org.json.JSONObject; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -43,7 +45,7 @@ import cn.droidlover.xrichtext.XRichText; * Created by 58381 on 2018/1/26. */ -public class ModActivity implements BaseActivityInterface { +public class ModActivity implements BaseActivityInterface ,Serializable{ private TMod tMod; private ImageView modImage, icon, collection_img; private TextView title, by, downloadText; @@ -60,7 +62,9 @@ public class ModActivity implements BaseActivityInterface { private LinearLayout mainLayot; private Context context; private Intent intent; - + public ModActivity(){ + Log.i("初始化mod列表"); + } @Override public void onCreate(Bundle savedInstanceState, LinearLayout layout, Context context,Intent intent) { layout.addView(LayoutInflater.from(context).inflate(R.layout.activity_mod, null)); diff --git a/MgListModel/src/main/java/views/ModListActivity.java b/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/views/ModListActivity.java similarity index 94% rename from MgListModel/src/main/java/views/ModListActivity.java rename to MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/views/ModListActivity.java index 2096293..0a9b7c8 100644 --- a/MgListModel/src/main/java/views/ModListActivity.java +++ b/MgListModel/src/main/java/com/yutou/jianrmg_v2/mglistmodel/views/ModListActivity.java @@ -1,4 +1,4 @@ -package views; +package com.yutou.jianrmg_v2.mglistmodel.views; import android.content.Context; import android.content.Intent; @@ -24,6 +24,7 @@ import com.yutou.jianrmg_v2.mglistmodel.Fragments.TestMod; import com.yutou.jianrmg_v2.resmodl.R; import com.yutou.jianrmg_v2.basemodel.Tools.Log; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; @@ -36,7 +37,7 @@ import me.majiajie.pagerbottomtabstrip.listener.OnTabItemSelectedListener; * Created by 58381 on 2018/1/25. */ -public class ModListActivity implements BaseActivityInterface { +public class ModListActivity implements BaseActivityInterface , Serializable{ private PageNavigationView tab; private ViewPager viewPager; private NavigationController navigationController; @@ -46,8 +47,10 @@ public class ModListActivity implements BaseActivityInterface { private Context context; private Intent intent; + @Override public void onCreate(Bundle savedInstanceState, LinearLayout layout, Context context,Intent intent) { + Log.i((layout==null)+" "+(intent==null)); layout.addView(LayoutInflater.from(context).inflate(R.layout.activity_mod_list,null)); mainView=layout; this.context=context; diff --git a/MgListModel/src/main/java/views/Test.java b/MgListModel/src/main/java/views/Test.java deleted file mode 100644 index c3a244e..0000000 --- a/MgListModel/src/main/java/views/Test.java +++ /dev/null @@ -1,92 +0,0 @@ -package views; - -import android.content.Intent; -import android.os.Bundle; -import android.support.annotation.Nullable; -import android.support.v7.app.AppCompatActivity; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.widget.LinearLayout; - -import com.yutou.jianrmg_v2.resmodl.R; - -import Interfaces.BaseActivityInterface; - -public class Test extends AppCompatActivity { - private BaseActivityInterface activityInterface; - private LinearLayout main_layut; - - @Override - protected void onCreate(@Nullable Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_base); - main_layut = findViewById(R.id.main_layut); - String baseActivityName=getIntent().getStringExtra("activityName"); - try { - switch (baseActivityName){ - case "ModListActivity": - activityInterface = new ModListActivity(); - break; - case "ModActivity": - activityInterface = new ModActivity(); - break; - } - - } catch (Exception e) { - e.printStackTrace(); - } - activityInterface.onCreate(savedInstanceState, main_layut, this, getIntent()); - - } - - @Override - protected void onRestart() { - activityInterface.onRestart(); - super.onRestart(); - } - - @Override - protected void onPause() { - activityInterface.onPause(); - super.onPause(); - } - - @Override - protected void onResume() { - activityInterface.onResume(); - super.onResume(); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - boolean tmp = activityInterface.onKeyDown(keyCode, event); - if (tmp) { - return tmp; - } - return super.onKeyDown(keyCode, event); - } - - @Override - public boolean onKeyUp(int keyCode, KeyEvent event) { - boolean tmp = activityInterface.onKeyUp(keyCode, event); - if (tmp) { - return tmp; - } - return super.onKeyUp(keyCode, event); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - boolean tmp = activityInterface.onTouchEvent(event); - if (tmp) - return tmp; - return super.onTouchEvent(event); - } - - @Override - protected void onDestroy() { - activityInterface.onDestroy(); - super.onDestroy(); - } - -} diff --git a/ResModl/src/androidTest/java/com/yutou/jianrmg_v2/resmodl/ExampleInstrumentedTest.java b/ResModl/src/androidTest/java/com/yutou/jianrmg_v2/resmodl/ExampleInstrumentedTest.java deleted file mode 100644 index 079df30..0000000 --- a/ResModl/src/androidTest/java/com/yutou/jianrmg_v2/resmodl/ExampleInstrumentedTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.yutou.jianrmg_v2.resmodl; - -import android.content.Context; -import android.support.test.InstrumentationRegistry; -import android.support.test.runner.AndroidJUnit4; - -import org.junit.Test; -import org.junit.runner.RunWith; - -import static org.junit.Assert.*; - -/** - * Instrumented test, which will execute on an Android device. - * - * @see Testing documentation - */ -@RunWith(AndroidJUnit4.class) -public class ExampleInstrumentedTest { - @Test - public void useAppContext() { - // Context of the app under test. - Context appContext = InstrumentationRegistry.getTargetContext(); - - assertEquals("com.yutou.jianrmg_v2.resmodl.test", appContext.getPackageName()); - } -} diff --git a/ResModl/src/main/res/layout/activity_download_list.xml b/ResModl/src/main/res/layout/activity_download_list.xml new file mode 100644 index 0000000..3509b84 --- /dev/null +++ b/ResModl/src/main/res/layout/activity_download_list.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/ResModl/src/main/res/layout/activity_mod.xml b/ResModl/src/main/res/layout/activity_mod.xml index ca37579..bfccde2 100644 --- a/ResModl/src/main/res/layout/activity_mod.xml +++ b/ResModl/src/main/res/layout/activity_mod.xml @@ -4,7 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="views.ModActivity"> + tools:context="ModActivity"> Testing documentation - */ -public class ExampleUnitTest { - @Test - public void addition_isCorrect() { - assertEquals(4, 2 + 2); - } -} \ No newline at end of file diff --git a/UserModel/src/main/java/com/jianrmg_v2/usermodel/Adapters/MyItemGridViewAdapter.java b/UserModel/src/main/java/com/jianrmg_v2/usermodel/Adapters/MyItemGridViewAdapter.java index 487de29..c52fd8c 100644 --- a/UserModel/src/main/java/com/jianrmg_v2/usermodel/Adapters/MyItemGridViewAdapter.java +++ b/UserModel/src/main/java/com/jianrmg_v2/usermodel/Adapters/MyItemGridViewAdapter.java @@ -1,6 +1,8 @@ package com.jianrmg_v2.usermodel.Adapters; import android.content.Context; +import android.content.Intent; +import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -8,8 +10,11 @@ import android.widget.BaseAdapter; import android.widget.ImageView; import android.widget.TextView; +import com.jianrmg_v2.usermodel.Views.DownloadListActivity; import com.yutou.jianrmg_v2.basemodel.R; +import com.yutou.jianrmg_v2.basemodel.Test; import com.yutou.jianrmg_v2.basemodel.Tools.Log; +import com.yutou.jianrmg_v2.basemodel.services.DownloadService; import java.util.List; @@ -76,6 +81,13 @@ public class MyItemGridViewAdapter extends BaseAdapter { @Override public void onClick(View view) { Log.i("点击"+list.get(i).getTitle()); + Intent intent=new Intent(context, Test.class); + switch (i){ + case 0: + intent.putExtra("activity",new DownloadListActivity()); + break; + } + context.startActivity(intent); } }); return view; diff --git a/UserModel/src/main/java/com/jianrmg_v2/usermodel/Views/DownloadListActivity.java b/UserModel/src/main/java/com/jianrmg_v2/usermodel/Views/DownloadListActivity.java new file mode 100644 index 0000000..495d8fe --- /dev/null +++ b/UserModel/src/main/java/com/jianrmg_v2/usermodel/Views/DownloadListActivity.java @@ -0,0 +1,67 @@ +package com.jianrmg_v2.usermodel.Views; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.view.KeyEvent; +import android.view.MotionEvent; +import android.widget.LinearLayout; + +import java.io.Serializable; + +import Interfaces.BaseActivityInterface; + +public class DownloadListActivity implements BaseActivityInterface ,Serializable { + private Context context; + private LinearLayout layout; + @Override + public void onCreate(Bundle savedInstanceState, LinearLayout layout, Context context, Intent intent) { + this.context=context; + this.layout=layout; + } + + @Override + public void onRestart() { + + } + + @Override + public void onResume() { + + } + + @Override + public void onPause() { + + } + + @Override + public void onDestroy() { + + } + + @Override + public void getIntent(Intent intent) { + + } + + @Override + public boolean onKeyDown(int keyCode, KeyEvent event) { + return false; + } + + @Override + public boolean onKeyUp(int keyCode, KeyEvent event) { + return false; + } + + @Override + public boolean onTouchEvent(MotionEvent event) { + return false; + } + + @Override + public Data getData() { + return null; + } +}