• 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

修订版b2487598a8abb56463fbb3e58d59d56256dabdd8 (tree)
时间2009-08-30 16:39:01
作者Dianne Hackborn <hackbod@goog...>
CommiterDianne Hackborn

Log Message

A few little fixes to the polar clock.

I was trying to figure out how to get it to fill the screen correctly when in
preview mode, but have no idea. :)

Change-Id: Ia4bb3ea4f4922475a27da0864d6a9d5e284ac37b

更改概述

差异

--- a/src/com/android/wallpaper/polarclock/PolarClockWallpaper.java
+++ b/src/com/android/wallpaper/polarclock/PolarClockWallpaper.java
@@ -30,6 +30,7 @@ import android.content.Context;
3030 import android.os.Handler;
3131 import android.os.SystemClock;
3232 import android.text.format.Time;
33+import android.util.Log;
3334 import android.util.MathUtils;
3435
3536 import java.util.TimeZone;
@@ -80,13 +81,13 @@ public class PolarClockWallpaper extends WallpaperService {
8081 public void onReceive(Context context, Intent intent) {
8182 final String timeZone = intent.getStringExtra("time-zone");
8283 mCalendar = new Time(TimeZone.getTimeZone(timeZone).getID());
83- drawFrame(true);
84+ drawFrame();
8485 }
8586 };
8687
8788 private final Runnable mDrawClock = new Runnable() {
8889 public void run() {
89- drawFrame(true);
90+ drawFrame();
9091 }
9192 };
9293 private boolean mVisible;
@@ -145,13 +146,13 @@ public class PolarClockWallpaper extends WallpaperService {
145146 }
146147 mHandler.removeCallbacks(mDrawClock);
147148 }
148- drawFrame(visible);
149+ drawFrame();
149150 }
150151
151152 @Override
152153 public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
153154 super.onSurfaceChanged(holder, format, width, height);
154- drawFrame(true);
155+ drawFrame();
155156 }
156157
157158 @Override
@@ -162,16 +163,17 @@ public class PolarClockWallpaper extends WallpaperService {
162163 @Override
163164 public void onSurfaceDestroyed(SurfaceHolder holder) {
164165 super.onSurfaceDestroyed(holder);
165- drawFrame(false);
166+ mVisible = false;
167+ mHandler.removeCallbacks(mDrawClock);
166168 }
167169
168170 @Override
169171 public void onOffsetsChanged(float xOffset, float yOffset, int xPixels, int yPixels) {
170172 mOffsetX = xOffset;
171- drawFrame(mVisible);
173+ drawFrame();
172174 }
173175
174- void drawFrame(boolean redraw) {
176+ void drawFrame() {
175177 final SurfaceHolder holder = getSurfaceHolder();
176178 final Rect frame = holder.getSurfaceFrame();
177179 final int width = frame.width();
@@ -204,6 +206,7 @@ public class PolarClockWallpaper extends WallpaperService {
204206 rect.set(-size, -size, size, size);
205207
206208 float angle = ((mStartTime + SystemClock.elapsedRealtime()) % 60000) / 60000.0f;
209+ if (angle < 0) angle = -angle;
207210 paint.setColor(colors[((int) (angle * COLORS_CACHE_COUNT))]);
208211 c.drawArc(rect, 0.0f, angle * 360.0f, false, paint);
209212
@@ -245,7 +248,7 @@ public class PolarClockWallpaper extends WallpaperService {
245248 }
246249
247250 mHandler.removeCallbacks(mDrawClock);
248- if (redraw) {
251+ if (mVisible) {
249252 mHandler.postDelayed(mDrawClock, 1000 / 25);
250253 }
251254 }