[状态栏]优化状态栏隐藏逻辑
This commit is contained in:
@@ -107,7 +107,7 @@ class DevaToolsProvider : IDevaToolsProvider {
|
||||
StatusManager.show(container)
|
||||
}
|
||||
|
||||
override fun hideStatusBar(container: ViewGroup) {
|
||||
StatusManager.hide(container)
|
||||
override fun hideStatusBar() {
|
||||
StatusManager.hide()
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import com.zhjt.mogo_core_function_devatools.status.ui.StatusView
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.*
|
||||
import mogo_msg.MogoReportMsg
|
||||
import java.lang.ref.*
|
||||
import java.util.concurrent.*
|
||||
|
||||
|
||||
@@ -43,6 +44,7 @@ object StatusManager {
|
||||
private var timer: Job? = null
|
||||
private var hasInit = false
|
||||
private val listeners by lazy { CopyOnWriteArrayList<IStatusListener>() }
|
||||
private var container: WeakReference<ViewGroup>? = null
|
||||
|
||||
private val listener = object : IMoGoAutopilotStatusListener {
|
||||
override fun onAutopilotGuardian(guardianInfo: MogoReportMsg.MogoReportMessage?) {
|
||||
@@ -152,15 +154,15 @@ object StatusManager {
|
||||
}
|
||||
return
|
||||
}
|
||||
this.container = WeakReference(container)
|
||||
val child = StatusView(model, container.context)
|
||||
container.addView(child, ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT))
|
||||
}
|
||||
|
||||
fun hide(container: ViewGroup) {
|
||||
container.visibility = View.GONE
|
||||
fun hide() {
|
||||
container?.get()?.takeIf { it.visibility == View.VISIBLE }?.run { visibility = View.GONE }
|
||||
}
|
||||
|
||||
|
||||
private fun onDestroy(ctx: Context) {
|
||||
hasInit = false
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
|
||||
Reference in New Issue
Block a user