diff options
| author | Romain Guy <romainguy@google.com> | 2012-11-06 17:35:23 -0800 |
|---|---|---|
| committer | Romain Guy <romainguy@google.com> | 2012-11-06 17:35:23 -0800 |
| commit | a76f7db323598f78512bbbdf2fb89248c9e317e5 (patch) | |
| tree | 12b0ef2d2dc62e5cd94fa522366267ec2750c9db /core/java/android/widget/TextClock.java | |
| parent | 1b3b2544e647a40094b9c9df2c94e34df7921da5 (diff) | |
Respond to ticks when a timezone is set and it doesn't display seconds
Bug #7489774
This change also fixes a crash if you programmatically set the time
formats from code before the widget is attached to the window.
Change-Id: I73ead93f5866d9059a4b3823c4304aeca8e419b6
Diffstat (limited to 'core/java/android/widget/TextClock.java')
| -rw-r--r-- | core/java/android/widget/TextClock.java | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/core/java/android/widget/TextClock.java b/core/java/android/widget/TextClock.java index 908eb0a8fe51..290d9b5b4a52 100644 --- a/core/java/android/widget/TextClock.java +++ b/core/java/android/widget/TextClock.java @@ -135,13 +135,11 @@ public class TextClock extends TextView { private final BroadcastReceiver mIntentReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - if (mTimeZone == null) { - if (intent.getAction().equals(Intent.ACTION_TIMEZONE_CHANGED)) { - final String timeZone = intent.getStringExtra("time-zone"); - createTime(timeZone); - } - onTimeChanged(); + if (mTimeZone == null && Intent.ACTION_TIMEZONE_CHANGED.equals(intent.getAction())) { + final String timeZone = intent.getStringExtra("time-zone"); + createTime(timeZone); } + onTimeChanged(); } }; @@ -406,11 +404,9 @@ public class TextClock extends TextView { boolean hadSeconds = mHasSeconds; mHasSeconds = DateFormat.hasSeconds(mFormat); - if (handleTicker) { - if (hadSeconds != mHasSeconds) { - if (hadSeconds) getHandler().removeCallbacks(mTicker); - else mTicker.run(); - } + if (handleTicker && mAttached && hadSeconds != mHasSeconds) { + if (hadSeconds) getHandler().removeCallbacks(mTicker); + else mTicker.run(); } } |
