Skip to content

Commit

Permalink
fix IllegalStateException when view is not attached.
Browse files Browse the repository at this point in the history
  • Loading branch information
MajedDH committed Apr 7, 2019
1 parent 0901acd commit 0405d39
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -992,8 +992,14 @@ public boolean show(final Activity activity) {
mHandler.postDelayed(new Runnable() {
@Override
public void run() {

if (mShouldAnimate) {
boolean attached;
// taken from https://android.googlesource.com/platform/frameworks/support/+/refs/heads/androidx-master-dev/core/src/main/java/androidx/core/view/ViewCompat.java#3310
if (Build.VERSION.SDK_INT >= 19) {
attached = isAttachedToWindow();
} else {
attached = getWindowToken() != null;
}
if (mShouldAnimate && attached) {
fadeIn();
} else {
setVisibility(VISIBLE);
Expand Down

0 comments on commit 0405d39

Please sign in to comment.