preserve selection across orientation changes

This commit is contained in:
Eric House 2013-11-21 07:10:36 -08:00
parent f88e7a89f0
commit 03b7a6d45f

View file

@ -74,6 +74,8 @@ public class GamesList extends XWExpandableListActivity
private static final String SAVE_ROWID = "SAVE_ROWID";
private static final String SAVE_ROWIDS = "SAVE_ROWIDS";
private static final String SAVE_SELGAMES = "SAVE_SELGAMES";
private static final String SAVE_SELGROUPS = "SAVE_SELGROUPS";
private static final String SAVE_GROUPID = "SAVE_GROUPID";
private static final String SAVE_DICTNAMES = "SAVE_DICTNAMES";
@ -370,10 +372,9 @@ public class GamesList extends XWExpandableListActivity
// scary, but worth playing with:
// Assert.assertTrue( isTaskRoot() );
getBundledData( savedInstanceState );
m_selGames = new HashSet<Long>();
m_selGroupIDs = new HashSet<Long>();
getBundledData( savedInstanceState );
setContentView(R.layout.game_list);
ExpandableListView listview = getExpandableListView();
@ -442,6 +443,8 @@ public class GamesList extends XWExpandableListActivity
super.onSaveInstanceState( outState );
outState.putLong( SAVE_ROWID, m_rowid );
outState.putLongArray( SAVE_ROWIDS, m_rowids );
outState.putLongArray( SAVE_SELGAMES, getSelRowIDs() );
outState.putLongArray( SAVE_SELGROUPS, getSelGroupIDs() );
outState.putLong( SAVE_GROUPID, m_groupid );
outState.putString( SAVE_DICTNAMES, m_missingDictName );
if ( null != m_netLaunchInfo ) {
@ -454,6 +457,15 @@ public class GamesList extends XWExpandableListActivity
if ( null != bundle ) {
m_rowid = bundle.getLong( SAVE_ROWID );
m_rowids = bundle.getLongArray( SAVE_ROWIDS );
long[] tmp;
tmp = bundle.getLongArray( SAVE_SELGAMES );
for ( long ll : tmp ) {
m_selGames.add( ll );
}
tmp = bundle.getLongArray( SAVE_SELGROUPS );
for ( long ll : tmp ) {
m_selGroupIDs.add( ll );
}
m_groupid = bundle.getLong( SAVE_GROUPID );
m_netLaunchInfo = new NetLaunchInfo( bundle );
m_missingDictName = bundle.getString( SAVE_DICTNAMES );