|
@@ -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() {
|