]> hydra-www.ietfng.org Git - acmetensortoys-ctfws-android/commitdiff
Display rationale in game state line, too
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Fri, 24 Feb 2017 20:39:09 +0000 (15:39 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Fri, 24 Feb 2017 20:39:09 +0000 (15:39 -0500)
mobile/src/main/java/com/acmetensortoys/ctfwstimer/CtFwSDisplayLocal.java

index 5b5a552907fc0084b7663557cb02e6ac559c92d8..c89e8fe2a2b38c74a814229b046aedd66bd595d2 100644 (file)
@@ -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;
         }