show green border in contracted view too when appropriate, and not

only for net games.
This commit is contained in:
Eric House 2012-06-12 07:19:18 -07:00 committed by Eric House
parent d46c827b4c
commit 545cf9166f

View file

@ -52,15 +52,16 @@ public class GameListAdapter extends XWListAdapter {
private View m_view; private View m_view;
private View m_hideable; private View m_hideable;
private View m_name; private View m_name;
private boolean m_expanded, m_haveTurn; private boolean m_expanded, m_haveTurn, m_haveTurnLocal;
private long m_rowid; private long m_rowid;
private ImageButton m_expandButton; private ImageButton m_expandButton;
public ViewInfo( View view, long rowid, boolean expanded, public ViewInfo( View view, long rowid, boolean expanded,
boolean haveTurn ) { boolean haveTurn, boolean haveTurnLocal ) {
m_view = view; m_view = view;
m_rowid = rowid; m_rowid = rowid;
m_expanded = expanded; m_expanded = expanded;
m_haveTurn = haveTurn; m_haveTurn = haveTurn;
m_haveTurnLocal = haveTurnLocal;
m_hideable = (LinearLayout)view.findViewById( R.id.hideable ); m_hideable = (LinearLayout)view.findViewById( R.id.hideable );
m_name = (TextView)m_view.findViewById( R.id.game_name ); m_name = (TextView)m_view.findViewById( R.id.game_name );
m_expandButton = (ImageButton)view.findViewById( R.id.expander ); m_expandButton = (ImageButton)view.findViewById( R.id.expander );
@ -75,8 +76,14 @@ public class GameListAdapter extends XWListAdapter {
R.drawable.expander_ic_minimized); R.drawable.expander_ic_minimized);
m_hideable.setVisibility( m_expanded? View.VISIBLE : View.GONE ); m_hideable.setVisibility( m_expanded? View.VISIBLE : View.GONE );
m_name.setBackgroundColor( m_haveTurn && !m_expanded ? TURN_COLOR : m_name.setBackgroundColor( android.R.color.transparent );
android.R.color.transparent ); if ( !m_expanded ) {
if ( m_haveTurnLocal ) {
m_name.setBackgroundColor( TURN_COLOR );
} else if ( m_haveTurn ) {
m_name.setBackgroundResource( R.drawable.green_border );
}
}
} }
public void onClick( View view ) { public void onClick( View view ) {
@ -164,7 +171,8 @@ public class GameListAdapter extends XWListAdapter {
LinearLayout list = LinearLayout list =
(LinearLayout)layout.findViewById( R.id.player_list ); (LinearLayout)layout.findViewById( R.id.player_list );
boolean haveNetTurn = false; boolean haveTurn = false;
boolean haveTurnLocal = false;
boolean[] isLocal = new boolean[1]; boolean[] isLocal = new boolean[1];
for ( int ii = 0; ii < summary.nPlayers; ++ii ) { for ( int ii = 0; ii < summary.nPlayers; ++ii ) {
View tmp = m_factory.inflate( R.layout.player_list_elem, View tmp = m_factory.inflate( R.layout.player_list_elem,
@ -174,14 +182,13 @@ public class GameListAdapter extends XWListAdapter {
view = (TextView)tmp.findViewById( R.id.item_score ); view = (TextView)tmp.findViewById( R.id.item_score );
view.setText( String.format( " %d", summary.scores[ii] ) ); view.setText( String.format( " %d", summary.scores[ii] ) );
if ( summary.isNextToPlay( ii, isLocal ) ) { if ( summary.isNextToPlay( ii, isLocal ) ) {
haveTurn = true;
if ( isLocal[0] ) { if ( isLocal[0] ) {
haveTurnLocal = true;
tmp.setBackgroundColor( TURN_COLOR ); tmp.setBackgroundColor( TURN_COLOR );
} else { } else {
tmp.setBackgroundResource( R.drawable.green_border ); tmp.setBackgroundResource( R.drawable.green_border );
} }
if ( summary.isMultiGame() ) {
haveNetTurn = true;
}
} }
list.addView( tmp, ii ); list.addView( tmp, ii );
} }
@ -216,7 +223,7 @@ public class GameListAdapter extends XWListAdapter {
boolean expanded = DBUtils.getExpanded( m_context, m_rowid ); boolean expanded = DBUtils.getExpanded( m_context, m_rowid );
ViewInfo vi = new ViewInfo( layout, m_rowid, ViewInfo vi = new ViewInfo( layout, m_rowid,
expanded, haveNetTurn ); expanded, haveTurn, haveTurnLocal );
synchronized( m_viewsCache ) { synchronized( m_viewsCache ) {
m_viewsCache.put( m_rowid, vi ); m_viewsCache.put( m_rowid, vi );