From d9a4783e32bfd62f00736c7925f27147d5fc5e66 Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 21 Mar 2017 20:56:37 -0700 Subject: [PATCH] fix NPE On Nexus 5x rotation with Invite/Wait alert up confuses things, and eventually gets a NPE. This fixes that, but I still need to fix the other. --- .../main/java/org/eehouse/android/xw4/DBAlert.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBAlert.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBAlert.java index 4b8cf724b..94b4cc7b9 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBAlert.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBAlert.java @@ -101,10 +101,14 @@ public class DBAlert extends XWDialogFragment { new Handler().post( new Runnable() { @Override public void run() { - DBAlert newMe = newInstance( mDlgID, mParams ); - ((MainActivity)getActivity()).show( newMe ); - - dismiss(); // kill myself... + MainActivity activity = (MainActivity)getActivity(); + if ( null != activity ) { + DBAlert newMe = newInstance( mDlgID, mParams ); + activity.show( newMe ); + dismiss(); // kill myself... + } else { + DbgUtils.logd( TAG, "null activity..." ); + } } } ); }