[Misc] Only create KeyguardStatusBarViewController once inside

NotificationPanelViewController.

The KeyguardStatusBarView never changes, so we don't need to
re-create its controller in NPVController#updateViewControllers.

Fixes: 194181195
Test: atest and manual

Change-Id: If955a8d6167a08bec6e7a7e9e66a2c6a55f68966
This commit is contained in:
Caitlin Cassidy
2021-08-02 14:37:45 +00:00
parent 02ce38c2cf
commit 0c2b77e5ac
4 changed files with 6 additions and 40 deletions

View File

@@ -47,12 +47,6 @@ public class BatteryMeterViewController extends ViewController<BatteryMeterView>
@Override @Override
protected void onViewDetached() { protected void onViewDetached() {
destroy();
}
@Override
public void destroy() {
super.destroy();
mConfigurationController.removeCallback(mConfigurationListener); mConfigurationController.removeCallback(mConfigurationListener);
} }
} }

View File

@@ -159,17 +159,6 @@ public class KeyguardStatusBarViewController extends ViewController<KeyguardStat
@Override @Override
protected void onViewDetached() { protected void onViewDetached() {
destroy();
}
@Override
public void destroy() {
// Don't receive future #onViewAttached calls so that we don't accidentally have two
// controllers registered for the same view.
// TODO(b/194181195): This shouldn't be necessary.
super.destroy();
mBatteryMeterViewController.destroy();
mConfigurationController.removeCallback(mConfigurationListener); mConfigurationController.removeCallback(mConfigurationListener);
mAnimationScheduler.removeCallback(mAnimationCallback); mAnimationScheduler.removeCallback(mAnimationCallback);
mUserInfoController.removeCallback(mOnUserInfoChangedListener); mUserInfoController.removeCallback(mOnUserInfoChangedListener);

View File

@@ -928,10 +928,14 @@ public class NotificationPanelViewController extends PanelViewController {
} }
} }
mKeyguardStatusBarViewController =
mKeyguardStatusBarViewComponentFactory.build(mKeyguardStatusBar)
.getKeyguardStatusBarViewController();
mKeyguardStatusBarViewController.init();
updateViewControllers( updateViewControllers(
mView.findViewById(R.id.keyguard_status_view), mView.findViewById(R.id.keyguard_status_view),
userAvatarView, userAvatarView,
mKeyguardStatusBar,
keyguardUserSwitcherView, keyguardUserSwitcherView,
mCommunalView, mCommunalView,
mView.findViewById(R.id.idle_host_view)); mView.findViewById(R.id.idle_host_view));
@@ -1025,7 +1029,6 @@ public class NotificationPanelViewController extends PanelViewController {
private void updateViewControllers(KeyguardStatusView keyguardStatusView, private void updateViewControllers(KeyguardStatusView keyguardStatusView,
UserAvatarView userAvatarView, UserAvatarView userAvatarView,
KeyguardStatusBarView keyguardStatusBarView,
KeyguardUserSwitcherView keyguardUserSwitcherView, KeyguardUserSwitcherView keyguardUserSwitcherView,
CommunalHostView communalView, CommunalHostView communalView,
IdleHostView idleHostView) { IdleHostView idleHostView) {
@@ -1039,16 +1042,6 @@ public class NotificationPanelViewController extends PanelViewController {
mIdleHostViewController = idleViewComponent.getIdleHostViewController(); mIdleHostViewController = idleViewComponent.getIdleHostViewController();
mIdleHostViewController.init(); mIdleHostViewController.init();
KeyguardStatusBarViewComponent statusBarViewComponent =
mKeyguardStatusBarViewComponentFactory.build(keyguardStatusBarView);
if (mKeyguardStatusBarViewController != null) {
// TODO(b/194181195): This shouldn't be necessary.
mKeyguardStatusBarViewController.destroy();
}
mKeyguardStatusBarViewController =
statusBarViewComponent.getKeyguardStatusBarViewController();
mKeyguardStatusBarViewController.init();
if (communalView != null) { if (communalView != null) {
CommunalViewComponent communalViewComponent = CommunalViewComponent communalViewComponent =
mCommunalViewComponentFactory.build(communalView); mCommunalViewComponentFactory.build(communalView);
@@ -1217,7 +1210,7 @@ public class NotificationPanelViewController extends PanelViewController {
mBigClockContainer.removeAllViews(); mBigClockContainer.removeAllViews();
updateViewControllers(mView.findViewById(R.id.keyguard_status_view), userAvatarView, updateViewControllers(mView.findViewById(R.id.keyguard_status_view), userAvatarView,
mKeyguardStatusBar, keyguardUserSwitcherView, mCommunalView, keyguardUserSwitcherView, mCommunalView,
mView.findViewById(R.id.idle_host_view)); mView.findViewById(R.id.idle_host_view));
// Update keyguard bottom area // Update keyguard bottom area

View File

@@ -109,16 +109,6 @@ public abstract class ViewController<T extends View> {
} }
} }
/**
* Destroys this controller so that it never receives view attach and detach events again.
* Does nothing if the view is null.
*/
public void destroy() {
if (mView != null) {
mView.removeOnAttachStateChangeListener(mOnAttachStateListener);
}
}
/** /**
* Called when the view is attached and a call to {@link #init()} has been made in either order. * Called when the view is attached and a call to {@link #init()} has been made in either order.
*/ */