add creation time to set displayable in gamelistitem

I'm storing the create time in the DB on Android so don't need to add it
to CurGameInfo right away.
This commit is contained in:
Eric House 2020-09-23 11:56:32 -07:00
parent 8072a0c629
commit 00c2052af8
6 changed files with 20 additions and 4 deletions

View file

@ -141,6 +141,7 @@ public class DBUtils {
DBHelper.LASTPLAY_TIME, DBHelper.REMOTEDEVS,
DBHelper.LASTMOVE, DBHelper.NPACKETSPENDING,
DBHelper.EXTRAS, DBHelper.NEXTDUPTIMER,
DBHelper.CREATE_TIME,
};
String selection = String.format( ROW_ID_FMT, lock.getRowid() );
@ -190,6 +191,9 @@ public class DBUtils {
cursor.getInt(cursor.getColumnIndex(DBHelper.LASTMOVE));
summary.dupTimerExpires =
cursor.getInt(cursor.getColumnIndex(DBHelper.NEXTDUPTIMER));
summary.created = cursor
.getLong(cursor.getColumnIndex(DBHelper.CREATE_TIME));
String str = cursor
.getString(cursor.getColumnIndex(DBHelper.EXTRAS));
summary.setExtras( str );
@ -1034,7 +1038,7 @@ public class DBUtils {
ContentValues values = new ContentValues();
values.put( DBHelper.SNAPSHOT, bytes );
long timestamp = new Date().getTime();
long timestamp = new Date().getTime(); // milliseconds since epoch
values.put( DBHelper.CREATE_TIME, timestamp );
values.put( DBHelper.LASTPLAY_TIME, timestamp );
values.put( DBHelper.GROUPID, groupID );

View file

@ -77,6 +77,10 @@ public class GameListItem extends LinearLayout
private boolean m_selected = false;
private DrawSelDelegate m_dsdel;
private static DateFormat sDF = DateFormat
.getDateTimeInstance( DateFormat.SHORT, DateFormat.SHORT );
public GameListItem( Context cx, AttributeSet as )
{
super( cx, as );
@ -276,6 +280,9 @@ public class GameListItem extends LinearLayout
case R.string.title_addrs_pref:
value = m_summary.conTypes.toString( m_context, false );
break;
case R.string.game_summary_field_created:
value = sDF.format( new Date( m_summary.created ) );
break;
}
String name = GameUtils.getName( m_context, m_rowid );
@ -323,9 +330,7 @@ public class GameListItem extends LinearLayout
long lastMoveTime = summary.lastMoveTime;
lastMoveTime *= 1000;
DateFormat df = DateFormat.getDateTimeInstance( DateFormat.SHORT,
DateFormat.SHORT );
m_modTime.setText( df.format( new Date( lastMoveTime ) ) );
m_modTime.setText( sDF.format( new Date( lastMoveTime ) ) );
setTypeIcon();

View file

@ -559,6 +559,7 @@ public class GamesListDelegate extends ListDelegateBase
R.string.game_summary_field_gameid,
R.string.game_summary_field_npackets,
R.string.title_addrs_pref,
R.string.game_summary_field_created,
};
int result = ids[0]; // need a default in case set changes
for ( int id : ids ) {

View file

@ -32,6 +32,7 @@ public class XWSumListPreference extends XWListPreference {
R.string.game_summary_field_rowid,
R.string.game_summary_field_gameid,
R.string.title_addrs_pref,
R.string.game_summary_field_created,
};
public XWSumListPreference( Context context, AttributeSet attrs )

View file

@ -77,6 +77,7 @@ public class GameSummary implements Serializable {
public String relayID;
public int seed;
public long modtime;
public long created;
public int gameID;
public String[] remoteDevs; // BTAddrs and phone numbers
@ -124,6 +125,7 @@ public class GameSummary implements Serializable {
&& gameOver == other.gameOver
&& seed == other.seed
&& modtime == other.modtime
&& created == other.created
&& gameID == other.gameID
&& dictLang == other.dictLang
&& nPacketsPending == other.nPacketsPending

View file

@ -815,6 +815,9 @@
<string name="game_summary_field_opponents">Opponent name[s]</string>
<!-- List the state of the game, "Game over" or "10 moves made"
etc. -->
<!-- Debug-only: list creation date of game -->
<string name="game_summary_field_created">When created</string>
<!-- State the game is in, e.g. finished or awaiting players -->
<string name="game_summary_field_state">Game state</string>
<!-- Checkbox that when set prevents showing a title bar in the
game board window to save space -->