..
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.zhjt.mogo_core_function_devatools.funcconfig
|
||||
|
||||
import android.content.Context
|
||||
import android.util.Log
|
||||
import com.mogo.aicloud.services.socket.IMogoOnMessageListener
|
||||
import com.mogo.aicloud.services.socket.MogoAiCloudSocketManager
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
@@ -36,6 +37,7 @@ class FuncConfigCenter : IMogoOnMessageListener<FuncConfig> {
|
||||
.registerOnMessageListener(FUNC_CONFIG_TYPE, this)
|
||||
UiThreadHandler.postDelayed({
|
||||
funcConfigNetWorkModel.requestFuncConfig({
|
||||
Log.i("emArrow-0915","config : $it")
|
||||
SPUtils.getInstance("biz_config").put("config", GsonUtils.toJson(it))
|
||||
refreshConfig(it)
|
||||
}, {
|
||||
@@ -43,7 +45,7 @@ class FuncConfigCenter : IMogoOnMessageListener<FuncConfig> {
|
||||
.getString("config", GsonUtils.toJson(defaultFuncConfig()))
|
||||
refreshConfig(GsonUtils.fromJson(bizJson, FuncConfig::class.java))
|
||||
})
|
||||
}, 2000L)
|
||||
}, 1000L * 30)
|
||||
|
||||
}
|
||||
|
||||
@@ -53,7 +55,7 @@ class FuncConfigCenter : IMogoOnMessageListener<FuncConfig> {
|
||||
|
||||
override fun onMsgReceived(obj: FuncConfig?) {
|
||||
obj?.let {
|
||||
refreshConfig(it)
|
||||
// refreshConfig(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,20 @@
|
||||
package com.zhjt.mogo_core_function_devatools.funcconfig.network
|
||||
|
||||
import android.util.Log
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.eagle.core.data.BaseResponse
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import com.mogo.eagle.core.network.request
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.DeviceUtils
|
||||
import com.mogo.module.common.constants.HostConst
|
||||
import com.zhjt.mogo_core_function_devatools.funcconfig.FuncConfigConst
|
||||
import com.zhjt.service_biz.FuncConfig
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
|
||||
class FuncConfigNetWorkModel {
|
||||
|
||||
@@ -18,9 +24,19 @@ class FuncConfigNetWorkModel {
|
||||
}
|
||||
|
||||
private var retryTime = 0
|
||||
private var success: ((FuncConfig) -> Unit)? = null
|
||||
private var error: ((String) -> Unit)? = null
|
||||
|
||||
fun requestFuncConfig(onSuccess: ((FuncConfig) -> Unit), onError: ((String) -> Unit)) {
|
||||
fun requestFuncConfig(onSuccess: ((FuncConfig) -> Unit)? = null, onError: ((String) -> Unit)? = null) {
|
||||
request<BaseResponse<FuncConfig>> {
|
||||
start {
|
||||
if(success == null){
|
||||
success = onSuccess
|
||||
}
|
||||
if(error == null){
|
||||
error = onError
|
||||
}
|
||||
}
|
||||
loader {
|
||||
val map = mutableMapOf<String, Any>()
|
||||
map["sn"] = MoGoAiCloudClientConfig.getInstance().sn
|
||||
@@ -30,23 +46,25 @@ class FuncConfigNetWorkModel {
|
||||
}
|
||||
onSuccess {
|
||||
if (it.result != null) {
|
||||
onSuccess.invoke(it.result)
|
||||
success?.invoke(it.result)
|
||||
} else {
|
||||
if (retryTime <= 3) {
|
||||
if (retryTime < 3) {
|
||||
retryTime += 1
|
||||
requestFuncConfig(onSuccess, onError)
|
||||
requestFuncConfig()
|
||||
} else {
|
||||
onError.invoke("manualControl result is null")
|
||||
error?.invoke("FuncConfig error msg is null")
|
||||
}
|
||||
}
|
||||
}
|
||||
onError {
|
||||
if (retryTime <= 3) {
|
||||
if (retryTime < 3) {
|
||||
retryTime += 1
|
||||
requestFuncConfig(onSuccess, onError)
|
||||
requestFuncConfig()
|
||||
} else if (it.message != null) {
|
||||
onError.invoke(it.message!!)
|
||||
Log.i("emArrow-0915"," onError : $retryTime")
|
||||
error?.invoke(it.message?:"FuncConfig error msg is null")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user