mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-16 15:41:16 +01:00
when deleting a group's games do as when they're deleted individually:
get the lock, tell the relay, and THEN remove from DB.
This commit is contained in:
parent
3bff555bfd
commit
a199dd2b92
2 changed files with 21 additions and 4 deletions
|
@ -310,18 +310,35 @@ public class GameUtils {
|
|||
return rowid;
|
||||
}
|
||||
|
||||
public static void deleteGame( Context context, long rowid,
|
||||
boolean informNow )
|
||||
public static boolean deleteGame( Context context, long rowid,
|
||||
boolean informNow )
|
||||
{
|
||||
DbgUtils.logf( "deleteGame(rowid=%d)", rowid );
|
||||
boolean success;
|
||||
// does this need to be synchronized?
|
||||
GameLock lock = new GameLock( rowid, true );
|
||||
if ( lock.tryLock() ) {
|
||||
tellDied( context, lock, informNow );
|
||||
DBUtils.deleteGame( context, lock );
|
||||
lock.unlock();
|
||||
success = true;
|
||||
} else {
|
||||
DbgUtils.logf( "deleteGame: unable to delete rowid %d", rowid );
|
||||
success = false;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
public static void deleteGroup( Context context, long groupid )
|
||||
{
|
||||
int nSuccesses = 0;
|
||||
long[] rowids = DBUtils.getGroupGames( context, groupid );
|
||||
for ( int ii = rowids.length - 1; ii >= 0; --ii ) {
|
||||
if ( deleteGame( context, rowids[ii], ii == 0 ) ) {
|
||||
++nSuccesses;
|
||||
}
|
||||
}
|
||||
if ( rowids.length == nSuccesses ) {
|
||||
DBUtils.deleteGroup( context, groupid );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -557,7 +557,7 @@ public class GamesList extends XWExpandableListActivity
|
|||
break;
|
||||
|
||||
case DELETE_GROUP_ACTION:
|
||||
DBUtils.deleteGroup( this, m_groupid );
|
||||
GameUtils.deleteGroup( this, m_groupid );
|
||||
onContentChanged();
|
||||
break;
|
||||
default:
|
||||
|
|
Loading…
Reference in a new issue