From a28e0f474ad01efaeee4211854a1d5d2e304110d Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Fri, 17 Apr 2020 14:58:48 -0700 Subject: [PATCH] Fix NPE when closing folder. There is a race condition where Folder is closing, it unbinds, and then another call to AbstractFloatingView.closeAllOpenViews tries to close the Folder again. But since the contents are unbound and removed from the folder, it produces a NPE. Bug: 153625271 Change-Id: Ia6c55f15cf7517e26af8f499bc0c1a4828737480 --- src/com/android/launcher3/folder/Folder.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index 4fe1d1a3bd..12d88df7d9 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -164,6 +164,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo @Thunk final ArrayList mItemsInReadingOrder = new ArrayList(); private AnimatorSet mCurrentAnimator; + private boolean mIsAnimatingClosed = false; protected final Launcher mLauncher; protected DragController mDragController; @@ -729,15 +730,24 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo } private void animateClosed() { + if (mIsAnimatingClosed) { + return; + } if (mCurrentAnimator != null && mCurrentAnimator.isRunning()) { mCurrentAnimator.cancel(); } AnimatorSet a = new FolderAnimationManager(this, false /* isOpening */).getAnimator(); a.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationStart(Animator animation) { + mIsAnimatingClosed = true; + } + @Override public void onAnimationEnd(Animator animation) { closeComplete(true); announceAccessibilityChanges(); + mIsAnimatingClosed = false; } }); startAnimation(a);