From b67870118e288f41133d58487c7b8f6e54992ec8 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 6 Sep 2020 11:24:38 -0700 Subject: [PATCH] tweak unable-to-create-alert alert And force a DEBUG-only crash so I can perhaps investigate --- .../java/org/eehouse/android/xw4/DBAlert.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 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 989cb1d26..f7f4951b0 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 @@ -19,6 +19,7 @@ package org.eehouse.android.xw4; +import android.app.Activity; import android.app.Dialog; import android.os.Bundle; import android.os.Handler; @@ -97,10 +98,10 @@ public class DBAlert extends XWDialogFragment { Dialog dialog = activity.makeDialog( this, mParams ); if ( null == dialog ) { - dialog = LocUtils.makeAlertBuilder( getActivity() ) - .setTitle( "Stub Alert" ) - .setMessage( String.format( "Unable to create for %s", - getDlgID().toString() ) ) + Log.e( TAG, "no dialog for %s from %s", getDlgID(), activity ); + Assert.failDbg(); + dialog = LocUtils.makeAlertBuilder( activity ) + .setMessage( "Unable to create " + getDlgID() + " Alert" ) .setPositiveButton( "Bummer", null ) // .setNegativeButton( "Try now", new OnClickListener() { // @Override @@ -115,10 +116,10 @@ public class DBAlert extends XWDialogFragment { @Override public void run() { try { - MainActivity activity = (MainActivity)getActivity(); - if ( null != activity ) { + Activity activity = getActivity(); + if ( null != activity && activity instanceof MainActivity ) { DBAlert newMe = newInstance( getDlgID(), mParams ); - activity.show( newMe ); + ((MainActivity)activity).show( newMe ); dismiss(); // kill myself... } else { Log.d( TAG, "null activity..." );