Skip to content

Commit

Permalink
[Contextual Page Actions] Fixed crash on action chip transition
Browse files Browse the repository at this point in the history
This CL fixes a null pointer exception when trying to post a task on an
OptionalButtonView instance that has been detached. This happens when
we finish the action chip expansion animation and we try to schedule
the collapse animation.

(cherry picked from commit a0233c6)

Bug: 1383559
Change-Id: I6fded66cab4f36368606f0469ccbc89586c0ea53
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4022030
Commit-Queue: Salvador Guerrero Ramos <salg@google.com>
Reviewed-by: Shakti Sahu <shaktisahu@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#1070604}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4021639
Commit-Queue: Shakti Sahu <shaktisahu@chromium.org>
Auto-Submit: Salvador Guerrero Ramos <salg@google.com>
Cr-Commit-Position: refs/branch-heads/5414@{#33}
Cr-Branched-From: 4417ee5-refs/heads/main@{#1070088}
  • Loading branch information
Salvador Guerrero authored and Chromium LUCI CQ committed Nov 14, 2022
1 parent b9398e8 commit 455478a
Showing 1 changed file with 7 additions and 1 deletion.
Expand Up @@ -36,6 +36,7 @@

import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.Callback;
import org.chromium.base.ThreadUtils;
import org.chromium.base.supplier.BooleanSupplier;
import org.chromium.chrome.browser.toolbar.ButtonData;
import org.chromium.chrome.browser.toolbar.ButtonData.ButtonSpec;
Expand Down Expand Up @@ -71,6 +72,7 @@ class OptionalButtonView extends FrameLayout implements TransitionListener {
private int mBackgroundColorFilter;
private Runnable mOnBeforeHideTransitionCallback;
private Callback<Transition> mFakeBeginTransitionForTesting;
private Handler mHandler;
private Handler mHandlerForTesting;

private @State int mState;
Expand Down Expand Up @@ -296,7 +298,11 @@ public Handler getHandler() {
return mHandlerForTesting;
}

return super.getHandler();
if (mHandler == null) {
mHandler = new Handler(ThreadUtils.getUiThreadLooper());
}

return mHandler;
}

@Override
Expand Down

0 comments on commit 455478a

Please sign in to comment.