将应用初始化的操作移动到子线程,缩短启动速度

This commit is contained in:
chenjuntao
2018-11-28 17:41:11 +08:00
parent 3b1556f931
commit 1968f4b7f3
2 changed files with 54 additions and 54 deletions

View File

@ -185,7 +185,6 @@ public class SplashScreenActivity extends BaseActivity {
@Override
public void onSuccess(String s) {
Utils.log("Gid", s);
// Utils.toast(SplashScreenActivity.this, "光环ID -> " + s);
mSharedPreferences.edit().putString(Constants.DEVICE_KEY, s).apply();
HaloApp.getInstance().setGid(s);
@ -204,32 +203,31 @@ public class SplashScreenActivity extends BaseActivity {
if (hasFocus && isFirst) {
isFirst = false;
// 第一次启动把package.txt文件内容加载进数据库
FilterManager filterManager = new FilterManager(getApplicationContext());
if (!mSharedPreferences.getBoolean("isLoadFilterV2d4", false)) {
filterManager.loadFilter();
}
// 获取过滤包
filterManager.getFilterFromServer(0);
HaloApp.getInstance().getMainExecutor().execute(() -> {
// 第一次启动把package.txt文件内容加载进数据库
FilterManager filterManager = new FilterManager(getApplicationContext());
if (!mSharedPreferences.getBoolean("isLoadFilterV2d4", false)) {
filterManager.loadFilter();
}
// 获取过滤包
filterManager.getFilterFromServer(0);
// 更新过滤表获取自动刷新的cd获取版本对应表
String time = mSharedPreferences.getString("refresh_time", null);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
String today = format.format(new Date());
if (!today.equals(time)) {
// 获取版本代码、名称
PlatformUtils.getInstance(getApplicationContext()).getPlatform();
TagUtils.getInstance(getApplicationContext()).getTag();
}
// 更新过滤表获取自动刷新的cd获取版本对应表
String time = mSharedPreferences.getString("refresh_time", null);
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd", Locale.getDefault());
String today = format.format(new Date());
if (!today.equals(time)) {
// 获取版本代码、名称
PlatformUtils.getInstance(getApplicationContext()).getPlatform();
TagUtils.getInstance(getApplicationContext()).getTag();
}
// 更新本地时间
DeviceTokenUtils.syncServerTime(this);
// 更新本地时间
DeviceTokenUtils.syncServerTime(this);
// // 上传数据---基于上报信息涉及用户权限 防止由于未授予权限导致的闪退 移动MainActivity上报
// DataCollectionManager.getInstance(getApplicationContext()).upload();
// 解决助手奔溃后导致的下载状态保留问题
DownloadManager.getInstance(this).checkAll();
// 解决助手奔溃后导致的下载状态保留问题
DownloadManager.getInstance(this).checkAll();
});
// 检查权限
if (EasyPermissions.hasPermissions(this, mPermissions)) {