mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-20 03:08:19 +00:00
Smoother second hand for dynamic clock
This commit is contained in:
@@ -17,10 +17,8 @@ public class AutoUpdateClock extends FastBitmapDrawable implements Runnable {
|
||||
}
|
||||
|
||||
private void rescheduleUpdate() {
|
||||
long millisInSecond = 1000L;
|
||||
unscheduleSelf(this);
|
||||
long uptimeMillis = SystemClock.uptimeMillis();
|
||||
scheduleSelf(this, uptimeMillis - uptimeMillis % millisInSecond + millisInSecond);
|
||||
scheduleSelf(this, SystemClock.uptimeMillis() + 100);
|
||||
}
|
||||
|
||||
void updateLayers(ClockLayers layers) {
|
||||
@@ -42,7 +40,6 @@ public class AutoUpdateClock extends FastBitmapDrawable implements Runnable {
|
||||
public void drawInternal(Canvas canvas, Rect bounds) {
|
||||
if (mLayers != null) {
|
||||
canvas.drawBitmap(mLayers.iconBitmap, null, bounds, mPaint);
|
||||
mLayers.updateAngles();
|
||||
canvas.scale(mLayers.scale, mLayers.scale, bounds.exactCenterX() + ((float) mLayers.offset), bounds.exactCenterY() + ((float) mLayers.offset));
|
||||
mLayers.clipToMask(canvas);
|
||||
mLayers.drawForeground(canvas);
|
||||
|
||||
@@ -75,6 +75,7 @@ public class ClockLayers {
|
||||
int hour = (mCurrentTime.get(Calendar.HOUR) + (12 - mDefaultHour)) % 12;
|
||||
int minute = (mCurrentTime.get(Calendar.MINUTE) + (60 - mDefaultMinute)) % 60;
|
||||
int second = (mCurrentTime.get(Calendar.SECOND) + (60 - mDefaultSecond)) % 60;
|
||||
int millis = second * 1000 + mCurrentTime.get(Calendar.MILLISECOND);
|
||||
|
||||
boolean hasChanged = false;
|
||||
if (mHourIndex != -1 && mLayerDrawable.getDrawable(mHourIndex).setLevel(hour * 60 + mCurrentTime.get(Calendar.MINUTE))) {
|
||||
@@ -83,7 +84,7 @@ public class ClockLayers {
|
||||
if (mMinuteIndex != -1 && mLayerDrawable.getDrawable(mMinuteIndex).setLevel(minute + mCurrentTime.get(Calendar.HOUR) * 60)) {
|
||||
hasChanged = true;
|
||||
}
|
||||
if (mSecondIndex != -1 && mLayerDrawable.getDrawable(mSecondIndex).setLevel(second * 10)) {
|
||||
if (mSecondIndex != -1 && mLayerDrawable.getDrawable(mSecondIndex).setLevel(millis / 100)) {
|
||||
hasChanged = true;
|
||||
}
|
||||
return hasChanged;
|
||||
|
||||
Reference in New Issue
Block a user