Browse Source

调整bugly初始化

Pq 3 years ago
parent
commit
2023255007

+ 7 - 1
student/src/main/java/com/cooleshow/student/App.java

@@ -85,13 +85,19 @@ public class App extends BaseApplication {
         JPushInterface.setDebugMode(true);
         JCollectionAuth.setAuth(this, UserHelper.isAgreePrivacy());
         registrationId = JPushInterface.getRegistrationID(this);
-        CrashReport.initCrashReport(getApplicationContext(), "b51fd73164", false);
+        initBugly();
         initRong();
         initUmeng();
         //二维码扫描
         ZXingLibrary.initDisplayOpinion(this);
     }
 
+    private void initBugly() {
+        if (UserHelper.isAgreePrivacy()) {
+            CrashReport.initCrashReport(getApplicationContext(), "b51fd73164", false);
+        }
+    }
+
     private void initUmeng() {
         if (UserHelper.isAgreePrivacy()) {
             UMConfigure.init(this, "5f2b6f03b4b08b653e91a49e", "app", UMConfigure.DEVICE_TYPE_PHONE, null);

+ 31 - 0
student/src/main/java/com/cooleshow/student/helper/InitHelper.java

@@ -0,0 +1,31 @@
+package com.cooleshow.student.helper;
+
+import com.cooleshow.base.common.BaseApplication;
+import com.cooleshow.base.utils.Utils;
+import com.tencent.bugly.crashreport.CrashReport;
+import com.umeng.commonsdk.UMConfigure;
+
+import cn.jiguang.api.utils.JCollectionAuth;
+import cn.jpush.android.api.JPushInterface;
+
+/**
+ * Author by pq, Date on 2022/7/25.
+ */
+public class InitHelper {
+    public static void initSdK() {
+        //bugly
+        CrashReport.initCrashReport(Utils.getApp(), "b51fd73164", false);
+        //友盟
+        UMConfigure.init(
+                Utils.getApp(),
+                "5f2b6f03b4b08b653e91a49e",
+                "app",
+                UMConfigure.DEVICE_TYPE_PHONE,
+                null
+        );
+        //极光推送
+        //用户同意之后才初始化极光推送
+        JCollectionAuth.setAuth(Utils.getApp(), true);
+        BaseApplication.registrationId = JPushInterface.getRegistrationID(Utils.getApp());
+    }
+}

+ 2 - 12
student/src/main/java/com/cooleshow/student/ui/splash/SplashActivity.kt

@@ -23,6 +23,7 @@ import com.cooleshow.base.utils.SPUtils
 import com.cooleshow.base.utils.ToastUtil
 import com.cooleshow.base.widgets.dialog.PrivacyTipDialog
 import com.cooleshow.student.databinding.ActivitySplashLayoutBinding
+import com.cooleshow.student.helper.InitHelper
 import com.cooleshow.usercenter.constants.UserConstants
 import com.cooleshow.usercenter.helper.UserHelper
 import com.cooleshow.usercenter.ui.activity.VerifyCodeLoginActivity
@@ -126,18 +127,7 @@ class SplashActivity : BaseActivity<ActivitySplashLayoutBinding>() {
         }
         dialog.setOnConfirmClickListener {
             UserHelper.setAppPrivacyModeIsAgree()
-            //友盟
-            UMConfigure.init(
-                this.applicationContext,
-                "5f2b6f03b4b08b653e91a49e",
-                "app",
-                UMConfigure.DEVICE_TYPE_PHONE,
-                null
-            )
-            //极光推送
-            //用户同意之后才初始化极光推送
-            JCollectionAuth.setAuth(this.applicationContext, true)
-            BaseApplication.registrationId = JPushInterface.getRegistrationID(this.applicationContext)
+            InitHelper.initSdK();
             goIntent()
         }
     }

+ 10 - 9
teacher/src/main/java/com/cooleshow/teacher/App.java

@@ -72,8 +72,7 @@ public class App extends BaseApplication {
         if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
             webviewSetPath(this);
         }
-        CrashReport.initCrashReport(getApplicationContext(), "c4d163184a", false);
-
+        initBugly();
         //极光推送
         JPushInterface.setDebugMode(true);
         JCollectionAuth.setAuth(this, UserHelper.isAgreePrivacy());
@@ -83,15 +82,17 @@ public class App extends BaseApplication {
         //二维码扫描
         ZXingLibrary.initDisplayOpinion(this);
     }
-  /*  public static String channel;
-    public void initBaseOtherSdk() {
-        channel = WalleChannelReader.getChannel(this);
-    }*/
+
+    private void initBugly() {
+        if (UserHelper.isAgreePrivacy()) {
+            CrashReport.initCrashReport(getApplicationContext(), "c4d163184a", false);
+        }
+    }
 
     private void initUmeng() {
-        if(UserHelper.isAgreePrivacy()){
+        if (UserHelper.isAgreePrivacy()) {
             UMConfigure.init(this, "62a8394605844627b5b0554b", "app", UMConfigure.DEVICE_TYPE_PHONE, null);
-        }else{
+        } else {
             UMConfigure.preInit(this, "62a8394605844627b5b0554b", "app");
         }
 
@@ -169,7 +170,7 @@ public class App extends BaseApplication {
     public String getProcessName(Context context) {
         if (context == null)
             return null;
-        if(!UserHelper.isAgreePrivacy()){
+        if (!UserHelper.isAgreePrivacy()) {
             return null;
         }
         ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);

+ 29 - 0
teacher/src/main/java/com/cooleshow/teacher/helper/InitHelper.java

@@ -0,0 +1,29 @@
+package com.cooleshow.teacher.helper;
+
+import com.cooleshow.base.common.BaseApplication;
+import com.cooleshow.base.utils.Utils;
+import com.tencent.bugly.crashreport.CrashReport;
+import com.umeng.commonsdk.UMConfigure;
+
+import cn.jiguang.api.utils.JCollectionAuth;
+import cn.jpush.android.api.JPushInterface;
+
+/**
+ * Author by pq, Date on 2022/7/25.
+ */
+public class InitHelper {
+    public static void initSdK() {
+        CrashReport.initCrashReport(Utils.getApp(), "c4d163184a", false);
+        UMConfigure.init(
+                Utils.getApp(),
+                "62a8394605844627b5b0554b",
+                "app",
+                UMConfigure.DEVICE_TYPE_PHONE,
+                null
+        );
+        //极光推送
+        //用户同意之后才初始化极光推送
+        JCollectionAuth.setAuth(Utils.getApp(), true);
+        BaseApplication.registrationId = JPushInterface.getRegistrationID(Utils.getApp());
+    }
+}

+ 1 - 11
teacher/src/main/java/com/cooleshow/teacher/ui/splash/SplashActivity.kt

@@ -119,17 +119,7 @@ class SplashActivity : BaseActivity<ActivitySplashLayoutBinding>() {
         }
         dialog.setOnConfirmClickListener {
             UserHelper.setAppPrivacyModeIsAgree()
-            UMConfigure.init(
-                this.applicationContext,
-                "62a8394605844627b5b0554b",
-                "app",
-                UMConfigure.DEVICE_TYPE_PHONE,
-                null
-            )
-            //极光推送
-            //用户同意之后才初始化极光推送
-            JCollectionAuth.setAuth(this.applicationContext, true)
-            BaseApplication.registrationId = JPushInterface.getRegistrationID(this.applicationContext)
+
             goIntent()
         }
     }