From: Nathaniel Wesley Filardo Date: Fri, 24 Feb 2017 20:39:09 +0000 (-0500) Subject: Display rationale in game state line, too X-Git-Tag: release-1.2~36 X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=4f134ed2ac4d2f48573aed600ee4ff7ff3fddfae;p=acmetensortoys-ctfws-android Display rationale in game state line, too --- 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; }