• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

packages/wallpapers/Basic


Commit MetaInfo

修订版b8ca9a4b5b8f70306b14d0cd05cbc8e4d1d7e0e5 (tree)
时间2009-08-21 11:39:42
作者Dianne Hackborn <hackbod@goog...>
CommiterDianne Hackborn

Log Message

Fix polar clock to work when showing a preview.

更改概述

差异

--- a/src/com/android/wallpaper/polarclock/PolarClockWallpaper.java
+++ b/src/com/android/wallpaper/polarclock/PolarClockWallpaper.java
@@ -35,16 +35,8 @@ import java.util.TimeZone;
3535
3636 public class PolarClockWallpaper extends WallpaperService {
3737 private final Handler mHandler = new Handler();
38- private final Runnable mDrawClock = new Runnable() {
39- public void run() {
40- mEngine.drawFrame(true);
41- }
42- };
4338
44- private boolean mWatcherRegistered;
45- private TimeWatcher mWatcher;
4639 private IntentFilter mFilter;
47- private ClockEngine mEngine;
4840
4941 @Override
5042 public void onCreate() {
@@ -52,31 +44,15 @@ public class PolarClockWallpaper extends WallpaperService {
5244
5345 mFilter = new IntentFilter();
5446 mFilter.addAction(Intent.ACTION_TIMEZONE_CHANGED);
55-
56- mWatcher = new TimeWatcher();
5747 }
5848
5949 @Override
6050 public void onDestroy() {
6151 super.onDestroy();
62- if (mWatcherRegistered) {
63- mWatcherRegistered = false;
64- unregisterReceiver(mWatcher);
65- }
66- mHandler.removeCallbacks(mDrawClock);
6752 }
6853
6954 public Engine onCreateEngine() {
70- mEngine = new ClockEngine();
71- return mEngine;
72- }
73-
74- class TimeWatcher extends BroadcastReceiver {
75- public void onReceive(Context context, Intent intent) {
76- final String timeZone = intent.getStringExtra("time-zone");
77- mEngine.mCalendar = new Time(TimeZone.getTimeZone(timeZone).getID());
78- mEngine.drawFrame(true);
79- }
55+ return new ClockEngine();
8056 }
8157
8258 class ClockEngine extends Engine {
@@ -89,6 +65,7 @@ public class PolarClockWallpaper extends WallpaperService {
8965
9066 private static final int COLORS_CACHE_COUNT = 720;
9167
68+ private boolean mWatcherRegistered;
9269 private float mStartTime;
9370 private Time mCalendar;
9471
@@ -96,6 +73,20 @@ public class PolarClockWallpaper extends WallpaperService {
9673 private final RectF mRect = new RectF();
9774 private final int[] mColors;
9875
76+ private final BroadcastReceiver mWatcher = new BroadcastReceiver() {
77+ public void onReceive(Context context, Intent intent) {
78+ final String timeZone = intent.getStringExtra("time-zone");
79+ mCalendar = new Time(TimeZone.getTimeZone(timeZone).getID());
80+ drawFrame(true);
81+ }
82+ };
83+
84+ private final Runnable mDrawClock = new Runnable() {
85+ public void run() {
86+ drawFrame(true);
87+ }
88+ };
89+
9990 ClockEngine() {
10091 mColors = new int[COLORS_CACHE_COUNT];
10192
@@ -123,6 +114,16 @@ public class PolarClockWallpaper extends WallpaperService {
123114 }
124115
125116 @Override
117+ public void onDestroy() {
118+ super.onDestroy();
119+ if (mWatcherRegistered) {
120+ mWatcherRegistered = false;
121+ unregisterReceiver(mWatcher);
122+ }
123+ mHandler.removeCallbacks(mDrawClock);
124+ }
125+
126+ @Override
126127 public void onVisibilityChanged(boolean visible) {
127128 if (visible) {
128129 if (!mWatcherRegistered) {