[BadCase][Refactor]重构OCH相关调用

This commit is contained in:
renwj
2022-02-17 10:10:59 +08:00
parent 0554fe45ed
commit 70c6c1e8b2
5 changed files with 13 additions and 35 deletions

View File

@@ -204,8 +204,7 @@ public abstract class BaseOchBusTabFragment<V extends IView, P extends Presenter
mBadcaseBtn = findViewById(R.id.module_mogo_och_badcase_iv);
CallerHmiManager.INSTANCE.registerBadCaseCallback(
() -> { // onShow()
CallerHmiManager.INSTANCE.showBadCaseEntrance(mBadcaseBtn);
return null; },
return mBadcaseBtn; },
() -> { // onHide()
return null; });
}

View File

@@ -137,8 +137,7 @@ public abstract class BaseOchTaxiTabFragment<V extends IView, P extends Presente
mBadcaseBtn = findViewById(R.id.module_och_taxi_badcase_iv);
CallerHmiManager.INSTANCE.registerBadCaseCallback(
() -> { // onShow()
CallerHmiManager.INSTANCE.showBadCaseEntrance(mBadcaseBtn);
return null; },
return mBadcaseBtn; },
() -> { // onHide()
return null; });

View File

@@ -94,7 +94,7 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
private var autoPilotBadCaseView: AutoPilotBadCaseView? = null
private var onBadCaseShow: (() -> Unit)? = null
private var onBadCaseShow: (() -> View)? = null
private var onBadCaseHide: (() -> Unit)? = null
companion object {
@@ -318,19 +318,12 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
}
dismissBadCaseEntryAfterSomeTime()
} else {
onBadCaseShow?.invoke()
}
}
}
override fun showBadCaseEntrance(entrance: View) {
entrance.lifecycleOwner.lifecycle.addObserver(badCaseEntranceObserver)
autoPilotBadCaseEntrance = entrance
lifecycleScope.launch {
withContext(Dispatchers.IO) {
val dao = Repository.dao()
dao.getAllUnConsumedRecords()?.first()?.let {
showBadCaseEntrance(it)
val view = onBadCaseShow?.invoke()
if (view != null) {
view.lifecycleOwner.lifecycle.addObserver(badCaseEntranceObserver)
view.visibility = View.GONE
autoPilotBadCaseEntrance = view
showBadCaseEntrance(record)
}
}
}
@@ -344,7 +337,7 @@ class MoGoHmiFragment : MvpFragment<MoGoWarningContract.View?, WaringPresenter?>
}
}
override fun registerBadCaseCallback(onShow: () -> Unit, onHide: (() -> Unit)?) {
override fun registerBadCaseCallback(onShow: () -> View, onHide: (() -> Unit)?) {
onBadCaseShow = onShow
onBadCaseHide = onHide
}

View File

@@ -181,16 +181,10 @@ interface IMoGoWaringProvider {
fun showAdUpgradeStatus(upgradeMode : Int,downloadStatus : Int,currentProgress : Int,totalProgress : Int
,downloadVersion : String,upgradeStatus : Int)
/**
* 显示BadCase入口
*/
fun showBadCaseEntrance(entrance: View)
/**
* 注册badcase入口展示和隐藏的回调
* 当[onShow]被调用时,调用[showBadCaseEntrance]
* [onHide]回调不用关心,可以不注册
*/
fun registerBadCaseCallback(onShow:() -> Unit, onHide: (() -> Unit)?)
fun registerBadCaseCallback(onShow:() -> View, onHide: (() -> Unit)?)
}

View File

@@ -257,19 +257,12 @@ object CallerHmiManager : CallerBase() {
waringProviderApi?.showAdUpgradeStatus(upgradeMode,downloadStatus, currentProgress, totalProgress, downloadVersion, upgradeStatus)
}
/**
* 显示BadCase入口
*/
fun showBadCaseEntrance(entrance: View) {
waringProviderApi?.showBadCaseEntrance(entrance)
}
/**
* 注册badcase入口展示和隐藏的回调
* 当[onShow]被调用时,调用[showBadCaseEntrance]
* 当[onShow]被调用时, 表示达到展示条件,返回展示的入口控件
* [onHide]回调不用关心,可以不注册
*/
fun registerBadCaseCallback(onShow:() -> Unit, onHide: (() -> Unit)?) {
fun registerBadCaseCallback(onShow:() -> View, onHide: (() -> Unit)?) {
waringProviderApi?.registerBadCaseCallback(onShow, onHide)
}