浏览代码

1.更新登录请求逻辑 20-40s调用一次

JaycePC 10 月之前
父节点
当前提交
0a00ac478d

+ 1 - 0
.gitignore

@@ -10,3 +10,4 @@
 .externalNativeBuild
 .cxx
 local.properties
+/release

二进制
app/release/Chemical_Xibei_1.19.apk


+ 0 - 18
app/release/output-metadata.json

@@ -1,18 +0,0 @@
-{
-  "version": 2,
-  "artifactType": {
-    "type": "APK",
-    "kind": "Directory"
-  },
-  "applicationId": "com.zhong.che",
-  "variantName": "processReleaseResources",
-  "elements": [
-    {
-      "type": "SINGLE",
-      "filters": [],
-      "versionCode": 19,
-      "versionName": "1.19",
-      "outputFile": "Chemical_Xibei_1.19.apk"
-    }
-  ]
-}

+ 23 - 3
app/src/main/java/com/example/chemical/ui/SplashActivity.kt

@@ -10,6 +10,7 @@ import android.os.Handler
 import android.view.LayoutInflater
 import androidx.core.content.FileProvider
 import com.blankj.utilcode.util.LogUtils
+import com.blankj.utilcode.util.SPUtils
 import com.example.chemical.BuildConfig
 import com.example.chemical.ChemicalApp
 import com.example.chemical.comm.Constants
@@ -30,6 +31,7 @@ import com.rc.httpcore.HttpConfig
 import com.rc.httpcore.client.ApiRepository
 import com.tbruyelle.rxpermissions2.RxPermissions
 import java.io.File
+import java.util.concurrent.ThreadLocalRandom
 
 class SplashActivity : RcBaseActivity<ActivitySplashBinding>() {
 
@@ -70,6 +72,8 @@ class SplashActivity : RcBaseActivity<ActivitySplashBinding>() {
             queryAppVersion()
         } else {
             if (!isOk) {
+                SPUtils.getInstance()
+                    .put("interval", (ThreadLocalRandom.current().nextInt(20, 40) * 1000).toLong())
                 // 启动定时任务
                 myHandler.start()
                 isOk = true
@@ -212,6 +216,12 @@ class SplashActivity : RcBaseActivity<ActivitySplashBinding>() {
                                     } catch (e: Exception) {
 
                                     } finally {
+                                        SPUtils.getInstance()
+                                            .put(
+                                                "interval",
+                                                (ThreadLocalRandom.current()
+                                                    .nextInt(20, 40) * 1000).toLong()
+                                            )
                                         myHandler.start()
                                     }
                                     showToast("版本信息不不存在")
@@ -227,6 +237,11 @@ class SplashActivity : RcBaseActivity<ActivitySplashBinding>() {
                     showNetError(throwable)
                     if (!isOk) {
                         // 启动定时任务
+                        SPUtils.getInstance()
+                            .put(
+                                "interval",
+                                (ThreadLocalRandom.current().nextInt(20, 40) * 1000).toLong()
+                            )
                         myHandler.start()
                         isOk = true
                     }
@@ -253,6 +268,11 @@ class SplashActivity : RcBaseActivity<ActivitySplashBinding>() {
                 } catch (e: Exception) {
 
                 } finally {
+                    SPUtils.getInstance()
+                        .put(
+                            "interval",
+                            (ThreadLocalRandom.current().nextInt(20, 40) * 1000).toLong()
+                        )
                     myHandler.start()
                 }
             }
@@ -287,17 +307,17 @@ class SplashActivity : RcBaseActivity<ActivitySplashBinding>() {
         private val handler = Handler()
 
         //        private val interval: Long = 10 * 60 * 1000 // 10分钟
-        private val interval: Long = 10000 // 10秒
+
 
         private val runnable = object : Runnable {
             override fun run() {
                 callback.invoke()
-                handler.postDelayed(this, interval)
+                handler.postDelayed(this, SPUtils.getInstance().getLong("interval", 10000L))
             }
         }
 
         fun start() {
-            handler.postDelayed(runnable, interval)
+            handler.postDelayed(runnable, SPUtils.getInstance().getLong("interval", 10000L))
         }
 
         fun stop() {

+ 2 - 2
config/config.gradle

@@ -9,8 +9,8 @@ ext {
             minSdkVersion    : 21,
             targetSdkVersion : 28,
             applicationId    : "com.zhong.che",
-            versionCode      : 19,
-            versionName      : "1.19"
+            versionCode      : 20,
+            versionName      : "1.20"
     ]
 
     test = [