Commit 470b8daa authored by Sinan Sahin's avatar Sinan Sahin Committed by Commit Bot

[Offline indicator v2] Clean up the animations on destroy

Currently, if the status indicator is destroyed while there are running
animations, we still get an #onAnimationEnd call causing NPEs.

To prevent this, this CL cancels all animations in #destroy(). Also, it
adds some null checks in TabbedRootUiCoordinator where we can
potentially try to access null mActivity and ActivityTabProvider.

Bug: 1087010
Change-Id: I60a199cdebad160b2ef3f63719552cc54cce87a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2219348Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Sinan Sahin <sinansahin@google.com>
Cr-Commit-Position: refs/heads/master@{#772934}
parent f427e830
...@@ -96,6 +96,7 @@ public class StatusIndicatorCoordinator { ...@@ -96,6 +96,7 @@ public class StatusIndicatorCoordinator {
public void destroy() { public void destroy() {
mRemoveOnLayoutChangeListener.run(); mRemoveOnLayoutChangeListener.run();
mMediator.destroy();
} }
// TODO(sinansahin): Destroy the view when not needed. // TODO(sinansahin): Destroy the view when not needed.
......
...@@ -97,6 +97,9 @@ public class TabbedRootUiCoordinator extends RootUiCoordinator implements Native ...@@ -97,6 +97,9 @@ public class TabbedRootUiCoordinator extends RootUiCoordinator implements Native
mIntentWithEffect = intentWithEffect; mIntentWithEffect = intentWithEffect;
mEphemeralTabCoordinatorSupplier = ephemeralTabCoordinatorSupplier; mEphemeralTabCoordinatorSupplier = ephemeralTabCoordinatorSupplier;
mCanAnimateBrowserControls = () -> { mCanAnimateBrowserControls = () -> {
// These null checks prevent any exceptions that may be caused by callbacks after
// destruction.
if (mActivity == null || mActivity.getActivityTabProvider() == null) return false;
final Tab tab = mActivity.getActivityTabProvider().get(); final Tab tab = mActivity.getActivityTabProvider().get();
return tab != null && tab.isUserInteractable() && !tab.isNativePage(); return tab != null && tab.isUserInteractable() && !tab.isNativePage();
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment