Commit 80f4f2d6 authored by Matthew Jones's avatar Matthew Jones Committed by Commit Bot

BottomToolbarMediator implements SceneChangeObserver directly

This patch has the BottomToolbarMediator implement SceneChangeObserver
rather than making it an anonymous class. This change also allows us
to remove the observer when the mediator is destroyed.

Change-Id: I045058f434e8638bc6c114dff4d1f0ed85059714
Reviewed-on: https://chromium-review.googlesource.com/1136988
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarPedro Amaral <amaralp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#575738}
parent 1d94c608
......@@ -32,7 +32,8 @@ import javax.annotation.Nullable;
* the model accordingly.
*/
class BottomToolbarMediator implements ContextualSearchObserver, FullscreenListener,
KeyboardVisibilityListener, OverviewModeObserver {
KeyboardVisibilityListener, OverviewModeObserver,
SceneChangeObserver {
/** The model for the bottom toolbar that holds all of its state. */
private BottomToolbarModel mModel;
......@@ -51,6 +52,9 @@ class BottomToolbarMediator implements ContextualSearchObserver, FullscreenListe
/** The previous height of the bottom toolbar. */
private int mBottomToolbarHeightBeforeHide;
/** Whether the swipe layout is currently active. */
private boolean mIsInSwipeLayout;
/**
* Build a new mediator that handles events from outside the bottom toolbar.
* @param model The {@link BottomToolbarModel} that holds all the state for the bottom toolbar.
......@@ -85,6 +89,9 @@ class BottomToolbarMediator implements ContextualSearchObserver, FullscreenListe
if (mContextualSearchManger != null) mContextualSearchManger.removeObserver(this);
if (mOverviewModeBehavior != null) mOverviewModeBehavior.removeOverviewModeObserver(this);
if (mWindowAndroid != null) mWindowAndroid.removeKeyboardVisibilityListener(this);
if (mModel.getValue(BottomToolbarModel.LAYOUT_MANAGER) != null) {
mModel.getValue(BottomToolbarModel.LAYOUT_MANAGER).removeSceneChangeObserver(this);
}
}
@Override
......@@ -159,10 +166,8 @@ class BottomToolbarMediator implements ContextualSearchObserver, FullscreenListe
void setLayoutManager(LayoutManager layoutManager) {
mModel.setValue(BottomToolbarModel.LAYOUT_MANAGER, layoutManager);
layoutManager.addSceneChangeObserver(new SceneChangeObserver() {
/** Whether the swipe layout is currently active. */
private boolean mIsInSwipeLayout;
layoutManager.addSceneChangeObserver(this);
}
@Override
public void onTabSelectionHinted(int tabId) {}
......@@ -178,8 +183,6 @@ class BottomToolbarMediator implements ContextualSearchObserver, FullscreenListe
mModel.setValue(BottomToolbarModel.ANDROID_VIEW_VISIBLE, true);
}
}
});
}
void setResourceManager(ResourceManager resourceManager) {
mModel.setValue(BottomToolbarModel.RESOURCE_MANAGER, resourceManager);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment