summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-09-11 03:05:57 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-09-11 03:05:57 +0000
commitec496ff757e9eb84153ec464efcb867f299f0f9c (patch)
tree96509137ef12cc0dab49cb9770df645b042a56be
parentba8e5584aacceb392a59afa40a542554f618b0d8 (diff)
parentd6b718de5f6bd24410087482a7687bb1fd09536b (diff)
downloadWallpaperPicker2-android-10.0.0_r16.tar.gz
Change-Id: I4c0a245a47b9dd78cda6692727322946f5f5f170
-rwxr-xr-xsrc/com/android/wallpaper/asset/Asset.java25
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 c1d22526..498fad79 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);