break item info into four text areas that can now be positioned to

look better.
This commit is contained in:
eehouse 2010-05-05 04:12:23 +00:00
parent 84a98fab4d
commit f03579dd14
3 changed files with 53 additions and 22 deletions

View file

@ -11,4 +11,22 @@
android:textAppearance="?android:attr/textAppearanceMedium"
/>
<TextView android:id="@+id/role"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/players"
/>
<TextView android:id="@+id/state"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/role"
/>
<TextView android:id="@+id/dict"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/state"
/>
</LinearLayout>

View file

@ -50,7 +50,6 @@ public class GameListAdapter extends XWListAdapter {
public Object getItem( int position )
{
final View layout = m_factory.inflate( R.layout.game_list_item, null );
TextView view = (TextView)layout.findViewById( R.id.players );
String path = Utils.gamesList(m_context)[position];
byte[] stream = open( path );
@ -59,9 +58,22 @@ public class GameListAdapter extends XWListAdapter {
XwJNI.gi_from_stream( gi, stream );
GameSummary summary = Utils.getSummary( m_context, path );
String summaryTxt = gi.summarize( m_context, summary );
view.setText( summaryTxt );
TextView view = (TextView)layout.findViewById( R.id.players );
view.setText( gi.summarizePlayers( m_context, summary ) );
view = (TextView)layout.findViewById( R.id.state );
view.setText( gi.summarizeState( m_context, summary ) );
view = (TextView)layout.findViewById( R.id.dict );
view.setText( gi.dictName );
view = (TextView)layout.findViewById( R.id.role );
String roleSummary = gi.summarizeRole( m_context, summary );
if ( null != roleSummary ) {
view.setText( roleSummary );
} else {
view.setVisibility( View.GONE );
}
}
return layout;
}

View file

@ -209,7 +209,7 @@ public class CurGameInfo {
return names;
}
public String summarize( Context context, GameSummary summary )
public String summarizePlayers( Context context, GameSummary summary )
{
StringBuffer sb = new StringBuffer();
String vsString = context.getString( R.string.vs );
@ -223,7 +223,12 @@ public class CurGameInfo {
}
sb.append( String.format( " %s ", vsString ) );
}
return sb.toString();
}
public String summarizeRole( Context context, GameSummary summary )
{
String result = null;
if ( null != summary ) {
DeviceRole role = serverRole;
if ( role != DeviceRole.SERVER_STANDALONE ) {
@ -253,30 +258,26 @@ public class CurGameInfo {
: summaryID );
String roleStr = context.getString( roleID );
if ( justListening ) {
tmp = String.format( fmt, roleStr );
result = String.format( fmt, roleStr );
} else {
tmp = String.format( fmt, roleStr, via );
result = String.format( fmt, roleStr, via );
}
sb.append( tmp );
}
}
if ( summary.gameOver ) {
tmp = context.getString( R.string.gameOver );
} else {
tmp = String.format( context.getString(R.string.movesf),
summary.nMoves );
}
sb.append( String.format( context.getString(R.string.statef),
tmp ) );
}
return result;
}
sb.append( String.format("\n%s %s",
context.getString( R.string.dictionary ),
dictName ) );
return sb.toString();
public String summarizeState( Context context, GameSummary summary )
{
String result = null;
if ( summary.gameOver ) {
result = context.getString( R.string.gameOver );
} else {
result = String.format( context.getString(R.string.movesf),
summary.nMoves );
}
return String.format( context.getString(R.string.statef), result );
}
public boolean addPlayer()