2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-02 03:40:16 +00:00
The menu is dismissed when toolbar view is detached from window.
This commit is contained in:
Mihai Adrian 2020-05-05 21:15:30 +03:00 committed by GitHub
parent 3a123090dd
commit 1ca5625edd

View File

@ -4,6 +4,7 @@
package org.mozilla.fenix.components.toolbar package org.mozilla.fenix.components.toolbar
import android.view.View
import mozilla.components.browser.session.SelectionAwareSessionObserver import mozilla.components.browser.session.SelectionAwareSessionObserver
import mozilla.components.browser.session.Session import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager import mozilla.components.browser.session.SessionManager
@ -14,10 +15,11 @@ class MenuPresenter(
private val menuToolbar: BrowserToolbar, private val menuToolbar: BrowserToolbar,
sessionManager: SessionManager, sessionManager: SessionManager,
private val sessionId: String? = null private val sessionId: String? = null
) : SelectionAwareSessionObserver(sessionManager) { ) : SelectionAwareSessionObserver(sessionManager), View.OnAttachStateChangeListener {
fun start() { fun start() {
observeIdOrSelected(sessionId) observeIdOrSelected(sessionId)
menuToolbar.addOnAttachStateChangeListener(this)
} }
/** Redraw the refresh/stop button */ /** Redraw the refresh/stop button */
@ -38,4 +40,12 @@ class MenuPresenter(
fun invalidateActions() { fun invalidateActions() {
menuToolbar.invalidateActions() menuToolbar.invalidateActions()
} }
override fun onViewDetachedFromWindow(v: View?) {
menuToolbar.onStop()
}
override fun onViewAttachedToWindow(v: View?) {
// no-op
}
} }