include name of game being deleted

This commit is contained in:
Eric House 2019-03-08 09:46:27 -08:00
parent 7f405a3a40
commit 21220bc839
3 changed files with 33 additions and 19 deletions

View file

@ -185,7 +185,7 @@ public class BoardDelegate extends DelegateBase
final DlgID dlgID = alert.getDlgID(); final DlgID dlgID = alert.getDlgID();
Log.d( TAG, "makeDialog(%s)", dlgID.toString() ); Log.d( TAG, "makeDialog(%s)", dlgID.toString() );
OnClickListener lstnr; OnClickListener lstnr;
AlertDialog.Builder ab = makeAlertBuilder(); AlertDialog.Builder ab = makeAlertBuilder(); // used everywhere...
Dialog dialog; Dialog dialog;
switch ( dlgID ) { switch ( dlgID ) {
@ -236,13 +236,15 @@ public class BoardDelegate extends DelegateBase
break; break;
case DLG_DELETED: { case DLG_DELETED: {
final int gameID = (Integer)params[0];
String gameName = GameUtils.getName( m_activity, m_rowid );
ab = ab.setTitle( R.string.query_title ) ab = ab.setTitle( R.string.query_title )
.setMessage( R.string.msg_dev_deleted ) .setMessage( getString( R.string.msg_dev_deleted_fmt, gameName ) )
.setPositiveButton( android.R.string.ok, null ); .setPositiveButton( android.R.string.ok, null );
lstnr = new OnClickListener() { lstnr = new OnClickListener() {
public void onClick( DialogInterface dlg, public void onClick( DialogInterface dlg,
int whichButton ) { int whichButton ) {
deleteAndClose(); deleteAndClose( gameID );
} }
}; };
ab.setNegativeButton( R.string.button_delete, lstnr ); ab.setNegativeButton( R.string.button_delete, lstnr );
@ -1082,7 +1084,7 @@ public class BoardDelegate extends DelegateBase
dropConViaAndRestart(CommsConnType.COMMS_CONN_RELAY); dropConViaAndRestart(CommsConnType.COMMS_CONN_RELAY);
break; break;
case DELETE_AND_EXIT: case DELETE_AND_EXIT:
deleteAndClose(); deleteAndClose( m_gi.gameID );
break; break;
case DROP_SMS_ACTION: // do nothing; work done in onNegButton case case DROP_SMS_ACTION: // do nothing; work done in onNegButton case
alertOrderIncrIfAt( StartAlertOrder.NBS_PERMS ); alertOrderIncrIfAt( StartAlertOrder.NBS_PERMS );
@ -1328,12 +1330,12 @@ public class BoardDelegate extends DelegateBase
doStopProgress = true; doStopProgress = true;
break; break;
case MESSAGE_NOGAME: case MESSAGE_NOGAME:
int gameID = (Integer)args[0]; final int gameID = (Integer)args[0];
if ( gameID == m_gi.gameID ) { if ( gameID == m_gi.gameID && !isFinishing() ) {
post( new Runnable() { post( new Runnable() {
@Override @Override
public void run() { public void run() {
showDialogFragment( DlgID.DLG_DELETED ); showDialogFragment( DlgID.DLG_DELETED, gameID );
} }
} ); } );
} }
@ -1405,6 +1407,7 @@ public class BoardDelegate extends DelegateBase
int strID = -1; int strID = -1;
DlgID dlgID = DlgID.NONE; DlgID dlgID = DlgID.NONE;
boolean doToast = false; boolean doToast = false;
Object[] params = null;
switch ( relayErr ) { switch ( relayErr ) {
case TOO_MANY: case TOO_MANY:
@ -1427,7 +1430,7 @@ public class BoardDelegate extends DelegateBase
case DEADGAME: case DEADGAME:
case DELETED: case DELETED:
strID = R.string.msg_dev_deleted; params = new Object[] { m_gi.gameID };
dlgID = DlgID.DLG_DELETED; dlgID = DlgID.DLG_DELETED;
break; break;
@ -1444,13 +1447,14 @@ public class BoardDelegate extends DelegateBase
if ( doToast ) { if ( doToast ) {
showToast( strID ); showToast( strID );
} else if ( dlgID != DlgID.NONE ) { } else if ( dlgID != DlgID.NONE ) {
final int strIDf = strID;
final DlgID dlgIDf = dlgID; final DlgID dlgIDf = dlgID;
final Object[] paramsF = null == params
? new Object[] {R.string.relay_alert, getString( strID )}
: params;
post( new Runnable() { post( new Runnable() {
@Override @Override
public void run() { public void run() {
showDialogFragment( dlgIDf, R.string.relay_alert, showDialogFragment( dlgIDf, paramsF );
getString( strIDf ) );
} }
}); });
} }
@ -1549,11 +1553,15 @@ public class BoardDelegate extends DelegateBase
means, code ); means, code );
} }
private void deleteAndClose() private void deleteAndClose( int gameID )
{ {
GameUtils.deleteGame( m_activity, m_jniThread.getLock(), false ); if ( gameID == m_gi.gameID ) {
waitCloseGame( false ); GameUtils.deleteGame( m_activity, m_jniThread.getLock(), false );
finish(); waitCloseGame( false );
finish();
} else {
Log.e( TAG, "deleteAndClose() called with wrong gameID %d", gameID );
}
} }
private void askDropRelay() private void askDropRelay()

View file

@ -473,7 +473,13 @@ public class DelegateBase implements DlgClickNotify,
runOnUiThread( new Runnable() { runOnUiThread( new Runnable() {
@Override @Override
public void run() { public void run() {
show( DBAlert.newInstance( dlgID, params ) ); if ( isFinishing() ) {
Log.e( TAG, "not posting dlgID %s b/c %s finishing",
dlgID, this );
DbgUtils.printStack( TAG );
} else {
show( DBAlert.newInstance( dlgID, params ) );
}
} }
} ); } );
} }

View file

@ -643,9 +643,9 @@
relay. Once this happens there is no way to continue the relay. Once this happens there is no way to continue the
game so you might as well delete it (unless you're saving it game so you might as well delete it (unless you're saving it
for its history etc.) --> for its history etc.) -->
<string name="msg_dev_deleted">This game has been deleted on <string name="msg_dev_deleted_fmt">The game named \"%1$s\" has been
another device. You will not be able to play any deleted on another device. You will not be able to play any
further.</string> further.</string>
<!-- Partial text of alert posted when phonies_warn or <!-- Partial text of alert posted when phonies_warn or
phonies_disallow is the current setting and a "phony" is phonies_disallow is the current setting and a "phony" is