[fix]
[HttpHeaderInterceptor降频 去掉Delegates.observable]
This commit is contained in:
yangyakun
2025-07-09 18:59:02 +08:00
parent 443f1cafe1
commit fc24043cef
2 changed files with 28 additions and 23 deletions

View File

@@ -75,17 +75,7 @@ class HttpDnsStartUp : AndroidStartup<Boolean>(), IMoGoCloudListener {
@Volatile
private var gotToken = false
private var httpDnsSimpleLocation by Delegates.observable(getDefaultSimpleLocation()) { _, oldValue, newValue ->
if (gotToken && oldValue.cityCode != newValue.cityCode) {
if (handler.hasMessages(1)) {
handler.removeMessages(1)
}
val msg = Message.obtain()
msg.what = 1
msg.obj = Pair(oldValue.cityCode, newValue.cityCode)
handler.sendMessageDelayed(msg, 1000L * 10)
}
}
private var httpDnsSimpleLocation = getDefaultSimpleLocation()
override fun callCreateOnMainThread() = true
@@ -190,8 +180,8 @@ class HttpDnsStartUp : AndroidStartup<Boolean>(), IMoGoCloudListener {
val envConfig = CallerDevaToolsManager.getEnvConfig()
if (envConfig != null) {
// 更新
httpDnsSimpleLocation =
SimpleLocation(envConfig.cityCode, envConfig.lat, envConfig.lon)
checkCityCode(envConfig.cityCode)
httpDnsSimpleLocation = SimpleLocation(envConfig.cityCode, envConfig.lat, envConfig.lon)
return httpDnsSimpleLocation
}
val mogoLocation: MogoLocation =
@@ -202,13 +192,16 @@ class HttpDnsStartUp : AndroidStartup<Boolean>(), IMoGoCloudListener {
mogoLocation.cityCode.isNullOrEmpty() &&
!CallerMapUIServiceManager.getGDLocationServer()?.lastCityCode.isNullOrEmpty()
) {
val cityCode = (CallerMapUIServiceManager.getGDLocationServer()?.lastCityCode
?: "010")
checkCityCode(cityCode)
SimpleLocation(
CallerMapUIServiceManager.getGDLocationServer()?.lastCityCode
?: "010",
cityCode,
mogoLocation.latitude,
mogoLocation.longitude
)
} else {
checkCityCode(mogoLocation.cityCode)
SimpleLocation(
mogoLocation.cityCode,
mogoLocation.latitude,
@@ -222,6 +215,18 @@ class HttpDnsStartUp : AndroidStartup<Boolean>(), IMoGoCloudListener {
initAiCloudSDK()
}
private fun checkCityCode(cityCode: String) {
if (gotToken && cityCode != httpDnsSimpleLocation.cityCode) {
if (handler.hasMessages(1)) {
handler.removeMessages(1)
}
val msg = Message.obtain()
msg.what = 1
msg.obj = Pair(httpDnsSimpleLocation.cityCode, cityCode)
handler.sendMessageDelayed(msg, 1000L * 10)
}
}
@ChainLog(
linkChainLog = CHAIN_TYPE_STATUS,
linkCode = CHAIN_SOURCE_CLOUD,