Merge "Simplifying mVerticalTranslationListener" into sc-dev

This commit is contained in:
Michał Brzeziński
2021-02-22 12:37:27 +00:00
committed by Android (Google) Code Review
3 changed files with 10 additions and 14 deletions

View File

@@ -134,7 +134,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
mStackScrollerController = stackScrollerController;
mNotificationPanelViewController = notificationPanelViewController;
notificationPanelViewController.addTrackingHeadsUpListener(mSetTrackingHeadsUp);
notificationPanelViewController.addVerticalTranslationListener(mUpdatePanelTranslation);
notificationPanelViewController.setVerticalTranslationListener(mUpdatePanelTranslation);
notificationPanelViewController.setHeadsUpAppearanceController(this);
mStackScrollerController.addOnExpandedHeightChangedListener(mSetExpandedHeight);
mStackScrollerController.addOnLayoutChangeListener(mStackScrollLayoutChangeListener);
@@ -171,7 +171,7 @@ public class HeadsUpAppearanceController implements OnHeadsUpChangedListener,
mHeadsUpStatusBarView.setOnDrawingRectChangedListener(null);
mWakeUpCoordinator.removeListener(this);
mNotificationPanelViewController.removeTrackingHeadsUpListener(mSetTrackingHeadsUp);
mNotificationPanelViewController.removeVerticalTranslationListener(mUpdatePanelTranslation);
mNotificationPanelViewController.setVerticalTranslationListener(null);
mNotificationPanelViewController.setHeadsUpAppearanceController(null);
mStackScrollerController.removeOnExpandedHeightChangedListener(mSetExpandedHeight);
mStackScrollerController.removeOnLayoutChangeListener(mStackScrollLayoutChangeListener);

View File

@@ -474,7 +474,7 @@ public class NotificationPanelViewController extends PanelViewController {
private ArrayList<Consumer<ExpandableNotificationRow>>
mTrackingHeadsUpListeners =
new ArrayList<>();
private ArrayList<Runnable> mVerticalTranslationListener = new ArrayList<>();
private Runnable mVerticalTranslationListener;
private HeadsUpAppearanceController mHeadsUpAppearanceController;
private int mPanelAlpha;
@@ -2954,9 +2954,8 @@ public class NotificationPanelViewController extends PanelViewController {
protected void setHorizontalPanelTranslation(float translation) {
mNotificationStackScrollLayoutController.setTranslationX(translation);
mQsFrame.setTranslationX(translation);
int size = mVerticalTranslationListener.size();
for (int i = 0; i < size; i++) {
mVerticalTranslationListener.get(i).run();
if (mVerticalTranslationListener != null) {
mVerticalTranslationListener.run();
}
}
@@ -3249,12 +3248,8 @@ public class NotificationPanelViewController extends PanelViewController {
mTrackingHeadsUpListeners.remove(listener);
}
public void addVerticalTranslationListener(Runnable verticalTranslationListener) {
mVerticalTranslationListener.add(verticalTranslationListener);
}
public void removeVerticalTranslationListener(Runnable verticalTranslationListener) {
mVerticalTranslationListener.remove(verticalTranslationListener);
public void setVerticalTranslationListener(Runnable verticalTranslationListener) {
mVerticalTranslationListener = verticalTranslationListener;
}
public void setHeadsUpAppearanceController(

View File

@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.phone;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.isNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
@@ -197,9 +198,9 @@ public class HeadsUpAppearanceControllerTest extends SysuiTestCase {
mHeadsUpAppearanceController.destroy();
verify(mHeadsUpManager).removeListener(any());
verify(mDarkIconDispatcher).removeDarkReceiver((DarkIconDispatcher.DarkReceiver) any());
verify(mPanelView).removeVerticalTranslationListener(any());
verify(mPanelView).setVerticalTranslationListener(isNull());
verify(mPanelView).removeTrackingHeadsUpListener(any());
verify(mPanelView).setHeadsUpAppearanceController(any());
verify(mPanelView).setHeadsUpAppearanceController(isNull());
verify(mStackScrollerController).removeOnExpandedHeightChangedListener(any());
verify(mStackScrollerController).removeOnLayoutChangeListener(any());
}