mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-07 05:24:46 +01:00
persist game config state across rotations
Make CurGameInfo serializable, make sure it's updated in onPause, and then just add it to the bundle. Easy.
This commit is contained in:
parent
b050ac5d62
commit
99664a8360
3 changed files with 10 additions and 37 deletions
|
@ -66,6 +66,7 @@ public class GameConfigDelegate extends DelegateBase
|
|||
private static final String INTENT_FORRESULT_NEWGAME = "newgame";
|
||||
|
||||
private static final String WHICH_PLAYER = "WHICH_PLAYER";
|
||||
private static final String LOCAL_GI = "LOCAL_GI";
|
||||
|
||||
private Activity m_activity;
|
||||
private CheckBox m_joinPublicCheck;
|
||||
|
@ -530,6 +531,7 @@ public class GameConfigDelegate extends DelegateBase
|
|||
|
||||
protected void onPause()
|
||||
{
|
||||
saveChanges(); // save before clearing m_giOrig!
|
||||
m_giOrig = null; // flag for onStart and onResume
|
||||
super.onPause();
|
||||
if ( null != m_jniThread ) {
|
||||
|
@ -541,6 +543,7 @@ public class GameConfigDelegate extends DelegateBase
|
|||
protected void onSaveInstanceState( Bundle outState )
|
||||
{
|
||||
outState.putInt( WHICH_PLAYER, m_whichPlayer );
|
||||
outState.putSerializable( LOCAL_GI, m_gi );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -666,6 +669,7 @@ public class GameConfigDelegate extends DelegateBase
|
|||
{
|
||||
if ( null != bundle ) {
|
||||
m_whichPlayer = bundle.getInt( WHICH_PLAYER );
|
||||
m_gi = (CurGameInfo)bundle.getSerializable( LOCAL_GI );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1152,41 +1156,6 @@ public class GameConfigDelegate extends DelegateBase
|
|||
return 0;
|
||||
}
|
||||
|
||||
// private int titleForDlg( int id )
|
||||
// {
|
||||
// switch( id ) {
|
||||
// // case ROLE_EDIT_RELAY:
|
||||
// // return R.string.tab_relay;
|
||||
// // case ROLE_EDIT_SMS:
|
||||
// // return R.string.tab_sms;
|
||||
// // case ROLE_EDIT_BT:
|
||||
// // return R.string.tab_bluetooth;
|
||||
// }
|
||||
// Assert.fail();
|
||||
// return -1;
|
||||
// }
|
||||
|
||||
// private String[] makeXportStrings()
|
||||
// {
|
||||
// ArrayList<String> strings = new ArrayList<String>();
|
||||
// ArrayList<CommsAddrRec.CommsConnType> types
|
||||
// = new ArrayList<CommsAddrRec.CommsConnType>();
|
||||
|
||||
// strings.add( getString(R.string.tab_relay) );
|
||||
// types.add( CommsAddrRec.CommsConnType.COMMS_CONN_RELAY );
|
||||
|
||||
// if ( m_canDoSMS ) {
|
||||
// strings.add( getString(R.string.tab_sms) );
|
||||
// types.add( CommsAddrRec.CommsConnType.COMMS_CONN_SMS );
|
||||
// }
|
||||
// if ( m_canDoBT ) {
|
||||
// strings.add( getString(R.string.tab_bluetooth) );
|
||||
// types.add( CommsAddrRec.CommsConnType.COMMS_CONN_BT );
|
||||
// }
|
||||
// m_types = types.toArray( new CommsAddrRec.CommsConnType[types.size()] );
|
||||
// return strings.toArray( new String[strings.size()] );
|
||||
// }
|
||||
|
||||
private void saveChanges()
|
||||
{
|
||||
if ( !localOnlyGame() ) {
|
||||
|
|
|
@ -35,7 +35,9 @@ import java.util.Arrays;
|
|||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
public class CurGameInfo {
|
||||
import java.io.Serializable;
|
||||
|
||||
public class CurGameInfo implements Serializable {
|
||||
private static final String TAG = CurGameInfo.class.getSimpleName();
|
||||
|
||||
public static final int MAX_NUM_PLAYERS = 4;
|
||||
|
|
|
@ -22,11 +22,13 @@ package org.eehouse.android.xw4.jni;
|
|||
|
||||
import android.content.Context;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.eehouse.android.xw4.R;
|
||||
|
||||
public class LocalPlayer {
|
||||
public class LocalPlayer implements Serializable {
|
||||
public String name;
|
||||
public String password;
|
||||
public String dictName;
|
||||
|
|
Loading…
Reference in a new issue