mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-18 22:26:30 +01:00
Also override TextView to show turn left there. Works, requiring only
that actual percentage of turn remainning be calculated.
This commit is contained in:
parent
50b10cd365
commit
0579253b8d
3 changed files with 63 additions and 17 deletions
|
@ -33,7 +33,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
>
|
||||
|
||||
<TextView android:id="@+id/game_name"
|
||||
<org.eehouse.android.xw4.ExpiringTextView
|
||||
android:id="@+id/game_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/* -*- compile-command: "cd ../../../../../; ant debug install"; -*- */
|
||||
/*
|
||||
* Copyright 2012 by Eric House (xwords@eehouse.org). All rights
|
||||
* reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License as
|
||||
* published by the Free Software Foundation; either version 2 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
package org.eehouse.android.xw4;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
|
||||
class ExpiringTextView extends TextView {
|
||||
private ExpiringDelegate m_delegate = null;
|
||||
private Context m_context;
|
||||
|
||||
public ExpiringTextView( Context context, AttributeSet attrs )
|
||||
{
|
||||
super( context, attrs );
|
||||
m_context = context;
|
||||
}
|
||||
|
||||
public void setPct( int pct, boolean haveTurn, boolean haveTurnLocal )
|
||||
{
|
||||
m_delegate = new ExpiringDelegate( m_context, this, pct, haveTurn,
|
||||
haveTurnLocal );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw( Canvas canvas )
|
||||
{
|
||||
super.onDraw( canvas );
|
||||
if ( null != m_delegate ) {
|
||||
m_delegate.onDraw( canvas );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -60,7 +60,7 @@ public class GameListAdapter extends XWListAdapter {
|
|||
private class ViewInfo implements View.OnClickListener {
|
||||
private View m_view;
|
||||
private View m_hideable;
|
||||
private View m_name;
|
||||
private ExpiringTextView m_name;
|
||||
private boolean m_expanded, m_haveTurn, m_haveTurnLocal;
|
||||
private long m_rowid;
|
||||
private ImageButton m_expandButton;
|
||||
|
@ -78,7 +78,7 @@ public class GameListAdapter extends XWListAdapter {
|
|||
m_haveTurn = haveTurn;
|
||||
m_haveTurnLocal = haveTurnLocal;
|
||||
m_hideable = (LinearLayout)view.findViewById( R.id.hideable );
|
||||
m_name = (TextView)m_view.findViewById( R.id.game_name );
|
||||
m_name = (ExpiringTextView)m_view.findViewById( R.id.game_name );
|
||||
m_expandButton = (ImageButton)view.findViewById( R.id.expander );
|
||||
m_expandButton.setOnClickListener( this );
|
||||
showHide();
|
||||
|
@ -92,13 +92,7 @@ public class GameListAdapter extends XWListAdapter {
|
|||
m_hideable.setVisibility( m_expanded? View.VISIBLE : View.GONE );
|
||||
|
||||
m_name.setBackgroundColor( android.R.color.transparent );
|
||||
if ( !m_expanded ) {
|
||||
if ( m_haveTurnLocal ) {
|
||||
m_name.setBackgroundColor( Utils.TURN_COLOR );
|
||||
} else if ( m_haveTurn ) {
|
||||
m_name.setBackgroundResource( R.drawable.green_border );
|
||||
}
|
||||
}
|
||||
m_name.setPct( 75, m_haveTurn && !m_expanded, m_haveTurnLocal );
|
||||
}
|
||||
|
||||
public void onClick( View view ) {
|
||||
|
|
Loading…
Reference in a new issue