diff options
| author | Hyunyoung Song <hyunyoungs@google.com> | 2019-08-28 13:40:10 -0700 |
|---|---|---|
| committer | Hyunyoung Song <hyunyoungs@google.com> | 2019-08-28 13:40:10 -0700 |
| commit | d6b718de5f6bd24410087482a7687bb1fd09536b (patch) | |
| tree | 96509137ef12cc0dab49cb9770df645b042a56be | |
| parent | 1ff5eb1b5bd6532e6f6899e6e4905ed2df6e48e3 (diff) | |
| parent | 0ac7580a4c902520aa6f533a99fc84f160cd795b (diff) | |
| download | android_packages_apps_WallpaperPicker2-d6b718de5f6bd24410087482a7687bb1fd09536b.tar.gz android_packages_apps_WallpaperPicker2-d6b718de5f6bd24410087482a7687bb1fd09536b.tar.bz2 android_packages_apps_WallpaperPicker2-d6b718de5f6bd24410087482a7687bb1fd09536b.zip | |
Merging from ub-launcher3-qt-qpr1-dev @ build 5834630
Test: manual, presubmit on the source branch
http://x20/teams/android-sysui/merge/ub-launcher3-qt-qpr1-dev_5834630.html
Change-Id: I42b66c2a98866ee234d1f573c74e84509239e40d
| -rwxr-xr-x | src/com/android/wallpaper/asset/Asset.java | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/com/android/wallpaper/asset/Asset.java b/src/com/android/wallpaper/asset/Asset.java index c1d2252..498fad7 100755 --- a/src/com/android/wallpaper/asset/Asset.java +++ b/src/com/android/wallpaper/asset/Asset.java @@ -27,6 +27,7 @@ import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; import android.graphics.drawable.TransitionDrawable; import android.os.AsyncTask; +import android.view.View; import android.widget.ImageView; import androidx.annotation.Nullable; @@ -44,7 +45,7 @@ public abstract class Asset { */ protected static Drawable getPlaceholderDrawable( Context context, ImageView imageView, int placeholderColor) { - Point imageViewDimensions = getImageViewDimensions(imageView); + Point imageViewDimensions = getViewDimensions(imageView); Bitmap placeholderBitmap = Bitmap.createBitmap(imageViewDimensions.x, imageViewDimensions.y, Config.ARGB_8888); placeholderBitmap.eraseColor(placeholderColor); @@ -55,13 +56,10 @@ public abstract class Asset { * Returns the visible height and width in pixels of the provided ImageView, or if it hasn't been * laid out yet, then gets the absolute value of the layout params. */ - private static Point getImageViewDimensions(ImageView imageView) { - int width = imageView.getWidth() > 0 - ? imageView.getWidth() - : Math.abs(imageView.getLayoutParams().width); - int height = imageView.getHeight() > 0 - ? imageView.getHeight() - : Math.abs(imageView.getLayoutParams().height); + private static Point getViewDimensions(View view) { + int width = view.getWidth() > 0 ? view.getWidth() : Math.abs(view.getLayoutParams().width); + int height = view.getHeight() > 0 ? view.getHeight() + : Math.abs(view.getLayoutParams().height); return new Point(width, height); } @@ -191,7 +189,7 @@ public abstract class Asset { final int transitionDurationMillis, @Nullable final DrawableLoadedListener drawableLoadedListener, int placeholderColor) { - Point imageViewDimensions = getImageViewDimensions(imageView); + Point imageViewDimensions = getViewDimensions(imageView); // Transition from a placeholder ColorDrawable to the decoded bitmap when the ImageView in // question is empty. @@ -275,7 +273,7 @@ public abstract class Asset { * Custom AsyncTask which returns a copy of the given bitmap which is center cropped and scaled to * fit in the given ImageView. */ - protected static class CenterCropBitmapTask extends AsyncTask<Void, Void, Bitmap> { + public static class CenterCropBitmapTask extends AsyncTask<Void, Void, Bitmap> { private Bitmap mBitmap; private BitmapReceiver mBitmapReceiver; @@ -283,12 +281,12 @@ public abstract class Asset { private int mImageViewWidth; private int mImageViewHeight; - public CenterCropBitmapTask(Bitmap bitmap, ImageView imageView, + public CenterCropBitmapTask(Bitmap bitmap, View view, BitmapReceiver bitmapReceiver) { mBitmap = bitmap; mBitmapReceiver = bitmapReceiver; - Point imageViewDimensions = getImageViewDimensions(imageView); + Point imageViewDimensions = getViewDimensions(view); mImageViewWidth = imageViewDimensions.x; mImageViewHeight = imageViewDimensions.y; @@ -307,7 +305,8 @@ public abstract class Asset { (float) bitmapHeight / measuredHeight); Bitmap scaledBitmap = Bitmap.createScaledBitmap( - mBitmap, Math.round(bitmapWidth / scale), Math.round(bitmapHeight / scale), true); + mBitmap, Math.round(bitmapWidth / scale), Math.round(bitmapHeight / scale), + true); int horizontalGutterPx = Math.max(0, (scaledBitmap.getWidth() - measuredWidth) / 2); int verticalGutterPx = Math.max(0, (scaledBitmap.getHeight() - measuredHeight) / 2); |
