完成启动图功能强化 (附带冷启动速度优化) https://git.ghzs.com/pm/halo-app-issues/-/issues/1131

This commit is contained in:
juntao
2021-01-25 12:01:28 +08:00
parent 9b893bcb42
commit fbe25c9099
19 changed files with 322 additions and 188 deletions

View File

@ -2,7 +2,6 @@ package com.gh.gamecenter;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
@ -28,6 +27,7 @@ import com.gh.common.AppExecutor;
import com.gh.common.constant.Config;
import com.gh.common.constant.Constants;
import com.gh.common.dialog.PrivacyDialogFragment;
import com.gh.common.util.AdHelper;
import com.gh.common.util.DataUtils;
import com.gh.common.util.DeviceTokenUtils;
import com.gh.common.util.DeviceUtils;
@ -285,45 +285,61 @@ public class SplashScreenActivity extends BaseActivity {
// 跳转到主界面
private void launchMainActivity() {
HaloApp.getInstance().postInit();
HaloApp.getInstance().postInit(true);
getUniqueId();
getAd();
prefetchData();
uploadTeaAndGdtData();
Bundle bundle = getIntent().getExtras();
Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
if (bundle != null) intent.putExtras(bundle);
if (bundle != null) {
intent.putExtras(bundle);
}
intent.putExtra(MainActivity.SHOW_AD, !mIsNewForThisVersion);
overridePendingTransition(0, 0);
startActivity(intent);
// TODO 是否可以放在子线程上报?
uploadTeaAndGdtData();
finish();
}
@SuppressLint("CheckResult")
private void getAd() {
AdHelper.getStartUpAd();
}
private void uploadTeaAndGdtData() {
// 在可能获取了相关权限后才初始化SDK/发送激活数据
if ("tea".equals(BuildConfig.FLAVOR)) {
// 在可能获取了相关权限后才初始化SDK/发送激活数据
// TeaHelper.init(getApplication(), HaloApp.getInstance().getChannel());
try {
Class<?> clazz = Class.forName("com.gh.gamecenter.TeaHelper");
Method method = clazz.getMethod("init", Context.class, String.class);
method.invoke(null, getApplication(), HaloApp.getInstance().getChannel());
} catch (Exception e) {
e.printStackTrace();
try {
Class<?> clazz = Class.forName("com.gh.gamecenter.TeaHelper");
Method method = clazz.getMethod("init", Context.class, String.class);
method.invoke(null, getApplication(), HaloApp.getInstance().getChannel());
} catch (Exception e) {
e.printStackTrace();
}
}
// GdtHelper.INSTANCE.logAction(ActionType.START_APP, GdtHelper.NETWORK_TYPE, DeviceUtils.getNetwork(this));
try {
Class<?> clazz = Class.forName("com.gh.gamecenter.GdtHelper");
Field field = clazz.getDeclaredField("NETWORK_TYPE");
String type = (String) field.get(null);
Method method = clazz.getMethod("logAction", String.class, String[].class);
Class<?> actionTypeClazz = Class.forName("com.qq.gdt.action.ActionType");
Field typeField = actionTypeClazz.getDeclaredField("START_APP");
String actionType = (String) typeField.get(null);
method.invoke(null, actionType, new String[]{type, DeviceUtils.getNetwork(this)});
} catch (Exception e) {
e.printStackTrace();
if ("gdt".equals(BuildConfig.FLAVOR)) {
try {
Class<?> clazz = Class.forName("com.gh.gamecenter.GdtHelper");
Field field = clazz.getDeclaredField("NETWORK_TYPE");
String type = (String) field.get(null);
Method method = clazz.getMethod("logAction", String.class, String[].class);
Class<?> actionTypeClazz = Class.forName("com.qq.gdt.action.ActionType");
Field typeField = actionTypeClazz.getDeclaredField("START_APP");
String actionType = (String) typeField.get(null);
method.invoke(null, actionType, new String[]{type, DeviceUtils.getNetwork(this)});
} catch (Exception e) {
e.printStackTrace();
}
}
}