am 0d7a1dd8: am 2a75bcf9: am 0c8d8e4c: Moves sample watchface bitmap scaling to onSurfaceChanged().
* commit '0d7a1dd832f3f389bb2b67cfc22c08dea6d07f35':
Moves sample watchface bitmap scaling to onSurfaceChanged().
diff --git a/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/AnalogWatchFaceService.java b/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/AnalogWatchFaceService.java
index 15c550f..16194b1 100644
--- a/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/AnalogWatchFaceService.java
+++ b/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/AnalogWatchFaceService.java
@@ -213,6 +213,17 @@
}
@Override
+ public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ if (mBackgroundScaledBitmap == null
+ || mBackgroundScaledBitmap.getWidth() != width
+ || mBackgroundScaledBitmap.getHeight() != height) {
+ mBackgroundScaledBitmap = Bitmap.createScaledBitmap(mBackgroundBitmap,
+ width, height, true /* filter */);
+ }
+ super.onSurfaceChanged(holder, format, width, height);
+ }
+
+ @Override
public void onDraw(Canvas canvas, Rect bounds) {
mCalendar.setTimeInMillis(System.currentTimeMillis());
@@ -220,12 +231,6 @@
int height = bounds.height();
// Draw the background, scaled to fit.
- if (mBackgroundScaledBitmap == null
- || mBackgroundScaledBitmap.getWidth() != width
- || mBackgroundScaledBitmap.getHeight() != height) {
- mBackgroundScaledBitmap = Bitmap.createScaledBitmap(mBackgroundBitmap,
- width, height, true /* filter */);
- }
canvas.drawBitmap(mBackgroundScaledBitmap, 0, 0, null);
// Find the center. Ignore the window insets so that, on round watches with a
diff --git a/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/SweepWatchFaceService.java b/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/SweepWatchFaceService.java
index 193f29a..d547f1c 100644
--- a/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/SweepWatchFaceService.java
+++ b/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/SweepWatchFaceService.java
@@ -171,6 +171,17 @@
}
@Override
+ public void onSurfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+ if (mBackgroundScaledBitmap == null
+ || mBackgroundScaledBitmap.getWidth() != width
+ || mBackgroundScaledBitmap.getHeight() != height) {
+ mBackgroundScaledBitmap = Bitmap.createScaledBitmap(mBackgroundBitmap,
+ width, height, true /* filter */);
+ }
+ super.onSurfaceChanged(holder, format, width, height);
+ }
+
+ @Override
public void onDraw(Canvas canvas, Rect bounds) {
if (Log.isLoggable(TAG, Log.VERBOSE)) {
Log.v(TAG, "onDraw");
@@ -182,12 +193,6 @@
int height = bounds.height();
// Draw the background, scaled to fit.
- if (mBackgroundScaledBitmap == null
- || mBackgroundScaledBitmap.getWidth() != width
- || mBackgroundScaledBitmap.getHeight() != height) {
- mBackgroundScaledBitmap = Bitmap.createScaledBitmap(mBackgroundBitmap,
- width, height, true /* filter */);
- }
canvas.drawBitmap(mBackgroundScaledBitmap, 0, 0, null);
// Find the center. Ignore the window insets so that, on round watches with a