mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
pass context into GameSummary constructor rather than into methods
that need it. No behavior change.
This commit is contained in:
parent
28c78a0a6a
commit
47bdec4eda
5 changed files with 22 additions and 20 deletions
|
@ -107,7 +107,7 @@ public class DBUtils {
|
|||
Cursor cursor = db.query( DBHelper.TABLE_NAME_SUM, columns,
|
||||
selection, null, null, null, null );
|
||||
if ( 1 == cursor.getCount() && cursor.moveToFirst() ) {
|
||||
summary = new GameSummary();
|
||||
summary = new GameSummary( context );
|
||||
summary.nMoves = cursor.getInt(cursor.
|
||||
getColumnIndex(DBHelper.NUM_MOVES));
|
||||
summary.nPlayers =
|
||||
|
@ -223,7 +223,7 @@ public class DBUtils {
|
|||
values.put( DBHelper.TURN, summary.turn );
|
||||
values.put( DBHelper.GIFLAGS, summary.giflags() );
|
||||
values.put( DBHelper.PLAYERS,
|
||||
summary.summarizePlayers(context) );
|
||||
summary.summarizePlayers() );
|
||||
values.put( DBHelper.DICTLANG, summary.dictLang );
|
||||
values.put( DBHelper.GAME_OVER, summary.gameOver );
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public class GameListAdapter extends XWListAdapter {
|
|||
} else {
|
||||
//Assert.assertNotNull( summary );
|
||||
|
||||
String state = summary.summarizeState( m_context );
|
||||
String state = summary.summarizeState();
|
||||
|
||||
TextView view = (TextView)layout.findViewById( R.id.game_name );
|
||||
if ( hideTitle ) {
|
||||
|
@ -168,7 +168,7 @@ public class GameListAdapter extends XWListAdapter {
|
|||
View tmp = m_factory.inflate( R.layout.player_list_elem,
|
||||
null );
|
||||
view = (TextView)tmp.findViewById( R.id.item_name );
|
||||
view.setText( summary.summarizePlayer( m_context, ii ) );
|
||||
view.setText( summary.summarizePlayer( ii ) );
|
||||
view = (TextView)tmp.findViewById( R.id.item_score );
|
||||
view.setText( String.format( " %d", summary.scores[ii] ) );
|
||||
if ( summary.isNextToPlay( ii ) ) {
|
||||
|
@ -200,7 +200,7 @@ public class GameListAdapter extends XWListAdapter {
|
|||
marker.setImageResource( iconID );
|
||||
|
||||
view = (TextView)layout.findViewById( R.id.role );
|
||||
String roleSummary = summary.summarizeRole( m_context );
|
||||
String roleSummary = summary.summarizeRole();
|
||||
if ( null != roleSummary ) {
|
||||
view.setText( roleSummary );
|
||||
} else {
|
||||
|
|
|
@ -258,7 +258,7 @@ public class GameUtils {
|
|||
int gamePtr, CurGameInfo gi,
|
||||
FeedUtilsImpl feedImpl )
|
||||
{
|
||||
GameSummary summary = new GameSummary( gi );
|
||||
GameSummary summary = new GameSummary( context, gi );
|
||||
XwJNI.game_summarize( gamePtr, summary );
|
||||
|
||||
if ( null != feedImpl ) {
|
||||
|
@ -984,7 +984,7 @@ public class GameUtils {
|
|||
|
||||
saveGame( context, gamePtr, gi, lock, false );
|
||||
|
||||
GameSummary summary = new GameSummary( gi );
|
||||
GameSummary summary = new GameSummary( context, gi );
|
||||
XwJNI.game_summarize( gamePtr, summary );
|
||||
DBUtils.saveSummary( context, lock, summary );
|
||||
|
||||
|
|
|
@ -59,14 +59,16 @@ public class GameSummary {
|
|||
private int m_giFlags;
|
||||
private String m_playersSummary;
|
||||
private CurGameInfo m_gi;
|
||||
private Context m_context;
|
||||
|
||||
public GameSummary(){
|
||||
public GameSummary( Context context ) {
|
||||
m_context = context;
|
||||
pendingMsgLevel = 0;
|
||||
}
|
||||
|
||||
public GameSummary( CurGameInfo gi )
|
||||
public GameSummary( Context context, CurGameInfo gi )
|
||||
{
|
||||
this();
|
||||
this( context );
|
||||
nPlayers = gi.nPlayers;
|
||||
dictLang = gi.dictLang;
|
||||
serverRole = gi.serverRole;
|
||||
|
@ -78,7 +80,7 @@ public class GameSummary {
|
|||
return null != relayID;
|
||||
}
|
||||
|
||||
public String summarizePlayers( Context context )
|
||||
public String summarizePlayers()
|
||||
{
|
||||
String result;
|
||||
if ( null == m_gi ) {
|
||||
|
@ -110,25 +112,25 @@ public class GameSummary {
|
|||
m_playersSummary = summary;
|
||||
}
|
||||
|
||||
public String summarizeState( Context context )
|
||||
public String summarizeState()
|
||||
{
|
||||
String result = null;
|
||||
if ( gameOver ) {
|
||||
result = context.getString( R.string.gameOver );
|
||||
result = m_context.getString( R.string.gameOver );
|
||||
} else {
|
||||
result = String.format( context.getString(R.string.movesf),
|
||||
result = String.format( m_context.getString(R.string.movesf),
|
||||
nMoves );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public String summarizeRole( Context context )
|
||||
public String summarizeRole()
|
||||
{
|
||||
String result = null;
|
||||
if ( isRelayGame() ) {
|
||||
Assert.assertTrue( CommsAddrRec.CommsConnType.COMMS_CONN_RELAY
|
||||
== conType );
|
||||
String fmt = context.getString( R.string.summary_fmt_relay );
|
||||
String fmt = m_context.getString( R.string.summary_fmt_relay );
|
||||
result = String.format( fmt, roomName );
|
||||
}
|
||||
return result;
|
||||
|
@ -175,14 +177,14 @@ public class GameSummary {
|
|||
m_giFlags = flags;
|
||||
}
|
||||
|
||||
public String summarizePlayer( Context context, int indx )
|
||||
public String summarizePlayer( int indx )
|
||||
{
|
||||
String player = players[indx];
|
||||
int formatID = 0;
|
||||
if ( !isLocal(indx) ) {
|
||||
boolean isMissing = 0 != ((1 << indx) & missingPlayers);
|
||||
if ( isMissing ) {
|
||||
player = context.getString( R.string.missing_player );
|
||||
player = m_context.getString( R.string.missing_player );
|
||||
} else {
|
||||
formatID = R.string.str_nonlocal_namef;
|
||||
}
|
||||
|
@ -191,7 +193,7 @@ public class GameSummary {
|
|||
}
|
||||
|
||||
if ( 0 != formatID ) {
|
||||
String format = context.getString( formatID );
|
||||
String format = m_context.getString( formatID );
|
||||
player = String.format( format, player );
|
||||
}
|
||||
return player;
|
||||
|
|
|
@ -264,7 +264,7 @@ public class JNIThread extends Thread {
|
|||
XwJNI.server_do( m_jniGamePtr );
|
||||
|
||||
XwJNI.game_getGi( m_jniGamePtr, m_gi );
|
||||
GameSummary summary = new GameSummary( m_gi );
|
||||
GameSummary summary = new GameSummary( m_context, m_gi );
|
||||
XwJNI.game_summarize( m_jniGamePtr, summary );
|
||||
byte[] state = XwJNI.game_saveToStream( m_jniGamePtr, null );
|
||||
GameUtils.saveGame( m_context, state, m_lock, false );
|
||||
|
|
Loading…
Add table
Reference in a new issue