call dbchange listeners after deleting game. And with the dbchange

listeners working a lot of inval/onContentChanged stuff can be
removed.
This commit is contained in:
Andy2 2011-03-02 07:02:24 -08:00
parent 61a9f708a2
commit 9e56e4f40c
2 changed files with 8 additions and 20 deletions

View file

@ -269,8 +269,8 @@ public class DBUtils {
values, selection, null );
Assert.assertTrue( result == 1 );
db.close();
notifyListeners( path );
}
notifyListeners( path );
}
public static int getMsgFlags( String path )
@ -454,8 +454,8 @@ public class DBUtils {
Assert.assertTrue( row >= 0 );
}
db.close();
notifyListeners( path );
}
notifyListeners( path );
}
public static byte[] loadGame( Context context, GameUtils.GameLock lock )
@ -483,6 +483,7 @@ public class DBUtils {
public static void deleteGame( Context context, GameUtils.GameLock lock )
{
Assert.assertTrue( lock.canWrite() );
initDB( context );
synchronized( s_dbHelper ) {
SQLiteDatabase db = s_dbHelper.getWritableDatabase();
@ -490,6 +491,7 @@ public class DBUtils {
db.delete( DBHelper.TABLE_NAME_SUM, selection, null );
db.close();
}
notifyListeners( lock.getPath() );
}
public static String[] gamesList( Context context )
@ -598,6 +600,8 @@ public class DBUtils {
}
}
// Chat is independent of the GameLock mechanism because it's not
// touching the SNAPSHOT column.
private static void saveChatHistory( Context context, String path,
String history )
{

View file

@ -266,15 +266,6 @@ public class GamesList extends XWListActivity
} );
}
@Override
public void onWindowFocusChanged( boolean hasFocus )
{
super.onWindowFocusChanged( hasFocus );
if ( hasFocus ) {
onContentChanged();
}
}
@Override
public void onCreateContextMenu( ContextMenu menu, View view,
ContextMenuInfo menuInfo )
@ -404,8 +395,6 @@ public class GamesList extends XWListActivity
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int ii ) {
GameUtils.deleteGame( GamesList.this, path, true );
m_adapter.inval( path );
onContentChanged();
}
};
showConfirmThen( R.string.confirm_delete, lstnr );
@ -417,8 +406,6 @@ public class GamesList extends XWListActivity
lstnr = new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dlg, int ii ) {
GameUtils.resetGame( GamesList.this, path );
m_adapter.inval( path );
onContentChanged();
}
};
showConfirmThen( R.string.confirm_reset, lstnr );
@ -438,7 +425,8 @@ public class GamesList extends XWListActivity
showOKOnlyDialog( R.string.no_copy_network );
} else {
byte[] stream = GameUtils.savedGame( this, path );
GameUtils.GameLock lock = GameUtils.saveGame( this, stream );
GameUtils.GameLock lock =
GameUtils.saveGame( this, stream );
DBUtils.saveSummary( this, lock, summary );
lock.unlock();
}
@ -462,9 +450,6 @@ public class GamesList extends XWListActivity
if ( null != invalPath ) {
m_adapter.inval( invalPath );
}
if ( handled ) {
onContentChanged();
}
}
return handled;
@ -505,7 +490,6 @@ public class GamesList extends XWListActivity
{
String path = saveNew( new CurGameInfo( this, networked ) );
GameUtils.resetGame( this, path );
onContentChanged();
return path;
}