[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

@@ -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
}