You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
1.1 KiB
Kotlin
32 lines
1.1 KiB
Kotlin
5 years ago
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||
|
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||
|
file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||
|
|
||
|
package org.mozilla.fenix.components.toolbar
|
||
|
|
||
|
import mozilla.components.browser.session.SelectionAwareSessionObserver
|
||
|
import mozilla.components.browser.session.Session
|
||
|
import mozilla.components.browser.session.SessionManager
|
||
|
import mozilla.components.browser.toolbar.BrowserToolbar
|
||
|
|
||
|
class MenuPresenter(
|
||
|
private val menuToolbar: BrowserToolbar,
|
||
|
sessionManager: SessionManager,
|
||
|
private val sessionId: String? = null
|
||
|
) : SelectionAwareSessionObserver(sessionManager) {
|
||
|
|
||
|
fun start() {
|
||
|
observeIdOrSelected(sessionId)
|
||
|
}
|
||
|
|
||
|
/** Redraw the refresh/stop button */
|
||
|
override fun onLoadingStateChanged(session: Session, loading: Boolean) {
|
||
|
menuToolbar.invalidateActions()
|
||
|
}
|
||
|
|
||
|
/** Redraw the back and forward buttons */
|
||
|
override fun onNavigationStateChanged(session: Session, canGoBack: Boolean, canGoForward: Boolean) {
|
||
|
menuToolbar.invalidateActions()
|
||
|
}
|
||
|
}
|