修复热更依耐性

This commit is contained in:
Yutousama 2018-04-19 14:43:50 +08:00
parent f4ce57882e
commit 58c306dafd
13 changed files with 173 additions and 148 deletions

View File

@ -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;
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();
}
}

View File

@ -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<MAppMg> {
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);
}

View File

@ -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<TMod> {
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);
}

View File

@ -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;

View File

@ -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));

View File

@ -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;

View File

@ -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();
}
}

View File

@ -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 <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@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());
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
</LinearLayout>

View File

@ -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">
<ScrollView
android:layout_width="match_parent"

View File

@ -1,17 +0,0 @@
package com.yutou.jianrmg_v2.resmodl;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

View File

@ -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;

View File

@ -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;
}
}