MrEngineer13 / SnackBar

toast-like alert pattern for Android inspired by the Google Material Design Spec

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Null Views and NPE when dealing with fragments

avsector opened this issue · comments

commented

The validity of a view reference should be checked before attempting to show the SnackBar. When using SnackBar and suppling the view in the builder for the fragments, there's a slight chance that when the SnackBar is building the view is no longer available, hence causing a NullPointerException.

An easy way to produce this is showing SnackBar in asynchronous callbacks in the fragments. Simply start an asynchronous job and navigate away from the fragment.