Loading packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +16 −9 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ public class KeyguardClockSwitch extends RelativeLayout { private int mClockSwitchYAmount; @VisibleForTesting boolean mChildrenAreLaidOut = false; private OnPreDrawListener mPreDrawListener; public KeyguardClockSwitch(Context context, AttributeSet attrs) { super(context, attrs); Loading Loading @@ -284,15 +285,14 @@ public class KeyguardClockSwitch extends RelativeLayout { if (mChildrenAreLaidOut) { animateClockChange(clockSize == LARGE); mDisplayedClockSize = clockSize; } else { getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() { @Override public boolean onPreDraw() { } else if (mPreDrawListener == null) { mPreDrawListener = () -> { switchToClock(clockSize); getViewTreeObserver().removeOnPreDrawListener(this); getViewTreeObserver().removeOnPreDrawListener(mPreDrawListener); mPreDrawListener = null; return true; } }); }; getViewTreeObserver().addOnPreDrawListener(mPreDrawListener); } return true; } Loading @@ -303,6 +303,13 @@ public class KeyguardClockSwitch extends RelativeLayout { mChildrenAreLaidOut = true; } void onViewDetached() { if (mPreDrawListener != null) { getViewTreeObserver().removeOnPreDrawListener(mPreDrawListener); mPreDrawListener = null; } } public Paint getPaint() { return mClockView.getPaint(); } Loading packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +1 −0 Original line number Diff line number Diff line Loading @@ -238,6 +238,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } mColorExtractor.removeOnColorsChangedListener(mColorsListener); mView.setClockPlugin(null, mStatusBarStateController.getState()); mView.onViewDetached(); } /** Loading packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -194,7 +194,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { verifyAttachment(times(1)); listenerArgumentCaptor.getValue().onViewDetachedFromWindow(mView); verify(mView).onViewDetached(); verify(mColorExtractor).removeOnColorsChangedListener( any(ColorExtractor.OnColorsChangedListener.class)); } Loading Loading
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitch.java +16 −9 Original line number Diff line number Diff line Loading @@ -89,6 +89,7 @@ public class KeyguardClockSwitch extends RelativeLayout { private int mClockSwitchYAmount; @VisibleForTesting boolean mChildrenAreLaidOut = false; private OnPreDrawListener mPreDrawListener; public KeyguardClockSwitch(Context context, AttributeSet attrs) { super(context, attrs); Loading Loading @@ -284,15 +285,14 @@ public class KeyguardClockSwitch extends RelativeLayout { if (mChildrenAreLaidOut) { animateClockChange(clockSize == LARGE); mDisplayedClockSize = clockSize; } else { getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() { @Override public boolean onPreDraw() { } else if (mPreDrawListener == null) { mPreDrawListener = () -> { switchToClock(clockSize); getViewTreeObserver().removeOnPreDrawListener(this); getViewTreeObserver().removeOnPreDrawListener(mPreDrawListener); mPreDrawListener = null; return true; } }); }; getViewTreeObserver().addOnPreDrawListener(mPreDrawListener); } return true; } Loading @@ -303,6 +303,13 @@ public class KeyguardClockSwitch extends RelativeLayout { mChildrenAreLaidOut = true; } void onViewDetached() { if (mPreDrawListener != null) { getViewTreeObserver().removeOnPreDrawListener(mPreDrawListener); mPreDrawListener = null; } } public Paint getPaint() { return mClockView.getPaint(); } Loading
packages/SystemUI/src/com/android/keyguard/KeyguardClockSwitchController.java +1 −0 Original line number Diff line number Diff line Loading @@ -238,6 +238,7 @@ public class KeyguardClockSwitchController extends ViewController<KeyguardClockS } mColorExtractor.removeOnColorsChangedListener(mColorsListener); mView.setClockPlugin(null, mStatusBarStateController.getState()); mView.onViewDetached(); } /** Loading
packages/SystemUI/tests/src/com/android/keyguard/KeyguardClockSwitchControllerTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -194,7 +194,7 @@ public class KeyguardClockSwitchControllerTest extends SysuiTestCase { verifyAttachment(times(1)); listenerArgumentCaptor.getValue().onViewDetachedFromWindow(mView); verify(mView).onViewDetached(); verify(mColorExtractor).removeOnColorsChangedListener( any(ColorExtractor.OnColorsChangedListener.class)); } Loading