193 lines
6.0 KiB
Java
193 lines
6.0 KiB
Java
package com.squareup.picasso;
|
|
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.net.Uri;
|
|
import android.widget.ImageView;
|
|
import com.squareup.picasso.Picasso;
|
|
import com.squareup.picasso.Request;
|
|
import com.ubt.jimu.base.entities.Course;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class RequestCreator {
|
|
private static final AtomicInteger m = new AtomicInteger();
|
|
private final Picasso a;
|
|
private final Request.Builder b;
|
|
private boolean c;
|
|
private boolean d;
|
|
private boolean e = true;
|
|
private int f;
|
|
private int g;
|
|
private int h;
|
|
private int i;
|
|
private Drawable j;
|
|
private Drawable k;
|
|
private Object l;
|
|
|
|
RequestCreator(Picasso picasso, Uri uri, int i) {
|
|
if (picasso.o) {
|
|
throw new IllegalStateException("Picasso instance already shut down. Cannot submit new requests.");
|
|
}
|
|
this.a = picasso;
|
|
this.b = new Request.Builder(uri, i, picasso.l);
|
|
}
|
|
|
|
private Drawable d() {
|
|
return this.f != 0 ? this.a.e.getResources().getDrawable(this.f) : this.j;
|
|
}
|
|
|
|
public RequestCreator a(Drawable drawable) {
|
|
if (!this.e) {
|
|
throw new IllegalStateException("Already explicitly declared as no placeholder.");
|
|
}
|
|
if (this.f != 0) {
|
|
throw new IllegalStateException("Placeholder image already set.");
|
|
}
|
|
this.j = drawable;
|
|
return this;
|
|
}
|
|
|
|
public RequestCreator b() {
|
|
this.d = true;
|
|
return this;
|
|
}
|
|
|
|
RequestCreator c() {
|
|
this.d = false;
|
|
return this;
|
|
}
|
|
|
|
public RequestCreator a(int i) {
|
|
if (i != 0) {
|
|
if (this.k == null) {
|
|
this.g = i;
|
|
return this;
|
|
}
|
|
throw new IllegalStateException("Error image already set.");
|
|
}
|
|
throw new IllegalArgumentException("Error image resource invalid.");
|
|
}
|
|
|
|
public RequestCreator a(int i, int i2) {
|
|
this.b.a(i, i2);
|
|
return this;
|
|
}
|
|
|
|
public RequestCreator a() {
|
|
this.b.b();
|
|
return this;
|
|
}
|
|
|
|
public RequestCreator a(Transformation transformation) {
|
|
this.b.a(transformation);
|
|
return this;
|
|
}
|
|
|
|
public void a(Target target) {
|
|
Bitmap b;
|
|
long nanoTime = System.nanoTime();
|
|
Utils.a();
|
|
if (target != null) {
|
|
if (!this.d) {
|
|
if (!this.b.c()) {
|
|
this.a.a(target);
|
|
target.b(this.e ? d() : null);
|
|
return;
|
|
}
|
|
Request a = a(nanoTime);
|
|
String a2 = Utils.a(a);
|
|
if (MemoryPolicy.shouldReadFromMemoryCache(this.h) && (b = this.a.b(a2)) != null) {
|
|
this.a.a(target);
|
|
target.a(b, Picasso.LoadedFrom.MEMORY);
|
|
return;
|
|
} else {
|
|
target.b(this.e ? d() : null);
|
|
this.a.a((Action) new TargetAction(this.a, target, a, this.h, this.i, this.k, a2, this.l, this.g));
|
|
return;
|
|
}
|
|
}
|
|
throw new IllegalStateException("Fit cannot be used with a Target.");
|
|
}
|
|
throw new IllegalArgumentException("Target must not be null.");
|
|
}
|
|
|
|
public void a(ImageView imageView) {
|
|
a(imageView, (Callback) null);
|
|
}
|
|
|
|
public void a(ImageView imageView, Callback callback) {
|
|
Bitmap b;
|
|
long nanoTime = System.nanoTime();
|
|
Utils.a();
|
|
if (imageView != null) {
|
|
if (!this.b.c()) {
|
|
this.a.a(imageView);
|
|
if (this.e) {
|
|
PicassoDrawable.a(imageView, d());
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (this.d) {
|
|
if (!this.b.d()) {
|
|
int width = imageView.getWidth();
|
|
int height = imageView.getHeight();
|
|
if (width != 0 && height != 0) {
|
|
this.b.a(width, height);
|
|
} else {
|
|
if (this.e) {
|
|
PicassoDrawable.a(imageView, d());
|
|
}
|
|
this.a.a(imageView, new DeferredRequestCreator(this, imageView, callback));
|
|
return;
|
|
}
|
|
} else {
|
|
throw new IllegalStateException("Fit cannot be used with resize.");
|
|
}
|
|
}
|
|
Request a = a(nanoTime);
|
|
String a2 = Utils.a(a);
|
|
if (MemoryPolicy.shouldReadFromMemoryCache(this.h) && (b = this.a.b(a2)) != null) {
|
|
this.a.a(imageView);
|
|
Picasso picasso = this.a;
|
|
PicassoDrawable.a(imageView, picasso.e, b, Picasso.LoadedFrom.MEMORY, this.c, picasso.m);
|
|
if (this.a.n) {
|
|
Utils.a("Main", Course.STATUS_COMPLETED, a.g(), "from " + Picasso.LoadedFrom.MEMORY);
|
|
}
|
|
if (callback != null) {
|
|
callback.onSuccess();
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
if (this.e) {
|
|
PicassoDrawable.a(imageView, d());
|
|
}
|
|
this.a.a((Action) new ImageViewAction(this.a, imageView, a, this.h, this.i, this.g, this.k, a2, this.l, callback, this.c));
|
|
return;
|
|
}
|
|
throw new IllegalArgumentException("Target must not be null.");
|
|
}
|
|
|
|
private Request a(long j) {
|
|
int andIncrement = m.getAndIncrement();
|
|
Request a = this.b.a();
|
|
a.a = andIncrement;
|
|
a.b = j;
|
|
boolean z = this.a.n;
|
|
if (z) {
|
|
Utils.a("Main", "created", a.g(), a.toString());
|
|
}
|
|
this.a.a(a);
|
|
if (a != a) {
|
|
a.a = andIncrement;
|
|
a.b = j;
|
|
if (z) {
|
|
Utils.a("Main", "changed", a.d(), "into " + a);
|
|
}
|
|
}
|
|
return a;
|
|
}
|
|
}
|