From 375d3fd84b41a2730adcab46ca889bc90747c1ad Mon Sep 17 00:00:00 2001 From: gitknilch Date: Sat, 9 Mar 2013 20:26:02 +0100 Subject: [PATCH] rename "zerotime". Change-Id: Ia6a0172206e38f9ae598bfa90228b6c4657a8747 Signed-off-by: gitknilch --- res/layout/highscore.xml | 24 ++++++------ res/values/strings.xml | 2 +- src/de/cwde/freeshisen/ShisenShoView.java | 47 +++++++++++++++-------- 3 files changed, 43 insertions(+), 30 deletions(-) diff --git a/res/layout/highscore.xml b/res/layout/highscore.xml index 02eaba0..783c98b 100644 --- a/res/layout/highscore.xml +++ b/res/layout/highscore.xml @@ -36,7 +36,7 @@ android:id="@+id/textViewHL1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/zerotime" + android:text="@string/invalidtime" android:textIsSelectable="true" /> @@ -68,7 +68,7 @@ android:id="@+id/textViewHM1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/zerotime" + android:text="@string/invalidtime" android:textIsSelectable="true" /> @@ -100,7 +100,7 @@ android:id="@+id/textViewHS1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/zerotime" + android:text="@string/invalidtime" android:textIsSelectable="true" /> @@ -140,7 +140,7 @@ android:id="@+id/textViewEL1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/zerotime" + android:text="@string/invalidtime" android:textIsSelectable="true" /> @@ -172,7 +172,7 @@ android:id="@+id/textViewEM1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/zerotime" + android:text="@string/invalidtime" android:textIsSelectable="true" /> @@ -204,7 +204,7 @@ android:id="@+id/textViewES1" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:text="@string/zerotime" + android:text="@string/invalidtime" android:textIsSelectable="true" /> diff --git a/res/values/strings.xml b/res/values/strings.xml index 9510be0..d9810cd 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -33,7 +33,7 @@ Get the source code: https://code.google.com/p/freeshisen/ ", 2nd " "Medium: 1st " "Small: 1st " - 00:00:00 + 9:99:99 Really clear best times? This will clear all saved times. Hit "OK" if you really want to do this. diff --git a/src/de/cwde/freeshisen/ShisenShoView.java b/src/de/cwde/freeshisen/ShisenShoView.java index 76d7fc6..2864811 100644 --- a/src/de/cwde/freeshisen/ShisenShoView.java +++ b/src/de/cwde/freeshisen/ShisenShoView.java @@ -1,5 +1,6 @@ package de.cwde.freeshisen; +import java.lang.ref.WeakReference; import java.util.List; import java.util.Locale; import java.util.Timer; @@ -45,17 +46,33 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback { private int tileWidth; private Bitmap bg; private Bitmap tile[]; - private Point selection1 = new Point(0,0); - private Point selection2 = new Point(0,0); - private List path=null; - private List pairs=null; + private Point selection1 = new Point(0, 0); + private Point selection2 = new Point(0, 0); + private List path = null; + private List pairs = null; private long startTime; private long playTime; private long baseTime; private Timer timer; - private static Handler timerHandler; - private boolean timerRegistered=false; + static class hHandler extends Handler { + private final WeakReference mTarget; + + hHandler(ShisenShoView target) { + mTarget = new WeakReference(target); + } + + @Override + public void handleMessage(Message msg) { + ShisenShoView target = mTarget.get(); + if (target != null) + target.onUpdateTime(); + } + } + + private Handler timerHandler = new hHandler(this); + + private boolean timerRegistered = false; private ShisenSho app; private StatePlay cstate; private StatePaint pstate; @@ -132,27 +149,23 @@ class ShisenShoView extends SurfaceView implements SurfaceHolder.Callback { } private void registerTimer() { - if (timer!=null) return; // Already registered - timerHandler = new Handler() { - public void handleMessage(Message msg) { - onUpdateTime(); - } - }; - timer=new Timer(); + if (timer != null) + return; // Already registered + timer = new Timer(); timer.scheduleAtFixedRate(new TimerTask() { public void run() { timerHandler.sendEmptyMessage(Activity.RESULT_OK); } }, 0, 1000); - timerRegistered=true; + timerRegistered = true; } private void unregisterTimer() { - if (timer==null) return; // Already unregistered + if (timer == null) + return; // Already unregistered timer.cancel(); timer = null; - timerHandler = null; - timerRegistered=false; + timerRegistered = false; } public void pauseTime() { -- 2.39.5