modify games list items to include a second column with everything but

the players and connection method in it.  Put the game's last-saved
time in that column.  Now sort order has most recently opened games at
top.
This commit is contained in:
Andy2 2011-02-11 18:29:11 -08:00
parent 2beea5b04f
commit 95b60cc767
4 changed files with 37 additions and 20 deletions

View file

@ -14,14 +14,14 @@
/> />
<LinearLayout android:orientation="vertical" <LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="fill_parent"
android:layout_weight="1" android:layout_weight="1"
> >
<LinearLayout android:id="@+id/player_list" <LinearLayout android:id="@+id/player_list"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
> >
</LinearLayout> </LinearLayout>
@ -30,22 +30,27 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
/> />
</LinearLayout>
<LinearLayout android:orientation="horizontal" <LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="fill_parent"
> >
<TextView android:id="@+id/state" <TextView android:id="@+id/modtime"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="left" android:gravity="right"
/> />
<TextView android:id="@+id/dict" <TextView android:id="@+id/state"
android:layout_width="fill_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:gravity="right" android:gravity="right"
/> />
</LinearLayout> <TextView android:id="@+id/dict"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -59,7 +59,8 @@ public class DBUtils {
DBHelper.ROOMNAME, DBHelper.RELAYID, DBHelper.ROOMNAME, DBHelper.RELAYID,
DBHelper.SMSPHONE, DBHelper.SEED, DBHelper.SMSPHONE, DBHelper.SEED,
DBHelper.DICTLANG, DBHelper.DICTNAME, DBHelper.DICTLANG, DBHelper.DICTNAME,
DBHelper.SCORES, DBHelper.HASMSGS DBHelper.SCORES, DBHelper.HASMSGS,
DBHelper.LASTPLAY_TIME
}; };
String selection = DBHelper.FILE_NAME + "=\"" + file + "\""; String selection = DBHelper.FILE_NAME + "=\"" + file + "\"";
@ -89,6 +90,9 @@ public class DBUtils {
summary.dictName = summary.dictName =
cursor.getString(cursor. cursor.getString(cursor.
getColumnIndex(DBHelper.DICTNAME)); getColumnIndex(DBHelper.DICTNAME));
summary.modtime =
cursor.getLong(cursor.
getColumnIndex(DBHelper.LASTPLAY_TIME));
int tmp = cursor.getInt(cursor. int tmp = cursor.getInt(cursor.
getColumnIndex(DBHelper.GAME_OVER)); getColumnIndex(DBHelper.GAME_OVER));
summary.gameOver = tmp == 0 ? false : true; summary.gameOver = tmp == 0 ? false : true;

View file

@ -26,7 +26,9 @@ import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import android.database.DataSetObserver; import android.database.DataSetObserver;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.text.DateFormat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.widget.LinearLayout; import android.widget.LinearLayout;
@ -41,11 +43,14 @@ public class GameListAdapter extends XWListAdapter {
private LayoutInflater m_factory; private LayoutInflater m_factory;
private int m_layoutId; private int m_layoutId;
private HashMap<String,View> m_viewsCache; private HashMap<String,View> m_viewsCache;
private DateFormat m_df;
public GameListAdapter( Context context ) { public GameListAdapter( Context context ) {
super( context, DBUtils.gamesList(context).length ); super( context, DBUtils.gamesList(context).length );
m_context = context; m_context = context;
m_factory = LayoutInflater.from( context ); m_factory = LayoutInflater.from( context );
m_df = DateFormat.getDateTimeInstance( DateFormat.SHORT,
DateFormat.SHORT );
int sdk_int = 0; int sdk_int = 0;
try { try {
@ -79,7 +84,7 @@ public class GameListAdapter extends XWListAdapter {
view = (TextView)tmp.findViewById( R.id.item_name ); view = (TextView)tmp.findViewById( R.id.item_name );
view.setText( summary.summarizePlayer( m_context, ii ) ); view.setText( summary.summarizePlayer( m_context, ii ) );
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 ) ) { if ( summary.isNextToPlay( ii ) ) {
tmp.setBackgroundColor( 0x7F00FF00 ); tmp.setBackgroundColor( 0x7F00FF00 );
} }
@ -90,6 +95,8 @@ public class GameListAdapter extends XWListAdapter {
view.setText( summary.summarizeState( m_context ) ); view.setText( summary.summarizeState( m_context ) );
view = (TextView)layout.findViewById( R.id.dict ); view = (TextView)layout.findViewById( R.id.dict );
view.setText( summary.dictName ); view.setText( summary.dictName );
view = (TextView)layout.findViewById( R.id.modtime );
view.setText( m_df.format( new Date( summary.modtime ) ) );
view = (TextView)layout.findViewById( R.id.role ); view = (TextView)layout.findViewById( R.id.role );
String roleSummary = summary.summarizeRole( m_context ); String roleSummary = summary.summarizeRole( m_context );

View file

@ -43,6 +43,7 @@ public class GameSummary {
public String relayID; public String relayID;
public int seed; public int seed;
public boolean msgsPending; public boolean msgsPending;
public long modtime;
public int dictLang; public int dictLang;
public String dictName; public String dictName;