mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-02 03:40:16 +00:00
[fenix] For https://github.com/mozilla-mobile/fenix/issues/10408: Dismiss menu when navigating away. (https://github.com/mozilla-mobile/fenix/pull/10415)
The menu is dismissed when toolbar view is detached from window.
This commit is contained in:
parent
3a123090dd
commit
1ca5625edd
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user