private LiveData<Slice> mLiveData;
private int mIconSize;
/**
- * Listener called whenever the view contents change.
- * Boolean will be true when the change happens animated.
+ * Runnable called whenever the view contents change.
*/
- private Consumer<Boolean> mContentChangeListener;
+ private Runnable mContentChangeListener;
private boolean mHasHeader;
private Slice mSlice;
private boolean mPulsing;
if (mPulsing || mSlice == null) {
mTitle.setVisibility(GONE);
mRow.setVisibility(GONE);
- mContentChangeListener.accept(getLayoutTransition() != null);
+ if (mContentChangeListener != null) {
+ mContentChangeListener.run();
+ }
return;
}
}
if (mContentChangeListener != null) {
- mContentChangeListener.accept(getLayoutTransition() != null);
+ mContentChangeListener.run();
}
}
}
/**
- * Listener that gets invoked every time the title or the row visibility changes.
- * Parameter will be {@code true} whenever the change happens animated.
+ * Runnable that gets invoked every time the title or the row visibility changes.
* @param contentChangeListener The listener.
*/
- public void setContentChangeListener(Consumer<Boolean> contentChangeListener) {
+ public void setContentChangeListener(Runnable contentChangeListener) {
mContentChangeListener = contentChangeListener;
}
private float mDarkAmount = 0;
private int mTextColor;
private float mWidgetPadding;
- private boolean mAnimateLayout;
private int mLastLayoutHeight;
private KeyguardUpdateMonitorCallback mInfoCallback = new KeyguardUpdateMonitorCallback() {
mClockView.addOnLayoutChangeListener(this);
mClockSeparator.addOnLayoutChangeListener(this);
mKeyguardSlice.setContentChangeListener(this::onSliceContentChanged);
- onSliceContentChanged(false /* animated */);
+ onSliceContentChanged();
boolean shouldMarquee = KeyguardUpdateMonitor.getInstance(mContext).isDeviceInteractive();
setEnableMarquee(shouldMarquee);
mClockView.setElegantTextHeight(false);
}
- private void onSliceContentChanged(boolean animated) {
- mAnimateLayout = animated;
+ private void onSliceContentChanged() {
boolean smallClock = mKeyguardSlice.hasHeader() || mPulsing;
float clockScale = smallClock ? mSmallClockScale : 1;
long duration = KeyguardSliceView.DEFAULT_ANIM_DURATION;
long delay = smallClock ? 0 : duration / 4;
+ boolean shouldAnimate = mKeyguardSlice.getLayoutTransition() != null
+ && mKeyguardSlice.getLayoutTransition().isRunning();
if (view == mClockView) {
float clockScale = smallClock ? mSmallClockScale : 1;
Paint.Style style = smallClock ? Paint.Style.FILL_AND_STROKE : Paint.Style.FILL;
- if (mAnimateLayout) {
+ if (shouldAnimate) {
mClockView.setY(oldTop + heightOffset);
mClockView.animate().cancel();
mClockView.animate()
} else if (view == mClockSeparator) {
boolean hasSeparator = hasHeader && !mPulsing;
float alpha = hasSeparator ? 1 : 0;
- if (mAnimateLayout) {
+ if (shouldAnimate) {
boolean isAwake = mDarkAmount != 0;
mClockSeparator.setY(oldTop + heightOffset);
mClockSeparator.animate().cancel();
public void showSlice_notifiesListener() {
ListBuilder builder = new ListBuilder(getContext(), mSliceUri);
AtomicBoolean notified = new AtomicBoolean();
- mKeyguardSliceView.setContentChangeListener((hasHeader)-> {
- notified.set(true);
- });
+ mKeyguardSliceView.setContentChangeListener(()-> notified.set(true));
mKeyguardSliceView.onChanged(builder.build());
Assert.assertTrue("Listener should be notified about slice changes.",
notified.get());
@Test
public void showSlice_emptySliceNotifiesListener() {
AtomicBoolean notified = new AtomicBoolean();
- mKeyguardSliceView.setContentChangeListener((hasHeader)-> {
- notified.set(true);
- });
+ mKeyguardSliceView.setContentChangeListener(()-> notified.set(true));
mKeyguardSliceView.onChanged(null);
Assert.assertTrue("Listener should be notified about slice changes.",
notified.get());
@Test
public void refresh_replacesSliceContentAndNotifiesListener() {
AtomicBoolean notified = new AtomicBoolean();
- mKeyguardSliceView.setContentChangeListener((hasHeader)-> {
- notified.set(true);
- });
+ mKeyguardSliceView.setContentChangeListener(()-> notified.set(true));
mKeyguardSliceView.refresh();
Assert.assertTrue("Listener should be notified about slice changes.",
notified.get());