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

View file

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

View file

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

View file

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