diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java index d0886e0ca1..ad5770d8c9 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewCallbacks.java @@ -132,7 +132,7 @@ public class TaskbarViewCallbacks { * Notifies launcher to update icon alignment. */ public void notifyIconLayoutBoundsChanged() { - mControllers.uiController.onIconLayoutBoundsChanged(); + mControllers.taskbarViewController.notifyIconLayoutBoundsChanged(); } /** diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 40718f16dd..c7d8a50383 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -162,6 +162,9 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar private final AnimatedFloat mTranslationXForBubbleBar = new AnimatedFloat( this::updateTranslationXForBubbleBar); + private final TransitionEndBoundsChangedNotifier mTransitionEndBoundsChangedNotifier = + new TransitionEndBoundsChangedNotifier(); + @Nullable private Animator mTaskbarShiftXAnim; @Nullable @@ -887,6 +890,16 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar as.play(reveal); } + void notifyIconLayoutBoundsChanged() { + final LayoutTransition layoutTransition = mTaskbarView.getLayoutTransition(); + if (layoutTransition != null && layoutTransition.isRunning()) { + // Defers notify until after transitions finish. + mTransitionEndBoundsChangedNotifier.mIsCanceled = false; + } else { + mControllers.uiController.onIconLayoutBoundsChanged(); + } + } + /** * Sets the Taskbar icon alignment relative to Launcher hotseat icons * @param alignmentRatio [0, 1] @@ -910,6 +923,12 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar mIsHotseatIconOnTopWhenAligned = isHotseatIconOnTopWhenAligned; mIsIconAlignedWithHotseat = isIconAlignedWithHotseat; mIsStashed = isStashed; + + final LayoutTransition layoutTransition = mTaskbarView.getLayoutTransition(); + if (layoutTransition != null && layoutTransition.isRunning()) { + mTransitionEndBoundsChangedNotifier.mIsCanceled = true; + layoutTransition.cancel(); + } mIconAlignControllerLazy = createIconAlignmentController(launcherDp); } mIconAlignControllerLazy.setPlayFraction(alignmentRatio); @@ -1261,6 +1280,7 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar // Do nothing. } }); + layoutTransition.addTransitionListener(mTransitionEndBoundsChangedNotifier); // Appearing. AnimatorSet appearingSet = new AnimatorSet(); @@ -1363,4 +1383,22 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar animator.setInterpolator(EMPHASIZED); return animator; } + + private class TransitionEndBoundsChangedNotifier implements TransitionListener { + private boolean mIsCanceled; + + @Override + public void startTransition( + LayoutTransition transition, ViewGroup container, View view, int type) { + // Do nothing. + } + + @Override + public void endTransition( + LayoutTransition transition, ViewGroup container, View view, int type) { + if (!transition.isRunning() && !mIsCanceled) { + mControllers.uiController.onIconLayoutBoundsChanged(); + } + } + } }