mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-09 22:00:39 +01:00
fix the unable-to-post-alert alert
Returning null from createDialog() isn't allowed, so return this as a fallback as before. But the old code immediately dismissed it and created another in an infinite loop. So just suck it up and display it. And as always hope users don't see it.
This commit is contained in:
parent
bf6afb803f
commit
a3048441e9
1 changed files with 10 additions and 28 deletions
|
@ -21,6 +21,8 @@ package org.eehouse.android.xw4;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface.OnClickListener;
|
||||
import android.content.DialogInterface;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
|
||||
|
@ -28,7 +30,6 @@ import org.eehouse.android.xw4.loc.LocUtils;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
public class DBAlert extends XWDialogFragment {
|
||||
private static final String TAG = DBAlert.class.getSimpleName();
|
||||
private static final String DLG_ID_KEY = "DLG_ID_KEY";
|
||||
|
@ -102,34 +103,15 @@ public class DBAlert extends XWDialogFragment {
|
|||
// Assert.failDbg(); // remove: better to see what users will see
|
||||
dialog = LocUtils.makeAlertBuilder( activity )
|
||||
.setMessage( "Unable to create " + getDlgID() + " Alert" )
|
||||
.setPositiveButton( "Bummer", null )
|
||||
// .setNegativeButton( "Try now", new OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick( DialogInterface dlg, int button ) {
|
||||
// DBAlert alrt = newInstance( mDlgID, mParams );
|
||||
// ((MainActivity)getActivity()).show( alrt );
|
||||
// }
|
||||
// })
|
||||
.create();
|
||||
|
||||
new Handler().post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Activity activity = getActivity();
|
||||
if ( null != activity && activity instanceof MainActivity ) {
|
||||
DBAlert newMe = newInstance( getDlgID(), mParams );
|
||||
((MainActivity)activity).show( newMe );
|
||||
dismiss(); // kill myself...
|
||||
} else {
|
||||
Log.d( TAG, "null activity..." );
|
||||
}
|
||||
} catch ( IllegalStateException ex ) {
|
||||
// Assert.assertFalse( BuildConfig.DEBUG );
|
||||
Log.e( TAG, "got ISE; dropping alert" );
|
||||
.setPositiveButton( android.R.string.ok, null )
|
||||
.setNegativeButton( "Try again", new OnClickListener() {
|
||||
@Override
|
||||
public void onClick( DialogInterface dlg, int button ) {
|
||||
DBAlert alrt = newInstance( mDlgID, mParams );
|
||||
((MainActivity)getActivity()).show( alrt );
|
||||
}
|
||||
}
|
||||
} );
|
||||
})
|
||||
.create();
|
||||
}
|
||||
return dialog;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue