fix bug of init twice

This commit is contained in:
zhongchao
2022-09-15 22:16:41 +08:00
parent 74c7bc3fe2
commit f26bd7aea5
6 changed files with 22 additions and 21 deletions

View File

@@ -31,9 +31,12 @@ class DevaToolsProvider : IDevaToolsProvider {
override fun init(context: Context) {
mContext = context
bizConfigCenter.init(context)
traceManager.init(context)
MogoLogCatchManager.init(context)
}
override fun initBiz() {
bizConfigCenter.init(mContext!!)
traceManager.init(mContext!!)
MogoLogCatchManager.init(mContext!!)
}
override fun startLogCatch() {

View File

@@ -1,7 +1,6 @@
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
@@ -37,7 +36,6 @@ 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)
}, {
@@ -55,7 +53,7 @@ class FuncConfigCenter : IMogoOnMessageListener<FuncConfig> {
override fun onMsgReceived(obj: FuncConfig?) {
obj?.let {
// refreshConfig(it)
refreshConfig(it)
}
}

View File

@@ -3,18 +3,11 @@ 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 {
@@ -27,13 +20,16 @@ class FuncConfigNetWorkModel {
private var success: ((FuncConfig) -> Unit)? = null
private var error: ((String) -> Unit)? = null
fun requestFuncConfig(onSuccess: ((FuncConfig) -> Unit)? = null, onError: ((String) -> Unit)? = null) {
fun requestFuncConfig(
onSuccess: ((FuncConfig) -> Unit)? = null,
onError: ((String) -> Unit)? = null
) {
request<BaseResponse<FuncConfig>> {
start {
if(success == null){
if (success == null) {
success = onSuccess
}
if(error == null){
if (error == null) {
error = onError
}
}
@@ -61,8 +57,7 @@ class FuncConfigNetWorkModel {
retryTime += 1
requestFuncConfig()
} else if (it.message != null) {
Log.i("emArrow-0915"," onError : $retryTime")
error?.invoke(it.message?:"FuncConfig error msg is null")
error?.invoke(it.message ?: "FuncConfig error msg is null")
}
}