]> hydra-www.ietfng.org Git - acmetensortoys-ctfws-android/commitdiff
Ensure we have flag counts more often
authorNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sat, 27 Oct 2018 16:13:23 +0000 (17:13 +0100)
committerNathaniel Wesley Filardo <nwfilardo@gmail.com>
Sun, 28 Oct 2018 00:55:59 +0000 (01:55 +0100)
In particular, we will want to display this even if we didn't get a Now
message, say, if we've relauched the app after the game ended.

mobile/src/main/java/com/acmetensortoys/ctfwstimer/CtFwSDisplayLocal.java

index 87bdcf9d129c32b2c1c03c894d01a150206fb1fe..8a8f8d2c5537fc3b809fc1daf788754a54d19931 100644 (file)
@@ -162,10 +162,24 @@ class CtFwSDisplayLocal implements CtFwSGameStateManager.Observer {
         stv.post(r);
     }
 
+    private void doSetFlagsLabel(final CtFwSGameStateManager gs) {
+        final TextView tv_flags = mAct.findViewById(R.id.tv_flags_label);
+        tv_flags.post(new Runnable() {
+            @Override
+            public void run() {
+                tv_flags.setText(mAct.getResources()
+                        .getQuantityString(R.plurals.ctfws_flags,
+                                gs.getFlagsTotal(),
+                                gs.getFlagsTotal()));
+            }
+        });
+    }
+
     @Override
     public void onCtFwSConfigure(final CtFwSGameStateManager gs) {
         doSetGameStateLabelText(gs, null);
         doSetSidesText(gs);
+        doSetFlagsLabel(gs);
     }
 
     @Override
@@ -177,6 +191,7 @@ class CtFwSDisplayLocal implements CtFwSGameStateManager.Observer {
 
         doSetGameStateLabelText(gs, now);
         doSetSidesText(gs);
+        doSetFlagsLabel(gs);
 
         if (now.rationale != CtFwSGameStateManager.NowRationale.NR_GAME_IN_PROGRESS) {
             Log.d("CtFwS", "Rationale: " + now.rationale + " stop=" + now.stop);
@@ -287,18 +302,6 @@ class CtFwSDisplayLocal implements CtFwSGameStateManager.Observer {
                 }
             });
         }
-        {
-            final TextView tv_flags = mAct.findViewById(R.id.tv_flags_label);
-            tv_flags.post(new Runnable() {
-                @Override
-                public void run() {
-                    tv_flags.setText(mAct.getResources()
-                            .getQuantityString(R.plurals.ctfws_flags,
-                                    gs.getFlagsTotal(),
-                                    gs.getFlagsTotal()));
-                }
-            });
-        }
     }
 
     private void doReset() {