mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
break item info into four text areas that can now be positioned to
look better.
This commit is contained in:
parent
84a98fab4d
commit
f03579dd14
3 changed files with 53 additions and 22 deletions
|
@ -11,4 +11,22 @@
|
||||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
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>
|
</LinearLayout>
|
||||||
|
|
|
@ -50,7 +50,6 @@ public class GameListAdapter extends XWListAdapter {
|
||||||
public Object getItem( int position )
|
public Object getItem( int position )
|
||||||
{
|
{
|
||||||
final View layout = m_factory.inflate( R.layout.game_list_item, null );
|
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];
|
String path = Utils.gamesList(m_context)[position];
|
||||||
byte[] stream = open( path );
|
byte[] stream = open( path );
|
||||||
|
@ -59,9 +58,22 @@ public class GameListAdapter extends XWListAdapter {
|
||||||
XwJNI.gi_from_stream( gi, stream );
|
XwJNI.gi_from_stream( gi, stream );
|
||||||
|
|
||||||
GameSummary summary = Utils.getSummary( m_context, path );
|
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;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ public class CurGameInfo {
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String summarize( Context context, GameSummary summary )
|
public String summarizePlayers( Context context, GameSummary summary )
|
||||||
{
|
{
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
String vsString = context.getString( R.string.vs );
|
String vsString = context.getString( R.string.vs );
|
||||||
|
@ -223,7 +223,12 @@ public class CurGameInfo {
|
||||||
}
|
}
|
||||||
sb.append( String.format( " %s ", vsString ) );
|
sb.append( String.format( " %s ", vsString ) );
|
||||||
}
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String summarizeRole( Context context, GameSummary summary )
|
||||||
|
{
|
||||||
|
String result = null;
|
||||||
if ( null != summary ) {
|
if ( null != summary ) {
|
||||||
DeviceRole role = serverRole;
|
DeviceRole role = serverRole;
|
||||||
if ( role != DeviceRole.SERVER_STANDALONE ) {
|
if ( role != DeviceRole.SERVER_STANDALONE ) {
|
||||||
|
@ -253,30 +258,26 @@ public class CurGameInfo {
|
||||||
: summaryID );
|
: summaryID );
|
||||||
String roleStr = context.getString( roleID );
|
String roleStr = context.getString( roleID );
|
||||||
if ( justListening ) {
|
if ( justListening ) {
|
||||||
tmp = String.format( fmt, roleStr );
|
result = String.format( fmt, roleStr );
|
||||||
} else {
|
} 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",
|
public String summarizeState( Context context, GameSummary summary )
|
||||||
context.getString( R.string.dictionary ),
|
{
|
||||||
dictName ) );
|
String result = null;
|
||||||
|
if ( summary.gameOver ) {
|
||||||
return sb.toString();
|
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()
|
public boolean addPlayer()
|
||||||
|
|
Loading…
Add table
Reference in a new issue