131 lines
4.4 KiB
Java
131 lines
4.4 KiB
Java
package com.squareup.picasso;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.Canvas;
|
|
import android.graphics.ColorFilter;
|
|
import android.graphics.Paint;
|
|
import android.graphics.Path;
|
|
import android.graphics.Point;
|
|
import android.graphics.Rect;
|
|
import android.graphics.drawable.AnimationDrawable;
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.os.Build;
|
|
import android.os.SystemClock;
|
|
import android.widget.ImageView;
|
|
import com.squareup.picasso.Picasso;
|
|
|
|
/* loaded from: classes.dex */
|
|
final class PicassoDrawable extends BitmapDrawable {
|
|
private static final Paint h = new Paint();
|
|
private final boolean a;
|
|
private final float b;
|
|
private final Picasso.LoadedFrom c;
|
|
Drawable d;
|
|
long e;
|
|
boolean f;
|
|
int g;
|
|
|
|
PicassoDrawable(Context context, Bitmap bitmap, Drawable drawable, Picasso.LoadedFrom loadedFrom, boolean z, boolean z2) {
|
|
super(context.getResources(), bitmap);
|
|
this.g = 255;
|
|
this.a = z2;
|
|
this.b = context.getResources().getDisplayMetrics().density;
|
|
this.c = loadedFrom;
|
|
if ((loadedFrom == Picasso.LoadedFrom.MEMORY || z) ? false : true) {
|
|
this.d = drawable;
|
|
this.f = true;
|
|
this.e = SystemClock.uptimeMillis();
|
|
}
|
|
}
|
|
|
|
static void a(ImageView imageView, Context context, Bitmap bitmap, Picasso.LoadedFrom loadedFrom, boolean z, boolean z2) {
|
|
Drawable drawable = imageView.getDrawable();
|
|
if (drawable instanceof AnimationDrawable) {
|
|
((AnimationDrawable) drawable).stop();
|
|
}
|
|
imageView.setImageDrawable(new PicassoDrawable(context, bitmap, drawable, loadedFrom, z, z2));
|
|
}
|
|
|
|
@Override // android.graphics.drawable.BitmapDrawable, android.graphics.drawable.Drawable
|
|
public void draw(Canvas canvas) {
|
|
if (this.f) {
|
|
float uptimeMillis = (SystemClock.uptimeMillis() - this.e) / 200.0f;
|
|
if (uptimeMillis >= 1.0f) {
|
|
this.f = false;
|
|
this.d = null;
|
|
super.draw(canvas);
|
|
} else {
|
|
Drawable drawable = this.d;
|
|
if (drawable != null) {
|
|
drawable.draw(canvas);
|
|
}
|
|
super.setAlpha((int) (this.g * uptimeMillis));
|
|
super.draw(canvas);
|
|
super.setAlpha(this.g);
|
|
if (Build.VERSION.SDK_INT <= 10) {
|
|
invalidateSelf();
|
|
}
|
|
}
|
|
} else {
|
|
super.draw(canvas);
|
|
}
|
|
if (this.a) {
|
|
a(canvas);
|
|
}
|
|
}
|
|
|
|
@Override // android.graphics.drawable.BitmapDrawable, android.graphics.drawable.Drawable
|
|
protected void onBoundsChange(Rect rect) {
|
|
Drawable drawable = this.d;
|
|
if (drawable != null) {
|
|
drawable.setBounds(rect);
|
|
}
|
|
super.onBoundsChange(rect);
|
|
}
|
|
|
|
@Override // android.graphics.drawable.BitmapDrawable, android.graphics.drawable.Drawable
|
|
public void setAlpha(int i) {
|
|
this.g = i;
|
|
Drawable drawable = this.d;
|
|
if (drawable != null) {
|
|
drawable.setAlpha(i);
|
|
}
|
|
super.setAlpha(i);
|
|
}
|
|
|
|
@Override // android.graphics.drawable.BitmapDrawable, android.graphics.drawable.Drawable
|
|
public void setColorFilter(ColorFilter colorFilter) {
|
|
Drawable drawable = this.d;
|
|
if (drawable != null) {
|
|
drawable.setColorFilter(colorFilter);
|
|
}
|
|
super.setColorFilter(colorFilter);
|
|
}
|
|
|
|
static void a(ImageView imageView, Drawable drawable) {
|
|
imageView.setImageDrawable(drawable);
|
|
if (imageView.getDrawable() instanceof AnimationDrawable) {
|
|
((AnimationDrawable) imageView.getDrawable()).start();
|
|
}
|
|
}
|
|
|
|
private void a(Canvas canvas) {
|
|
h.setColor(-1);
|
|
canvas.drawPath(a(new Point(0, 0), (int) (this.b * 16.0f)), h);
|
|
h.setColor(this.c.debugColor);
|
|
canvas.drawPath(a(new Point(0, 0), (int) (this.b * 15.0f)), h);
|
|
}
|
|
|
|
private static Path a(Point point, int i) {
|
|
Point point2 = new Point(point.x + i, point.y);
|
|
Point point3 = new Point(point.x, point.y + i);
|
|
Path path = new Path();
|
|
path.moveTo(point.x, point.y);
|
|
path.lineTo(point2.x, point2.y);
|
|
path.lineTo(point3.x, point3.y);
|
|
return path;
|
|
}
|
|
}
|