mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
On resume of GamesList, remove from selected set any game that no
longer exists.
This commit is contained in:
parent
a6d8806a7c
commit
f305cbb9fe
2 changed files with 40 additions and 3 deletions
|
@ -1020,6 +1020,33 @@ public class DBUtils {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static Set<Long> getAllGames( Context context )
|
||||
{
|
||||
HashSet<Long> result = null;
|
||||
initDB( context );
|
||||
String[] columns = { ROW_ID };
|
||||
synchronized( s_dbHelper ) {
|
||||
SQLiteDatabase db = s_dbHelper.getReadableDatabase();
|
||||
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
|
||||
null, // selection
|
||||
null, // args
|
||||
null, // groupBy
|
||||
null, // having
|
||||
null
|
||||
);
|
||||
int index = cursor.getColumnIndex( ROW_ID );
|
||||
result = new HashSet<Long>( cursor.getCount() );
|
||||
for ( int ii = 0; cursor.moveToNext(); ++ii ) {
|
||||
long rowid = cursor.getInt( index );
|
||||
result.add( rowid );
|
||||
}
|
||||
cursor.close();
|
||||
db.close();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static long getGroupForGame( Context context, long rowid )
|
||||
{
|
||||
long result = ROWID_NOTFOUND;
|
||||
|
|
|
@ -50,6 +50,7 @@ import java.io.File;
|
|||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
|
||||
// import android.telephony.PhoneStateListener;
|
||||
// import android.telephony.TelephonyManager;
|
||||
|
@ -335,8 +336,6 @@ public class GamesList extends XWExpandableListActivity
|
|||
// scary, but worth playing with:
|
||||
// Assert.assertTrue( isTaskRoot() );
|
||||
|
||||
loadSelectedRows();
|
||||
|
||||
getBundledData( savedInstanceState );
|
||||
|
||||
setContentView(R.layout.game_list);
|
||||
|
@ -421,6 +420,13 @@ public class GamesList extends XWExpandableListActivity
|
|||
// PhoneStateListener.LISTEN_DATA_CONNECTION_STATE );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
loadSelectedRows();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause()
|
||||
{
|
||||
|
@ -1188,9 +1194,13 @@ public class GamesList extends XWExpandableListActivity
|
|||
{
|
||||
int keyID = R.string.key_selected_games;
|
||||
String[] asStrings = XWPrefs.getPrefsStringArray( this, keyID );
|
||||
Set<Long> allGames = DBUtils.getAllGames( this );
|
||||
HashSet<Long> result = new HashSet<Long>(asStrings.length);
|
||||
for ( String str : asStrings ) {
|
||||
result.add( Long.parseLong( str ) );
|
||||
long rowid = Long.parseLong( str );
|
||||
if ( allGames.contains( rowid ) ) {
|
||||
result.add( rowid );
|
||||
}
|
||||
}
|
||||
m_selected = result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue