mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
shift responsibility for deleting new game when config activity is
cancelled from games list to config activity. Fixes race condition that on emulator, and less often on device, left a game highlighted after config was cancelled that should have been deleted.
This commit is contained in:
parent
35525d62a4
commit
5e6bb507b7
3 changed files with 31 additions and 24 deletions
|
@ -87,7 +87,7 @@ public class DlgDelegate {
|
||||||
|
|
||||||
// Game configs
|
// Game configs
|
||||||
LOCKED_CHANGE_ACTION,
|
LOCKED_CHANGE_ACTION,
|
||||||
EXIT_NO_SAVE,
|
DELETE_AND_EXIT,
|
||||||
|
|
||||||
// New Game
|
// New Game
|
||||||
NEW_GAME_ACTION,
|
NEW_GAME_ACTION,
|
||||||
|
|
|
@ -558,7 +558,7 @@ public class GameConfigDelegate extends DelegateBase
|
||||||
if ( XwJNI.game_hasComms( gamePtr ) ) {
|
if ( XwJNI.game_hasComms( gamePtr ) ) {
|
||||||
XwJNI.comms_getAddr( gamePtr, m_carOrig );
|
XwJNI.comms_getAddr( gamePtr, m_carOrig );
|
||||||
m_remoteAddrs = XwJNI.comms_getAddrs( gamePtr );
|
m_remoteAddrs = XwJNI.comms_getAddrs( gamePtr );
|
||||||
} else if (DeviceRole.SERVER_STANDALONE != m_giOrig.serverRole){
|
} else if ( !localOnlyGame() ) {
|
||||||
String relayName = XWPrefs.getDefaultRelayHost( m_activity );
|
String relayName = XWPrefs.getDefaultRelayHost( m_activity );
|
||||||
int relayPort = XWPrefs.getDefaultRelayPort( m_activity );
|
int relayPort = XWPrefs.getDefaultRelayPort( m_activity );
|
||||||
XwJNI.comms_getInitialAddr( m_carOrig, relayName, relayPort );
|
XwJNI.comms_getInitialAddr( m_carOrig, relayName, relayPort );
|
||||||
|
@ -644,7 +644,8 @@ public class GameConfigDelegate extends DelegateBase
|
||||||
case SMS_CONFIG_ACTION:
|
case SMS_CONFIG_ACTION:
|
||||||
Utils.launchSettings( m_activity );
|
Utils.launchSettings( m_activity );
|
||||||
break;
|
break;
|
||||||
case EXIT_NO_SAVE:
|
case DELETE_AND_EXIT:
|
||||||
|
deleteGame();
|
||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -652,7 +653,7 @@ public class GameConfigDelegate extends DelegateBase
|
||||||
}
|
}
|
||||||
} else if ( AlertDialog.BUTTON_NEGATIVE == button ) {
|
} else if ( AlertDialog.BUTTON_NEGATIVE == button ) {
|
||||||
switch ( action ) {
|
switch ( action ) {
|
||||||
case EXIT_NO_SAVE:
|
case DELETE_AND_EXIT:
|
||||||
showDialog( DlgID.CHANGE_CONN );
|
showDialog( DlgID.CHANGE_CONN );
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -697,11 +698,11 @@ public class GameConfigDelegate extends DelegateBase
|
||||||
// from here if there's no confirmation needed, or launch
|
// from here if there's no confirmation needed, or launch
|
||||||
// a new dialog whose OK button does the same thing.
|
// a new dialog whose OK button does the same thing.
|
||||||
saveChanges();
|
saveChanges();
|
||||||
if ( 0 == m_conTypes.size() ) {
|
if ( !localOnlyGame() && 0 == m_conTypes.size() ) {
|
||||||
showConfirmThen( R.string.config_no_connvia,
|
showConfirmThen( R.string.config_no_connvia,
|
||||||
R.string.button_discard,
|
R.string.button_discard,
|
||||||
R.string.button_edit,
|
R.string.button_edit,
|
||||||
Action.EXIT_NO_SAVE );
|
Action.DELETE_AND_EXIT );
|
||||||
} else if ( m_forResult ) {
|
} else if ( m_forResult ) {
|
||||||
applyChanges( true );
|
applyChanges( true );
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
|
@ -730,21 +731,35 @@ public class GameConfigDelegate extends DelegateBase
|
||||||
if ( null == m_gameLock ) {
|
if ( null == m_gameLock ) {
|
||||||
// Do nothing; we're on our way out
|
// Do nothing; we're on our way out
|
||||||
} else if ( keyCode == KeyEvent.KEYCODE_BACK ) {
|
} else if ( keyCode == KeyEvent.KEYCODE_BACK ) {
|
||||||
saveChanges();
|
if ( m_forResult ) {
|
||||||
if ( !m_gameStarted ) { // no confirm needed
|
deleteGame();
|
||||||
applyChanges( true );
|
|
||||||
} else if ( m_giOrig.changesMatter(m_gi)
|
|
||||||
|| m_carOrig.changesMatter(m_car) ) {
|
|
||||||
showDialog( DlgID.CONFIRM_CHANGE );
|
|
||||||
consumed = true; // don't dismiss activity yet!
|
|
||||||
} else {
|
} else {
|
||||||
applyChanges( false );
|
saveChanges();
|
||||||
|
if ( !m_gameStarted ) { // no confirm needed
|
||||||
|
applyChanges( true );
|
||||||
|
} else if ( m_giOrig.changesMatter(m_gi)
|
||||||
|
|| m_carOrig.changesMatter(m_car) ) {
|
||||||
|
showDialog( DlgID.CONFIRM_CHANGE );
|
||||||
|
consumed = true; // don't dismiss activity yet!
|
||||||
|
} else {
|
||||||
|
applyChanges( false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return consumed;
|
return consumed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void deleteGame()
|
||||||
|
{
|
||||||
|
Assert.assertTrue( m_forResult );
|
||||||
|
if ( null != m_gameLock ) {
|
||||||
|
DBUtils.deleteGame( m_activity, m_gameLock );
|
||||||
|
m_gameLock.unlock();
|
||||||
|
m_gameLock = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void loadPlayersList()
|
private void loadPlayersList()
|
||||||
{
|
{
|
||||||
m_playerLayout.removeAllViews();
|
m_playerLayout.removeAllViews();
|
||||||
|
@ -1178,7 +1193,7 @@ public class GameConfigDelegate extends DelegateBase
|
||||||
|
|
||||||
private boolean localOnlyGame()
|
private boolean localOnlyGame()
|
||||||
{
|
{
|
||||||
return 0 == m_conTypes.size();
|
return DeviceRole.SERVER_STANDALONE == m_giOrig.serverRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void editForResult( Activity parent, int requestCode,
|
public static void editForResult( Activity parent, int requestCode,
|
||||||
|
|
|
@ -552,7 +552,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
private String m_missingDict;
|
private String m_missingDict;
|
||||||
private String m_missingDictName;
|
private String m_missingDictName;
|
||||||
private long m_missingDictRowId = DBUtils.ROWID_NOTFOUND;
|
private long m_missingDictRowId = DBUtils.ROWID_NOTFOUND;
|
||||||
private long m_configRowID = DBUtils.ROWID_NOTFOUND;
|
|
||||||
private int m_missingDictMenuId;
|
private int m_missingDictMenuId;
|
||||||
private String[] m_sameLangDicts;
|
private String[] m_sameLangDicts;
|
||||||
private int m_missingDictLang;
|
private int m_missingDictLang;
|
||||||
|
@ -1191,17 +1190,11 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CONFIG_GAME:
|
case CONFIG_GAME:
|
||||||
if ( cancelled ) {
|
if ( !cancelled ) {
|
||||||
if ( DBUtils.ROWID_NOTFOUND != m_configRowID ) {
|
|
||||||
long[] rowids = { m_configRowID };
|
|
||||||
deleteGames( rowids );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
long rowID = data.getLongExtra( GameUtils.INTENT_KEY_ROWID,
|
long rowID = data.getLongExtra( GameUtils.INTENT_KEY_ROWID,
|
||||||
DBUtils.ROWID_NOTFOUND );
|
DBUtils.ROWID_NOTFOUND );
|
||||||
GameUtils.launchGame( m_activity, rowID );
|
GameUtils.launchGame( m_activity, rowID );
|
||||||
}
|
}
|
||||||
m_configRowID = DBUtils.ROWID_NOTFOUND;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2105,7 +2098,6 @@ public class GamesListDelegate extends ListDelegateBase
|
||||||
|
|
||||||
if ( doConfigure ) {
|
if ( doConfigure ) {
|
||||||
// configure it
|
// configure it
|
||||||
m_configRowID = rowID;
|
|
||||||
GameConfigDelegate.editForResult( m_activity, CONFIG_GAME, rowID );
|
GameConfigDelegate.editForResult( m_activity, CONFIG_GAME, rowID );
|
||||||
} else {
|
} else {
|
||||||
// launch it
|
// launch it
|
||||||
|
|
Loading…
Reference in a new issue