Abort dispatching animation callbacks if the root view is gone

This CL prevents possible NullPointerExceptions.

Bug: 118118435
Bug: 149479853
Test: atest AnimatedVectorDrawableParameterizedTest
Change-Id: I966a15c0886b80317a34541fb315b2886981af16
This commit is contained in:
Tiger Huang
2020-02-13 16:07:01 +08:00
committed by Jorim Jaggi
parent a000089341
commit f0ef89a522

View File

@@ -39,7 +39,6 @@ import android.util.Log;
import android.util.Pair;
import android.util.Property;
import android.util.SparseArray;
import android.view.InputDevice.MotionRange;
import android.view.InsetsSourceConsumer.ShowResult;
import android.view.InsetsState.InternalInsetsType;
import android.view.SurfaceControl.Transaction;
@@ -855,6 +854,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
} else {
hideDirectly(types);
}
if (mViewRoot.mView == null) {
return;
}
mViewRoot.mView.dispatchWindowInsetsAnimationPrepare(animation);
mViewRoot.mView.getViewTreeObserver().addOnPreDrawListener(new OnPreDrawListener() {
@Override