1
0
Fork 0

For #10408: Dismiss menu when navigating away. (#10415)

The menu is dismissed when toolbar view is detached from window.
master
Mihai Adrian 2020-05-05 21:15:30 +03:00 committed by GitHub
parent d2a3613b73
commit 5106134786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

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