mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-01 06:19:57 +01:00
pass the rematch request off to GamesList where it can create new
games without interference from locked current game. Handle standalone case by cloning and launching: easy. Networked games will be harder.
This commit is contained in:
parent
c041792f83
commit
2c71c8425f
2 changed files with 35 additions and 2 deletions
|
@ -252,8 +252,7 @@ public class BoardActivity extends XWActivity
|
|||
lstnr = new DialogInterface.OnClickListener() {
|
||||
public void onClick( DialogInterface dlg,
|
||||
int whichButton ) {
|
||||
Utils.notImpl( BoardActivity.this );
|
||||
finish();
|
||||
doRematch();
|
||||
}
|
||||
};
|
||||
ab.setNegativeButton( R.string.button_rematch, lstnr );
|
||||
|
@ -2106,4 +2105,11 @@ public class BoardActivity extends XWActivity
|
|||
m_passwdEdit = (EditText)m_passwdLyt.findViewById( R.id.edit );
|
||||
}
|
||||
|
||||
private void doRematch()
|
||||
{
|
||||
Intent intent = GamesList.makeRematchIntent( this, m_gi, m_rowid );
|
||||
startActivity( intent );
|
||||
finish();
|
||||
}
|
||||
|
||||
} // class BoardActivity
|
||||
|
|
|
@ -68,6 +68,7 @@ public class GamesList extends XWListActivity
|
|||
|
||||
private static final String RELAYIDS_EXTRA = "relayids";
|
||||
private static final String GAMEID_EXTRA = "gameid";
|
||||
private static final String REMATCH_ROWID_EXTRA = "rowid";
|
||||
|
||||
private static final int NEW_NET_GAME_ACTION = 1;
|
||||
private static final int RESET_GAME_ACTION = 2;
|
||||
|
@ -291,6 +292,7 @@ public class GamesList extends XWListActivity
|
|||
startFirstHasDict( intent );
|
||||
startNewNetGame( intent );
|
||||
startHasGameID( intent );
|
||||
startHasRowID( intent );
|
||||
askDefaultNameIf();
|
||||
} // onCreate
|
||||
|
||||
|
@ -305,6 +307,7 @@ public class GamesList extends XWListActivity
|
|||
startFirstHasDict( intent );
|
||||
startNewNetGame( intent );
|
||||
startHasGameID( intent );
|
||||
startHasRowID( intent );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -826,6 +829,16 @@ public class GamesList extends XWListActivity
|
|||
}
|
||||
}
|
||||
|
||||
private void startHasRowID( Intent intent )
|
||||
{
|
||||
long rowid = intent.getLongExtra( REMATCH_ROWID_EXTRA, -1 );
|
||||
if ( -1 != rowid ) {
|
||||
// this will juggle if the preference is set
|
||||
long newid = GameUtils.dupeGame( this, rowid );
|
||||
GameUtils.launchGame( this, newid );
|
||||
}
|
||||
}
|
||||
|
||||
private void askDefaultNameIf()
|
||||
{
|
||||
if ( null == CommonPrefs.getDefaultPlayerName( this, 0, false ) ) {
|
||||
|
@ -900,6 +913,20 @@ public class GamesList extends XWListActivity
|
|||
return intent;
|
||||
}
|
||||
|
||||
public static Intent makeRematchIntent( Context context, CurGameInfo gi,
|
||||
long rowid )
|
||||
{
|
||||
Intent intent = makeSelfIntent( context );
|
||||
|
||||
if ( CurGameInfo.DeviceRole.SERVER_STANDALONE == gi.serverRole ) {
|
||||
intent.putExtra( REMATCH_ROWID_EXTRA, rowid );
|
||||
} else {
|
||||
Utils.notImpl( context );
|
||||
}
|
||||
|
||||
return intent;
|
||||
}
|
||||
|
||||
public static void openGame( Context context, Uri data )
|
||||
{
|
||||
Intent intent = makeSelfIntent( context );
|
||||
|
|
Loading…
Reference in a new issue