From 4f134ed2ac4d2f48573aed600ee4ff7ff3fddfae Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Fri, 24 Feb 2017 15:39:09 -0500 Subject: [PATCH] Display rationale in game state line, too --- .../ctfwstimer/CtFwSDisplayLocal.java | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/CtFwSDisplayLocal.java b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/CtFwSDisplayLocal.java index 5b5a552..c89e8fe 100644 --- a/mobile/src/main/java/com/acmetensortoys/ctfwstimer/CtFwSDisplayLocal.java +++ b/mobile/src/main/java/com/acmetensortoys/ctfwstimer/CtFwSDisplayLocal.java @@ -27,18 +27,23 @@ class CtFwSDisplayLocal implements CtFwSGameState.Observer { gameStateLabelText = mAct.getResources().getString(R.string.header_gamestate0); } - @Override - public void onCtFwSConfigure(final CtFwSGameState gs) { - int gameix = gs.getGameIx(); - gameStateLabelText = - (gs.isConfigured() && gameix != 0) + private void doSetGameStateLabelText(final CtFwSGameState gs, String rationale) { + int gameIndex = gs.getGameIx(); + + String pfx = + (gs.isConfigured() && gameIndex != 0) ? String.format( mAct.getResources() .getString(R.string.header_gamestateN), - gameix) + gameIndex) : mAct.getResources().getString(R.string.header_gamestate0); + if (rationale != null) { + gameStateLabelText = pfx + " " + rationale; + } else { + gameStateLabelText = pfx; + } final TextView gstv = (TextView) mAct.findViewById(R.id.header_gamestate); gstv.post(new Runnable() { @@ -49,6 +54,11 @@ class CtFwSDisplayLocal implements CtFwSGameState.Observer { }); } + @Override + public void onCtFwSConfigure(final CtFwSGameState gs) { + doSetGameStateLabelText(gs, null); + } + @Override public void onCtFwSNow(final CtFwSGameState gs, final CtFwSGameState.Now now) { // time base correction factor ("when we booted"-ish) @@ -56,9 +66,10 @@ class CtFwSDisplayLocal implements CtFwSGameState.Observer { Log.d("CtFwS", "Display game state; nowMS=" + now.wallMS + " r=" + now.round + " rs=" + now.roundStart + " re=" + now.roundEnd); + doSetGameStateLabelText(gs, now.rationale); + if (now.rationale != null) { Log.d("CtFwS", "Rationale: " + now.rationale + " stop=" + now.stop); - // TODO: display rationale somewhere, probably by hiding the game state! doReset(); return; } -- 2.50.1