Merge "Add null-safety checks" into tm-qpr-dev am: 4c31889176

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19931025

Change-Id: I9418d28956ffa3776949e108ec78f6c3fa831a69
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Andrey Epin
2022-09-13 16:43:29 +00:00
committed by Automerger Merge Worker

View File

@@ -2953,12 +2953,14 @@ public class ChooserActivity extends ResolverActivity implements
private void startFinishAnimation() {
View rootView = findRootView();
rootView.startAnimation(new FinishAnimation(this, rootView));
if (rootView != null) {
rootView.startAnimation(new FinishAnimation(this, rootView));
}
}
private boolean maybeCancelFinishAnimation() {
View rootView = findRootView();
Animation animation = rootView.getAnimation();
Animation animation = rootView == null ? null : rootView.getAnimation();
if (animation instanceof FinishAnimation) {
boolean hasEnded = animation.hasEnded();
animation.cancel();
@@ -4086,11 +4088,13 @@ public class ChooserActivity extends ResolverActivity implements
*/
private static class FinishAnimation extends AlphaAnimation implements
Animation.AnimationListener {
@Nullable
private Activity mActivity;
@Nullable
private View mRootView;
private final float mFromAlpha;
FinishAnimation(Activity activity, View rootView) {
FinishAnimation(@NonNull Activity activity, @NonNull View rootView) {
super(rootView.getAlpha(), 0.0f);
mActivity = activity;
mRootView = rootView;
@@ -4114,7 +4118,9 @@ public class ChooserActivity extends ResolverActivity implements
@Override
public void cancel() {
mRootView.setAlpha(mFromAlpha);
if (mRootView != null) {
mRootView.setAlpha(mFromAlpha);
}
cleanup();
super.cancel();
}
@@ -4125,9 +4131,10 @@ public class ChooserActivity extends ResolverActivity implements
@Override
public void onAnimationEnd(Animation animation) {
if (mActivity != null) {
mActivity.finish();
cleanup();
Activity activity = mActivity;
cleanup();
if (activity != null) {
activity.finish();
}
}