Skip to content

Commit bd7de3d

Browse files
wcshiikim24
authored andcommitted
Add null check in #animateViewIn to guard against the post runnable executing after the view has been destroyed.
Resolves #917 PiperOrigin-RevId: 290300667
1 parent 3cd591f commit bd7de3d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/java/com/google/android/material/snackbar/BaseTransientBottomBar.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ public boolean handleMessage(@NonNull Message message) {
268268
new Runnable() {
269269
@Override
270270
public void run() {
271+
if (view == null || context == null) {
272+
return;
273+
}
271274
// Calculate current bottom inset, factoring in translationY to account for where the
272275
// view will likely be animating to.
273276
int currentInsetBottom =
@@ -829,6 +832,9 @@ void animateViewIn() {
829832
new Runnable() {
830833
@Override
831834
public void run() {
835+
if (view == null) {
836+
return;
837+
}
832838
// Make view VISIBLE now that we are about to start the enter animation
833839
view.setVisibility(View.VISIBLE);
834840
if (view.getAnimationMode() == ANIMATION_MODE_FADE) {

0 commit comments

Comments
 (0)