-
Notifications
You must be signed in to change notification settings - Fork 68
/
App.java
126 lines (106 loc) · 4.71 KB
/
App.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
package com.kongzue.baseframeworkdemo;
import android.content.DialogInterface;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import com.kongzue.baseframework.BaseApp;
import com.kongzue.baseframework.BaseFrameworkSettings;
import com.kongzue.baseframework.interfaces.OnBugReportListener;
import com.kongzue.baseframework.interfaces.OnSDKInitializedCallBack;
import com.kongzue.baseframework.util.AppManager;
import com.kongzue.baseframework.util.AsyncActivityLayoutLoader;
import com.kongzue.baseframework.util.SettingsUtil;
import com.kongzue.baseframeworkdemo.activity.AdapterTestActivity;
import com.kongzue.baseframeworkdemo.activity.DemoActivity;
import com.kongzue.baseframeworkdemo.activity.JumpActivity;
import com.kongzue.baseframeworkdemo.activity.ResponseActivity;
import com.kongzue.baseframeworkdemo.activity.TransitionActivity;
import com.kongzue.baseframeworkdemo.fragment.AboutFragment;
import com.kongzue.baseframeworkdemo.fragment.FunctionFragment;
import com.kongzue.baseframeworkdemo.fragment.IntroductionFragment;
import com.kongzue.baseframeworkdemo.util.User;
import java.io.File;
/**
* Author: @Kongzue
* Github: https://github.com/kongzue/
* Homepage: http://kongzue.com/
* Mail: [email protected]
* CreateTime: 2018/9/30 04:12
*/
public class App extends BaseApp<App> {
@Override
public void init() {
// AsyncActivityLayoutLoader.preCreateActivityLayoutCache(AdapterTestActivity.class);
// AsyncActivityLayoutLoader.preCreateActivityLayoutCache(DemoActivity.class);
// AsyncActivityLayoutLoader.preCreateActivityLayoutCache(JumpActivity.class);
// AsyncActivityLayoutLoader.preCreateActivityLayoutCache(ResponseActivity.class);
// AsyncActivityLayoutLoader.preCreateActivityLayoutCache(TransitionActivity.class);
// AsyncActivityLayoutLoader.preCreateActivityLayoutCache(AboutFragment.class);
// AsyncActivityLayoutLoader.preCreateActivityLayoutCache(FunctionFragment.class);
// AsyncActivityLayoutLoader.preCreateActivityLayoutCache(IntroductionFragment.class);
// try {
// Thread.sleep(2000);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
setOnSDKInitializedCallBack(new OnSDKInitializedCallBack() {
@Override
public void onInitialized() {
log("onInitialized: ");
Toast.makeText(me, "SDK已加载完毕", Toast.LENGTH_LONG).show();
}
});
setOnCrashListener(new OnBugReportListener() {
@Override
public boolean onCrash(Exception e, final File crashLogFile) {
if (AppManager.getInstance().getActiveActivity() == null || !AppManager.getInstance().getActiveActivity().isActive) {
return false;
}
AlertDialog.Builder builder = new AlertDialog.Builder(AppManager.getInstance().getActiveActivity());
builder.setTitle("Ops!发生了一次崩溃!");
builder.setMessage("您是否愿意帮助我们改进程序以修复此Bug?");
builder.setPositiveButton("愿意", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
toast("请对file进行处理:" + crashLogFile.getAbsolutePath());
}
});
builder.setNegativeButton("不了", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
});
builder.setCancelable(false);
AlertDialog dialog = builder.create();
dialog.show();
return false;
}
});
// Bitmap bm = null; //随便写的 Demo
// App.cache.set("key","value");
// App.cache.set("bitmap",bm);
// App.cache.clean();
User user = new User("张三", 18, "192.168.1.1");
App.user.set("userInfo", user);
}
public static USER user = new USER();
public static class USER extends SettingsUtil {
public USER() {
super("user");
}
}
public static CACHE cache;
public static class CACHE extends SettingsUtil {
public CACHE() {
super("cache");
}
}
@Override
public void initSDKs() {
BaseFrameworkSettings.DEBUGMODE = true;
BaseFrameworkSettings.BETA_PLAN = true;
try {
Thread.sleep(8000);
} catch (Exception e) {
}
}
}