Merge "[Misc] Only create KeyguardStatusBarViewController once inside NotificationPanelViewController." into sc-v2-dev

This commit is contained in:
TreeHugger Robot
2021-08-13 14:27:56 +00:00
committed by Android (Google) Code Review
4 changed files with 6 additions and 40 deletions

View File

@@ -107,12 +107,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);
unsubscribeFromTunerUpdates(); unsubscribeFromTunerUpdates();
mCurrentUserTracker.stopTracking(); mCurrentUserTracker.stopTracking();

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

@@ -884,10 +884,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);
mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent); mNotificationContainerParent = mView.findViewById(R.id.notification_container_parent);
NotificationStackScrollLayout stackScrollLayout = mView.findViewById( NotificationStackScrollLayout stackScrollLayout = mView.findViewById(
@@ -979,7 +983,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) {
// Re-associate the KeyguardStatusViewController // Re-associate the KeyguardStatusViewController
KeyguardStatusViewComponent statusViewComponent = KeyguardStatusViewComponent statusViewComponent =
@@ -987,16 +990,6 @@ public class NotificationPanelViewController extends PanelViewController {
mKeyguardStatusViewController = statusViewComponent.getKeyguardStatusViewController(); mKeyguardStatusViewController = statusViewComponent.getKeyguardStatusViewController();
mKeyguardStatusViewController.init(); mKeyguardStatusViewController.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 (mKeyguardUserSwitcherController != null) { if (mKeyguardUserSwitcherController != null) {
// Try to close the switcher so that callbacks are triggered if necessary. // Try to close the switcher so that callbacks are triggered if necessary.
// Otherwise, NPV can get into a state where some of the views are still hidden // Otherwise, NPV can get into a state where some of the views are still hidden
@@ -1156,7 +1149,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); keyguardUserSwitcherView);
// Update keyguard bottom area // Update keyguard bottom area
int index = mView.indexOfChild(mKeyguardBottomArea); int index = mView.indexOfChild(mKeyguardBottomArea);

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.
*/ */