[6.9.0]
[fix] [offline] [提高获取时间的频率]
This commit is contained in:
@@ -73,6 +73,7 @@ class TimeProvider : TimeService {
|
||||
TAG,
|
||||
"时间信息_时间延迟较上次大 放弃此次同步${currentNetTime}___上次同步网络延迟${netTime}___时间差是:${offset}"
|
||||
)
|
||||
tryload()
|
||||
return
|
||||
}
|
||||
netTime = currentNetTime
|
||||
@@ -90,18 +91,7 @@ class TimeProvider : TimeService {
|
||||
"时间同步_请求时间信息成功:${data};时间差是:${offset}_路上的时间:${delay}"
|
||||
)
|
||||
|
||||
if (netTime > 3_000 || FunctionBuildConfig.isOffLine) {
|
||||
// 网络延迟大 10s 同步一次
|
||||
RxUtils.disposeSubscribe(nextGetTime)
|
||||
nextGetTime = RxUtils.createSubscribeOnOwnThread(30_000) {
|
||||
loadNewTime()
|
||||
}
|
||||
} else {
|
||||
RxUtils.disposeSubscribe(nextGetTime)
|
||||
nextGetTime = RxUtils.createSubscribeOnOwnThread(30 * 60_000) {
|
||||
loadNewTime()
|
||||
}
|
||||
}
|
||||
tryload()
|
||||
|
||||
}
|
||||
|
||||
@@ -135,6 +125,21 @@ class TimeProvider : TimeService {
|
||||
}
|
||||
}
|
||||
|
||||
fun tryload(){
|
||||
if (netTime > 3_000 || FunctionBuildConfig.isOffLine) {
|
||||
// 网络延迟大 10s 同步一次
|
||||
RxUtils.disposeSubscribe(nextGetTime)
|
||||
nextGetTime = RxUtils.createSubscribeOnOwnThread(30_000) {
|
||||
loadNewTime()
|
||||
}
|
||||
} else {
|
||||
RxUtils.disposeSubscribe(nextGetTime)
|
||||
nextGetTime = RxUtils.createSubscribeOnOwnThread(30 * 60_000) {
|
||||
loadNewTime()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getCurrentTimeStamp(): Long {
|
||||
d(TAG, "获取时间_${System.currentTimeMillis() + offset}")
|
||||
return System.currentTimeMillis() + offset
|
||||
|
||||
@@ -53,16 +53,16 @@ class GoLoginModel : ViewModel(), IBusLinesCallback {
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe({
|
||||
this.viewCallback?.setCountDownText("${it}s",false)
|
||||
CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "倒计时:$it")
|
||||
d(TAG, "倒计时:$it")
|
||||
}, {
|
||||
CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "倒计时onError:${it}")
|
||||
d(TAG, "倒计时onError:${it}")
|
||||
it.printStackTrace()
|
||||
this.viewCallback ?.setCountDownText("0",true)
|
||||
}, {
|
||||
RxUtils.createSubscribe(1_000) {
|
||||
this.viewCallback ?.setCountDownText("0s",true)
|
||||
}
|
||||
CallerLogger.d(SceneConstant.M_TAXI_P + TAG, "倒计时onComplete")
|
||||
d(TAG, "倒计时onComplete")
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user