when deleting all games don't inform relay until after the last one so

a single connection does it.
This commit is contained in:
Andy2 2010-11-23 18:28:05 -08:00
parent 5bf87b3bea
commit c3f43dd26c
2 changed files with 16 additions and 9 deletions

View file

@ -107,7 +107,7 @@ public class GameUtils {
public static void resetGame( Context context, String pathIn )
{
tellRelayDied( context, pathIn );
tellRelayDied( context, pathIn, true );
resetGame( context, pathIn, pathIn );
}
@ -143,10 +143,11 @@ public class GameUtils {
return newName;
}
public static void deleteGame( Context context, String path )
public static void deleteGame( Context context, String path,
boolean informNow )
{
// does this need to be synchronized?
tellRelayDied( context, path );
tellRelayDied( context, path, informNow );
context.deleteFile( path );
DBUtils.saveSummary( context, path, null );
}
@ -406,7 +407,7 @@ public class GameUtils {
CommonPrefs cp = CommonPrefs.get( context );
if ( forceNew ) {
tellRelayDied( context, path );
tellRelayDied( context, path, true );
} else {
byte[] stream = GameUtils.savedGame( context, path );
// Will fail if there's nothing in the stream but a gi.
@ -471,12 +472,15 @@ public class GameUtils {
}
}
private static void tellRelayDied( Context context, String path )
private static void tellRelayDied( Context context, String path,
boolean informNow )
{
GameSummary summary = DBUtils.getSummary( context, path );
if ( null != summary.relayID ) {
DBUtils.addDeceased( context, summary.relayID, summary.seed );
NetUtils.informOfDeaths( context );
if ( informNow ) {
NetUtils.informOfDeaths( context );
}
}
}

View file

@ -258,8 +258,11 @@ public class GamesList extends XWListActivity
DialogInterface.OnClickListener lstnr =
new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int item ) {
for( String game:GameUtils.gamesList(GamesList.this)) {
GameUtils.deleteGame( GamesList.this, game );
String[] games =
GameUtils.gamesList( GamesList.this );
for ( int ii = games.length - 1; ii >= 0; --ii ) {
GameUtils.deleteGame( GamesList.this, games[ii],
ii == 0 );
}
m_adapter = new GameListAdapter( GamesList.this );
setListAdapter( m_adapter );
@ -348,7 +351,7 @@ public class GamesList extends XWListActivity
if ( R.id.list_item_delete == menuID ) {
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int ii ) {
GameUtils.deleteGame( GamesList.this, path );
GameUtils.deleteGame( GamesList.this, path, true );
m_adapter.inval( path );
onContentChanged();
}