mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-14 20:47:54 +01:00
cleanup connection status display text
Get rid of treating 0 as a legit date (1970 being illegit). Tweak formatting. It's not perfect, but few people see it so we'll see how it goes during development.
This commit is contained in:
parent
1a36f3286b
commit
24a38c8f46
2 changed files with 30 additions and 13 deletions
|
@ -84,14 +84,24 @@ public class ConnStatusHandler {
|
||||||
|
|
||||||
public String newerStr( Context context )
|
public String newerStr( Context context )
|
||||||
{
|
{
|
||||||
s_time.set( successNewer? lastSuccess : lastFailure );
|
String result = null;
|
||||||
return format( context, s_time );
|
long time = successNewer? lastSuccess : lastFailure;
|
||||||
|
if ( time > 0 ) {
|
||||||
|
s_time.set( time );
|
||||||
|
result = format( context, s_time );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String olderStr( Context context )
|
public String olderStr( Context context )
|
||||||
{
|
{
|
||||||
s_time.set( successNewer? lastFailure : lastSuccess );
|
String result = null;
|
||||||
return format( context, s_time );
|
long time = successNewer? lastFailure : lastSuccess;
|
||||||
|
if ( time > 0 ) {
|
||||||
|
s_time.set( time );
|
||||||
|
result = format( context, s_time );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update( boolean success )
|
public void update( boolean success )
|
||||||
|
@ -175,13 +185,20 @@ public class ConnStatusHandler {
|
||||||
String did = addDebugInfo( context, typ );
|
String did = addDebugInfo( context, typ );
|
||||||
sb.append( String.format( "\n\n*** %s %s***\n",
|
sb.append( String.format( "\n\n*** %s %s***\n",
|
||||||
typ.longName( context ), did ) );
|
typ.longName( context ), did ) );
|
||||||
|
|
||||||
|
// For sends we list failures too.
|
||||||
SuccessRecord record = recordFor( typ, false );
|
SuccessRecord record = recordFor( typ, false );
|
||||||
tmp = LocUtils.getString( context, record.successNewer?
|
tmp = LocUtils.getString( context, record.successNewer?
|
||||||
R.string.connstat_succ :
|
R.string.connstat_succ :
|
||||||
R.string.connstat_unsucc );
|
R.string.connstat_unsucc );
|
||||||
|
|
||||||
|
String timeStr = record.newerStr( context );
|
||||||
|
if ( null != timeStr ) {
|
||||||
sb.append( LocUtils
|
sb.append( LocUtils
|
||||||
.getString( context, R.string.connstat_lastsend_fmt,
|
.getString( context, R.string.connstat_lastsend_fmt,
|
||||||
tmp, record.newerStr( context ) ) );
|
tmp, timeStr ) )
|
||||||
|
.append( "\n" );
|
||||||
|
}
|
||||||
|
|
||||||
int fmtId = 0;
|
int fmtId = 0;
|
||||||
if ( record.successNewer ) {
|
if ( record.successNewer ) {
|
||||||
|
@ -193,11 +210,12 @@ public class ConnStatusHandler {
|
||||||
fmtId = R.string.connstat_lastother_unsucc_fmt;
|
fmtId = R.string.connstat_lastother_unsucc_fmt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( 0 != fmtId ) {
|
timeStr = record.olderStr( context );
|
||||||
sb.append( LocUtils.getString( context, fmtId,
|
if ( 0 != fmtId && null != timeStr ) {
|
||||||
record.olderStr( context )));
|
sb.append( LocUtils.getString( context, fmtId, timeStr ))
|
||||||
|
.append( "\n" );
|
||||||
}
|
}
|
||||||
sb.append( "\n\n" );
|
sb.append( "\n" );
|
||||||
|
|
||||||
record = recordFor( typ, true );
|
record = recordFor( typ, true );
|
||||||
if ( record.haveSuccess() ) {
|
if ( record.haveSuccess() ) {
|
||||||
|
|
|
@ -511,8 +511,7 @@ public class Utils {
|
||||||
new ObjectInputStream( new ByteArrayInputStream(bytes) );
|
new ObjectInputStream( new ByteArrayInputStream(bytes) );
|
||||||
result = ois.readObject();
|
result = ois.readObject();
|
||||||
} catch ( Exception ex ) {
|
} catch ( Exception ex ) {
|
||||||
Log.ex( TAG, ex );
|
Log.d( TAG, ex.getMessage() );
|
||||||
Assert.assertFalse( BuildConfig.DEBUG );
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue