Skip to content

Commit c6b39c3

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 (cherry picked from commit bd7de3d)
1 parent 09d87fe commit c6b39c3

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
@@ -263,6 +263,9 @@ public boolean handleMessage(@NonNull Message message) {
263263
new Runnable() {
264264
@Override
265265
public void run() {
266+
if (view == null || context == null) {
267+
return;
268+
}
266269
// Calculate current bottom inset, factoring in translationY to account for where the
267270
// view will likely be animating to.
268271
int currentInsetBottom =
@@ -845,6 +848,9 @@ void animateViewIn() {
845848
new Runnable() {
846849
@Override
847850
public void run() {
851+
if (view == null) {
852+
return;
853+
}
848854
// Make view VISIBLE now that we are about to start the enter animation
849855
view.setVisibility(View.VISIBLE);
850856
if (view.getAnimationMode() == ANIMATION_MODE_FADE) {

0 commit comments

Comments
 (0)