Initial commit
This commit is contained in:
97
sources/com/squareup/picasso/Action.java
Normal file
97
sources/com/squareup/picasso/Action.java
Normal file
@@ -0,0 +1,97 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
abstract class Action<T> {
|
||||
final Picasso a;
|
||||
final Request b;
|
||||
final WeakReference<T> c;
|
||||
final boolean d;
|
||||
final int e;
|
||||
final int f;
|
||||
final int g;
|
||||
final Drawable h;
|
||||
final String i;
|
||||
final Object j;
|
||||
boolean k;
|
||||
boolean l;
|
||||
|
||||
static class RequestWeakReference<M> extends WeakReference<M> {
|
||||
final Action a;
|
||||
|
||||
public RequestWeakReference(Action action, M m, ReferenceQueue<? super M> referenceQueue) {
|
||||
super(m, referenceQueue);
|
||||
this.a = action;
|
||||
}
|
||||
}
|
||||
|
||||
Action(Picasso picasso, T t, Request request, int i, int i2, int i3, Drawable drawable, String str, Object obj, boolean z) {
|
||||
this.a = picasso;
|
||||
this.b = request;
|
||||
this.c = t == null ? null : new RequestWeakReference(this, t, picasso.k);
|
||||
this.e = i;
|
||||
this.f = i2;
|
||||
this.d = z;
|
||||
this.g = i3;
|
||||
this.h = drawable;
|
||||
this.i = str;
|
||||
this.j = obj == null ? this : obj;
|
||||
}
|
||||
|
||||
void a() {
|
||||
this.l = true;
|
||||
}
|
||||
|
||||
abstract void a(Bitmap bitmap, Picasso.LoadedFrom loadedFrom);
|
||||
|
||||
abstract void b();
|
||||
|
||||
String c() {
|
||||
return this.i;
|
||||
}
|
||||
|
||||
int d() {
|
||||
return this.e;
|
||||
}
|
||||
|
||||
int e() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
Picasso f() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
Picasso.Priority g() {
|
||||
return this.b.r;
|
||||
}
|
||||
|
||||
Request h() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
Object i() {
|
||||
return this.j;
|
||||
}
|
||||
|
||||
T j() {
|
||||
WeakReference<T> weakReference = this.c;
|
||||
if (weakReference == null) {
|
||||
return null;
|
||||
}
|
||||
return weakReference.get();
|
||||
}
|
||||
|
||||
boolean k() {
|
||||
return this.l;
|
||||
}
|
||||
|
||||
boolean l() {
|
||||
return this.k;
|
||||
}
|
||||
}
|
33
sources/com/squareup/picasso/AssetRequestHandler.java
Normal file
33
sources/com/squareup/picasso/AssetRequestHandler.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.net.Uri;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestHandler;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class AssetRequestHandler extends RequestHandler {
|
||||
private static final int b = 22;
|
||||
private final AssetManager a;
|
||||
|
||||
public AssetRequestHandler(Context context) {
|
||||
this.a = context.getAssets();
|
||||
}
|
||||
|
||||
static String c(Request request) {
|
||||
return request.d.toString().substring(b);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public boolean a(Request request) {
|
||||
Uri uri = request.d;
|
||||
return "file".equals(uri.getScheme()) && !uri.getPathSegments().isEmpty() && "android_asset".equals(uri.getPathSegments().get(0));
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public RequestHandler.Result a(Request request, int i) throws IOException {
|
||||
return new RequestHandler.Result(this.a.open(c(request)), Picasso.LoadedFrom.DISK);
|
||||
}
|
||||
}
|
445
sources/com/squareup/picasso/BitmapHunter.java
Normal file
445
sources/com/squareup/picasso/BitmapHunter.java
Normal file
@@ -0,0 +1,445 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.NetworkInfo;
|
||||
import com.squareup.picasso.Downloader;
|
||||
import com.squareup.picasso.NetworkRequestHandler;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestHandler;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class BitmapHunter implements Runnable {
|
||||
private static final Object t = new Object();
|
||||
private static final ThreadLocal<StringBuilder> u = new ThreadLocal<StringBuilder>() { // from class: com.squareup.picasso.BitmapHunter.1
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // java.lang.ThreadLocal
|
||||
public StringBuilder initialValue() {
|
||||
return new StringBuilder("Picasso-");
|
||||
}
|
||||
};
|
||||
private static final AtomicInteger v = new AtomicInteger();
|
||||
private static final RequestHandler x = new RequestHandler() { // from class: com.squareup.picasso.BitmapHunter.2
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public RequestHandler.Result a(Request request, int i) throws IOException {
|
||||
throw new IllegalStateException("Unrecognized type of request: " + request);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public boolean a(Request request) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
final int a = v.incrementAndGet();
|
||||
final Picasso b;
|
||||
final Dispatcher c;
|
||||
final Cache d;
|
||||
final Stats e;
|
||||
final String f;
|
||||
final Request g;
|
||||
final int h;
|
||||
int i;
|
||||
final RequestHandler j;
|
||||
Action k;
|
||||
List<Action> l;
|
||||
Bitmap m;
|
||||
Future<?> n;
|
||||
Picasso.LoadedFrom o;
|
||||
Exception p;
|
||||
int q;
|
||||
int r;
|
||||
Picasso.Priority s;
|
||||
|
||||
BitmapHunter(Picasso picasso, Dispatcher dispatcher, Cache cache, Stats stats, Action action, RequestHandler requestHandler) {
|
||||
this.b = picasso;
|
||||
this.c = dispatcher;
|
||||
this.d = cache;
|
||||
this.e = stats;
|
||||
this.k = action;
|
||||
this.f = action.c();
|
||||
this.g = action.h();
|
||||
this.s = action.g();
|
||||
this.h = action.d();
|
||||
this.i = action.e();
|
||||
this.j = requestHandler;
|
||||
this.r = requestHandler.a();
|
||||
}
|
||||
|
||||
static Bitmap a(InputStream inputStream, Request request) throws IOException {
|
||||
MarkableInputStream markableInputStream = new MarkableInputStream(inputStream);
|
||||
long a = markableInputStream.a(65536);
|
||||
BitmapFactory.Options b = RequestHandler.b(request);
|
||||
boolean a2 = RequestHandler.a(b);
|
||||
boolean b2 = Utils.b(markableInputStream);
|
||||
markableInputStream.a(a);
|
||||
if (b2) {
|
||||
byte[] c = Utils.c(markableInputStream);
|
||||
if (a2) {
|
||||
BitmapFactory.decodeByteArray(c, 0, c.length, b);
|
||||
RequestHandler.a(request.h, request.i, b, request);
|
||||
}
|
||||
return BitmapFactory.decodeByteArray(c, 0, c.length, b);
|
||||
}
|
||||
if (a2) {
|
||||
BitmapFactory.decodeStream(markableInputStream, null, b);
|
||||
RequestHandler.a(request.h, request.i, b, request);
|
||||
markableInputStream.a(a);
|
||||
}
|
||||
Bitmap decodeStream = BitmapFactory.decodeStream(markableInputStream, null, b);
|
||||
if (decodeStream != null) {
|
||||
return decodeStream;
|
||||
}
|
||||
throw new IOException("Failed to decode stream.");
|
||||
}
|
||||
|
||||
private static boolean a(boolean z, int i, int i2, int i3, int i4) {
|
||||
return !z || i > i3 || i2 > i4;
|
||||
}
|
||||
|
||||
private Picasso.Priority q() {
|
||||
Picasso.Priority priority = Picasso.Priority.LOW;
|
||||
List<Action> list = this.l;
|
||||
boolean z = true;
|
||||
boolean z2 = (list == null || list.isEmpty()) ? false : true;
|
||||
if (this.k == null && !z2) {
|
||||
z = false;
|
||||
}
|
||||
if (!z) {
|
||||
return priority;
|
||||
}
|
||||
Action action = this.k;
|
||||
if (action != null) {
|
||||
priority = action.g();
|
||||
}
|
||||
if (z2) {
|
||||
int size = this.l.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
Picasso.Priority g = this.l.get(i).g();
|
||||
if (g.ordinal() > priority.ordinal()) {
|
||||
priority = g;
|
||||
}
|
||||
}
|
||||
}
|
||||
return priority;
|
||||
}
|
||||
|
||||
void b(Action action) {
|
||||
boolean remove;
|
||||
if (this.k == action) {
|
||||
this.k = null;
|
||||
remove = true;
|
||||
} else {
|
||||
List<Action> list = this.l;
|
||||
remove = list != null ? list.remove(action) : false;
|
||||
}
|
||||
if (remove && action.g() == this.s) {
|
||||
this.s = q();
|
||||
}
|
||||
if (this.b.n) {
|
||||
Utils.a("Hunter", "removed", action.b.d(), Utils.a(this, "from "));
|
||||
}
|
||||
}
|
||||
|
||||
Request c() {
|
||||
return this.g;
|
||||
}
|
||||
|
||||
boolean cancel() {
|
||||
Future<?> future;
|
||||
if (this.k != null) {
|
||||
return false;
|
||||
}
|
||||
List<Action> list = this.l;
|
||||
return (list == null || list.isEmpty()) && (future = this.n) != null && future.cancel(false);
|
||||
}
|
||||
|
||||
Exception d() {
|
||||
return this.p;
|
||||
}
|
||||
|
||||
String e() {
|
||||
return this.f;
|
||||
}
|
||||
|
||||
Picasso.LoadedFrom f() {
|
||||
return this.o;
|
||||
}
|
||||
|
||||
int j() {
|
||||
return this.h;
|
||||
}
|
||||
|
||||
Picasso k() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
Picasso.Priority l() {
|
||||
return this.s;
|
||||
}
|
||||
|
||||
Bitmap m() {
|
||||
return this.m;
|
||||
}
|
||||
|
||||
Bitmap n() throws IOException {
|
||||
Bitmap bitmap;
|
||||
if (MemoryPolicy.shouldReadFromMemoryCache(this.h)) {
|
||||
bitmap = this.d.get(this.f);
|
||||
if (bitmap != null) {
|
||||
this.e.b();
|
||||
this.o = Picasso.LoadedFrom.MEMORY;
|
||||
if (this.b.n) {
|
||||
Utils.a("Hunter", "decoded", this.g.d(), "from cache");
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
} else {
|
||||
bitmap = null;
|
||||
}
|
||||
this.g.c = this.r == 0 ? NetworkPolicy.OFFLINE.index : this.i;
|
||||
RequestHandler.Result a = this.j.a(this.g, this.i);
|
||||
if (a != null) {
|
||||
this.o = a.c();
|
||||
this.q = a.b();
|
||||
bitmap = a.a();
|
||||
if (bitmap == null) {
|
||||
InputStream d = a.d();
|
||||
try {
|
||||
Bitmap a2 = a(d, this.g);
|
||||
Utils.a(d);
|
||||
bitmap = a2;
|
||||
} catch (Throwable th) {
|
||||
Utils.a(d);
|
||||
throw th;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bitmap != null) {
|
||||
if (this.b.n) {
|
||||
Utils.a("Hunter", "decoded", this.g.d());
|
||||
}
|
||||
this.e.a(bitmap);
|
||||
if (this.g.f() || this.q != 0) {
|
||||
synchronized (t) {
|
||||
if (this.g.e() || this.q != 0) {
|
||||
bitmap = a(this.g, bitmap, this.q);
|
||||
if (this.b.n) {
|
||||
Utils.a("Hunter", "transformed", this.g.d());
|
||||
}
|
||||
}
|
||||
if (this.g.b()) {
|
||||
bitmap = a(this.g.g, bitmap);
|
||||
if (this.b.n) {
|
||||
Utils.a("Hunter", "transformed", this.g.d(), "from custom transformations");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (bitmap != null) {
|
||||
this.e.b(bitmap);
|
||||
}
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
boolean o() {
|
||||
Future<?> future = this.n;
|
||||
return future != null && future.isCancelled();
|
||||
}
|
||||
|
||||
boolean p() {
|
||||
return this.j.b();
|
||||
}
|
||||
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
try {
|
||||
try {
|
||||
try {
|
||||
a(this.g);
|
||||
if (this.b.n) {
|
||||
Utils.a("Hunter", "executing", Utils.a(this));
|
||||
}
|
||||
this.m = n();
|
||||
if (this.m == null) {
|
||||
this.c.b(this);
|
||||
} else {
|
||||
this.c.a(this);
|
||||
}
|
||||
} catch (Downloader.ResponseException e) {
|
||||
if (!e.localCacheOnly || e.responseCode != 504) {
|
||||
this.p = e;
|
||||
}
|
||||
this.c.b(this);
|
||||
} catch (IOException e2) {
|
||||
this.p = e2;
|
||||
this.c.c(this);
|
||||
} catch (Exception e3) {
|
||||
this.p = e3;
|
||||
this.c.b(this);
|
||||
}
|
||||
} catch (NetworkRequestHandler.ContentLengthException e4) {
|
||||
this.p = e4;
|
||||
this.c.c(this);
|
||||
} catch (OutOfMemoryError e5) {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
this.e.a().a(new PrintWriter(stringWriter));
|
||||
this.p = new RuntimeException(stringWriter.toString(), e5);
|
||||
this.c.b(this);
|
||||
}
|
||||
} finally {
|
||||
Thread.currentThread().setName("Picasso-Idle");
|
||||
}
|
||||
}
|
||||
|
||||
List<Action> b() {
|
||||
return this.l;
|
||||
}
|
||||
|
||||
void a(Action action) {
|
||||
boolean z = this.b.n;
|
||||
Request request = action.b;
|
||||
if (this.k == null) {
|
||||
this.k = action;
|
||||
if (z) {
|
||||
List<Action> list = this.l;
|
||||
if (list != null && !list.isEmpty()) {
|
||||
Utils.a("Hunter", "joined", request.d(), Utils.a(this, "to "));
|
||||
return;
|
||||
} else {
|
||||
Utils.a("Hunter", "joined", request.d(), "to empty hunter");
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.l == null) {
|
||||
this.l = new ArrayList(3);
|
||||
}
|
||||
this.l.add(action);
|
||||
if (z) {
|
||||
Utils.a("Hunter", "joined", request.d(), Utils.a(this, "to "));
|
||||
}
|
||||
Picasso.Priority g = action.g();
|
||||
if (g.ordinal() > this.s.ordinal()) {
|
||||
this.s = g;
|
||||
}
|
||||
}
|
||||
|
||||
boolean a(boolean z, NetworkInfo networkInfo) {
|
||||
if (!(this.r > 0)) {
|
||||
return false;
|
||||
}
|
||||
this.r--;
|
||||
return this.j.a(z, networkInfo);
|
||||
}
|
||||
|
||||
Action a() {
|
||||
return this.k;
|
||||
}
|
||||
|
||||
static void a(Request request) {
|
||||
String a = request.a();
|
||||
StringBuilder sb = u.get();
|
||||
sb.ensureCapacity(a.length() + 8);
|
||||
sb.replace(8, sb.length(), a);
|
||||
Thread.currentThread().setName(sb.toString());
|
||||
}
|
||||
|
||||
static BitmapHunter a(Picasso picasso, Dispatcher dispatcher, Cache cache, Stats stats, Action action) {
|
||||
Request h = action.h();
|
||||
List<RequestHandler> a = picasso.a();
|
||||
int size = a.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
RequestHandler requestHandler = a.get(i);
|
||||
if (requestHandler.a(h)) {
|
||||
return new BitmapHunter(picasso, dispatcher, cache, stats, action, requestHandler);
|
||||
}
|
||||
}
|
||||
return new BitmapHunter(picasso, dispatcher, cache, stats, action, x);
|
||||
}
|
||||
|
||||
static Bitmap a(List<Transformation> list, Bitmap bitmap) {
|
||||
int size = list.size();
|
||||
int i = 0;
|
||||
while (i < size) {
|
||||
final Transformation transformation = list.get(i);
|
||||
try {
|
||||
Bitmap a = transformation.a(bitmap);
|
||||
if (a == null) {
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("Transformation ");
|
||||
sb.append(transformation.a());
|
||||
sb.append(" returned null after ");
|
||||
sb.append(i);
|
||||
sb.append(" previous transformation(s).\n\nTransformation list:\n");
|
||||
Iterator<Transformation> it = list.iterator();
|
||||
while (it.hasNext()) {
|
||||
sb.append(it.next().a());
|
||||
sb.append('\n');
|
||||
}
|
||||
Picasso.p.post(new Runnable() { // from class: com.squareup.picasso.BitmapHunter.4
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
throw new NullPointerException(sb.toString());
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
if (a == bitmap && bitmap.isRecycled()) {
|
||||
Picasso.p.post(new Runnable() { // from class: com.squareup.picasso.BitmapHunter.5
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
throw new IllegalStateException("Transformation " + Transformation.this.a() + " returned input Bitmap but recycled it.");
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
if (a != bitmap && !bitmap.isRecycled()) {
|
||||
Picasso.p.post(new Runnable() { // from class: com.squareup.picasso.BitmapHunter.6
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
throw new IllegalStateException("Transformation " + Transformation.this.a() + " mutated input Bitmap but failed to recycle the original.");
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
i++;
|
||||
bitmap = a;
|
||||
} catch (RuntimeException e) {
|
||||
Picasso.p.post(new Runnable() { // from class: com.squareup.picasso.BitmapHunter.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
throw new RuntimeException("Transformation " + Transformation.this.a() + " crashed with exception.", e);
|
||||
}
|
||||
});
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/* JADX WARN: Removed duplicated region for block: B:19:0x00b4 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:22:0x00c0 */
|
||||
/* JADX WARN: Removed duplicated region for block: B:25:0x00c4 */
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
static android.graphics.Bitmap a(com.squareup.picasso.Request r13, android.graphics.Bitmap r14, int r15) {
|
||||
/*
|
||||
Method dump skipped, instructions count: 198
|
||||
To view this dump change 'Code comments level' option to 'DEBUG'
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.squareup.picasso.BitmapHunter.a(com.squareup.picasso.Request, android.graphics.Bitmap, int):android.graphics.Bitmap");
|
||||
}
|
||||
}
|
37
sources/com/squareup/picasso/Cache.java
Normal file
37
sources/com/squareup/picasso/Cache.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Cache {
|
||||
static {
|
||||
new Cache() { // from class: com.squareup.picasso.Cache.1
|
||||
@Override // com.squareup.picasso.Cache
|
||||
public int a() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Cache
|
||||
public void a(String str, Bitmap bitmap) {
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Cache
|
||||
public Bitmap get(String str) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Cache
|
||||
public int size() {
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
int a();
|
||||
|
||||
void a(String str, Bitmap bitmap);
|
||||
|
||||
Bitmap get(String str);
|
||||
|
||||
int size();
|
||||
}
|
8
sources/com/squareup/picasso/Callback.java
Normal file
8
sources/com/squareup/picasso/Callback.java
Normal file
@@ -0,0 +1,8 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Callback {
|
||||
void onError();
|
||||
|
||||
void onSuccess();
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.UriMatcher;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.provider.ContactsContract;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestHandler;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ContactsPhotoRequestHandler extends RequestHandler {
|
||||
private static final UriMatcher b = new UriMatcher(-1);
|
||||
private final Context a;
|
||||
|
||||
@TargetApi(14)
|
||||
private static class ContactPhotoStreamIcs {
|
||||
static InputStream a(ContentResolver contentResolver, Uri uri) {
|
||||
return ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri, true);
|
||||
}
|
||||
}
|
||||
|
||||
static {
|
||||
b.addURI("com.android.contacts", "contacts/lookup/*/#", 1);
|
||||
b.addURI("com.android.contacts", "contacts/lookup/*", 1);
|
||||
b.addURI("com.android.contacts", "contacts/#/photo", 2);
|
||||
b.addURI("com.android.contacts", "contacts/#", 3);
|
||||
b.addURI("com.android.contacts", "display_photo/#", 4);
|
||||
}
|
||||
|
||||
ContactsPhotoRequestHandler(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
private InputStream c(Request request) throws IOException {
|
||||
ContentResolver contentResolver = this.a.getContentResolver();
|
||||
Uri uri = request.d;
|
||||
int match = b.match(uri);
|
||||
if (match != 1) {
|
||||
if (match != 2) {
|
||||
if (match != 3) {
|
||||
if (match != 4) {
|
||||
throw new IllegalStateException("Invalid uri: " + uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
return contentResolver.openInputStream(uri);
|
||||
}
|
||||
uri = ContactsContract.Contacts.lookupContact(contentResolver, uri);
|
||||
if (uri == null) {
|
||||
return null;
|
||||
}
|
||||
return Build.VERSION.SDK_INT < 14 ? ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri) : ContactPhotoStreamIcs.a(contentResolver, uri);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public boolean a(Request request) {
|
||||
Uri uri = request.d;
|
||||
return "content".equals(uri.getScheme()) && ContactsContract.Contacts.CONTENT_URI.getHost().equals(uri.getHost()) && b.match(request.d) != -1;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public RequestHandler.Result a(Request request, int i) throws IOException {
|
||||
InputStream c = c(request);
|
||||
if (c != null) {
|
||||
return new RequestHandler.Result(c, Picasso.LoadedFrom.DISK);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.content.Context;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestHandler;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ContentStreamRequestHandler extends RequestHandler {
|
||||
final Context a;
|
||||
|
||||
ContentStreamRequestHandler(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public boolean a(Request request) {
|
||||
return "content".equals(request.d.getScheme());
|
||||
}
|
||||
|
||||
InputStream c(Request request) throws FileNotFoundException {
|
||||
return this.a.getContentResolver().openInputStream(request.d);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public RequestHandler.Result a(Request request, int i) throws IOException {
|
||||
return new RequestHandler.Result(c(request), Picasso.LoadedFrom.DISK);
|
||||
}
|
||||
}
|
53
sources/com/squareup/picasso/DeferredRequestCreator.java
Normal file
53
sources/com/squareup/picasso/DeferredRequestCreator.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.ImageView;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class DeferredRequestCreator implements ViewTreeObserver.OnPreDrawListener {
|
||||
final RequestCreator a;
|
||||
final WeakReference<ImageView> b;
|
||||
Callback c;
|
||||
|
||||
DeferredRequestCreator(RequestCreator requestCreator, ImageView imageView, Callback callback) {
|
||||
this.a = requestCreator;
|
||||
this.b = new WeakReference<>(imageView);
|
||||
this.c = callback;
|
||||
imageView.getViewTreeObserver().addOnPreDrawListener(this);
|
||||
}
|
||||
|
||||
void a() {
|
||||
this.c = null;
|
||||
ImageView imageView = this.b.get();
|
||||
if (imageView == null) {
|
||||
return;
|
||||
}
|
||||
ViewTreeObserver viewTreeObserver = imageView.getViewTreeObserver();
|
||||
if (viewTreeObserver.isAlive()) {
|
||||
viewTreeObserver.removeOnPreDrawListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.ViewTreeObserver.OnPreDrawListener
|
||||
public boolean onPreDraw() {
|
||||
ImageView imageView = this.b.get();
|
||||
if (imageView == null) {
|
||||
return true;
|
||||
}
|
||||
ViewTreeObserver viewTreeObserver = imageView.getViewTreeObserver();
|
||||
if (!viewTreeObserver.isAlive()) {
|
||||
return true;
|
||||
}
|
||||
int width = imageView.getWidth();
|
||||
int height = imageView.getHeight();
|
||||
if (width > 0 && height > 0) {
|
||||
viewTreeObserver.removeOnPreDrawListener(this);
|
||||
RequestCreator requestCreator = this.a;
|
||||
requestCreator.c();
|
||||
requestCreator.a(width, height);
|
||||
requestCreator.a(imageView, this.c);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
462
sources/com/squareup/picasso/Dispatcher.java
Normal file
462
sources/com/squareup/picasso/Dispatcher.java
Normal file
@@ -0,0 +1,462 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import com.squareup.picasso.NetworkRequestHandler;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class Dispatcher {
|
||||
final DispatcherThread a = new DispatcherThread();
|
||||
final Context b;
|
||||
final ExecutorService c;
|
||||
final Downloader d;
|
||||
final Map<String, BitmapHunter> e;
|
||||
final Map<Object, Action> f;
|
||||
final Map<Object, Action> g;
|
||||
final Set<Object> h;
|
||||
final Handler i;
|
||||
final Handler j;
|
||||
final Cache k;
|
||||
final Stats l;
|
||||
final List<BitmapHunter> m;
|
||||
final NetworkBroadcastReceiver n;
|
||||
final boolean o;
|
||||
boolean p;
|
||||
|
||||
private static class DispatcherHandler extends Handler {
|
||||
private final Dispatcher a;
|
||||
|
||||
public DispatcherHandler(Looper looper, Dispatcher dispatcher) {
|
||||
super(looper);
|
||||
this.a = dispatcher;
|
||||
}
|
||||
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(final Message message) {
|
||||
switch (message.what) {
|
||||
case 1:
|
||||
this.a.d((Action) message.obj);
|
||||
break;
|
||||
case 2:
|
||||
this.a.c((Action) message.obj);
|
||||
break;
|
||||
case 3:
|
||||
case 8:
|
||||
default:
|
||||
Picasso.p.post(new Runnable(this) { // from class: com.squareup.picasso.Dispatcher.DispatcherHandler.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
throw new AssertionError("Unknown handler message received: " + message.what);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case 4:
|
||||
this.a.d((BitmapHunter) message.obj);
|
||||
break;
|
||||
case 5:
|
||||
this.a.e((BitmapHunter) message.obj);
|
||||
break;
|
||||
case 6:
|
||||
this.a.a((BitmapHunter) message.obj, false);
|
||||
break;
|
||||
case 7:
|
||||
this.a.a();
|
||||
break;
|
||||
case 9:
|
||||
this.a.b((NetworkInfo) message.obj);
|
||||
break;
|
||||
case 10:
|
||||
this.a.b(message.arg1 == 1);
|
||||
break;
|
||||
case 11:
|
||||
this.a.a(message.obj);
|
||||
break;
|
||||
case 12:
|
||||
this.a.b(message.obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class DispatcherThread extends HandlerThread {
|
||||
DispatcherThread() {
|
||||
super("Picasso-Dispatcher", 10);
|
||||
}
|
||||
}
|
||||
|
||||
static class NetworkBroadcastReceiver extends BroadcastReceiver {
|
||||
private final Dispatcher a;
|
||||
|
||||
NetworkBroadcastReceiver(Dispatcher dispatcher) {
|
||||
this.a = dispatcher;
|
||||
}
|
||||
|
||||
void a() {
|
||||
IntentFilter intentFilter = new IntentFilter();
|
||||
intentFilter.addAction("android.intent.action.AIRPLANE_MODE");
|
||||
if (this.a.o) {
|
||||
intentFilter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
|
||||
}
|
||||
this.a.b.registerReceiver(this, intentFilter);
|
||||
}
|
||||
|
||||
@Override // android.content.BroadcastReceiver
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent == null) {
|
||||
return;
|
||||
}
|
||||
String action = intent.getAction();
|
||||
if ("android.intent.action.AIRPLANE_MODE".equals(action)) {
|
||||
if (intent.hasExtra("state")) {
|
||||
this.a.a(intent.getBooleanExtra("state", false));
|
||||
}
|
||||
} else if ("android.net.conn.CONNECTIVITY_CHANGE".equals(action)) {
|
||||
this.a.a(((ConnectivityManager) Utils.a(context, "connectivity")).getActiveNetworkInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Dispatcher(Context context, ExecutorService executorService, Handler handler, Downloader downloader, Cache cache, Stats stats) {
|
||||
this.a.start();
|
||||
Utils.a(this.a.getLooper());
|
||||
this.b = context;
|
||||
this.c = executorService;
|
||||
this.e = new LinkedHashMap();
|
||||
this.f = new WeakHashMap();
|
||||
this.g = new WeakHashMap();
|
||||
this.h = new HashSet();
|
||||
this.i = new DispatcherHandler(this.a.getLooper(), this);
|
||||
this.d = downloader;
|
||||
this.j = handler;
|
||||
this.k = cache;
|
||||
this.l = stats;
|
||||
this.m = new ArrayList(4);
|
||||
this.p = Utils.d(this.b);
|
||||
this.o = Utils.b(context, "android.permission.ACCESS_NETWORK_STATE");
|
||||
this.n = new NetworkBroadcastReceiver(this);
|
||||
this.n.a();
|
||||
}
|
||||
|
||||
private void f(BitmapHunter bitmapHunter) {
|
||||
if (bitmapHunter.o()) {
|
||||
return;
|
||||
}
|
||||
this.m.add(bitmapHunter);
|
||||
if (this.i.hasMessages(7)) {
|
||||
return;
|
||||
}
|
||||
this.i.sendEmptyMessageDelayed(7, 200L);
|
||||
}
|
||||
|
||||
private void g(BitmapHunter bitmapHunter) {
|
||||
Action a = bitmapHunter.a();
|
||||
if (a != null) {
|
||||
e(a);
|
||||
}
|
||||
List<Action> b = bitmapHunter.b();
|
||||
if (b != null) {
|
||||
int size = b.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
e(b.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void a(Action action) {
|
||||
Handler handler = this.i;
|
||||
handler.sendMessage(handler.obtainMessage(2, action));
|
||||
}
|
||||
|
||||
void b(Action action) {
|
||||
Handler handler = this.i;
|
||||
handler.sendMessage(handler.obtainMessage(1, action));
|
||||
}
|
||||
|
||||
void c(BitmapHunter bitmapHunter) {
|
||||
Handler handler = this.i;
|
||||
handler.sendMessageDelayed(handler.obtainMessage(5, bitmapHunter), 500L);
|
||||
}
|
||||
|
||||
void d(Action action) {
|
||||
a(action, true);
|
||||
}
|
||||
|
||||
void e(BitmapHunter bitmapHunter) {
|
||||
if (bitmapHunter.o()) {
|
||||
return;
|
||||
}
|
||||
boolean z = false;
|
||||
if (this.c.isShutdown()) {
|
||||
a(bitmapHunter, false);
|
||||
return;
|
||||
}
|
||||
NetworkInfo activeNetworkInfo = this.o ? ((ConnectivityManager) Utils.a(this.b, "connectivity")).getActiveNetworkInfo() : null;
|
||||
boolean z2 = activeNetworkInfo != null && activeNetworkInfo.isConnected();
|
||||
boolean a = bitmapHunter.a(this.p, activeNetworkInfo);
|
||||
boolean p = bitmapHunter.p();
|
||||
if (!a) {
|
||||
if (this.o && p) {
|
||||
z = true;
|
||||
}
|
||||
a(bitmapHunter, z);
|
||||
if (z) {
|
||||
g(bitmapHunter);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (this.o && !z2) {
|
||||
a(bitmapHunter, p);
|
||||
if (p) {
|
||||
g(bitmapHunter);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (bitmapHunter.k().n) {
|
||||
Utils.a("Dispatcher", "retrying", Utils.a(bitmapHunter));
|
||||
}
|
||||
if (bitmapHunter.d() instanceof NetworkRequestHandler.ContentLengthException) {
|
||||
bitmapHunter.i |= NetworkPolicy.NO_CACHE.index;
|
||||
}
|
||||
bitmapHunter.n = this.c.submit(bitmapHunter);
|
||||
}
|
||||
|
||||
void a(BitmapHunter bitmapHunter) {
|
||||
Handler handler = this.i;
|
||||
handler.sendMessage(handler.obtainMessage(4, bitmapHunter));
|
||||
}
|
||||
|
||||
void b(BitmapHunter bitmapHunter) {
|
||||
Handler handler = this.i;
|
||||
handler.sendMessage(handler.obtainMessage(6, bitmapHunter));
|
||||
}
|
||||
|
||||
void c(Action action) {
|
||||
String c = action.c();
|
||||
BitmapHunter bitmapHunter = this.e.get(c);
|
||||
if (bitmapHunter != null) {
|
||||
bitmapHunter.b(action);
|
||||
if (bitmapHunter.cancel()) {
|
||||
this.e.remove(c);
|
||||
if (action.f().n) {
|
||||
Utils.a("Dispatcher", "canceled", action.h().d());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.h.contains(action.i())) {
|
||||
this.g.remove(action.j());
|
||||
if (action.f().n) {
|
||||
Utils.a("Dispatcher", "canceled", action.h().d(), "because paused request got canceled");
|
||||
}
|
||||
}
|
||||
Action remove = this.f.remove(action.j());
|
||||
if (remove == null || !remove.f().n) {
|
||||
return;
|
||||
}
|
||||
Utils.a("Dispatcher", "canceled", remove.h().d(), "from replaying");
|
||||
}
|
||||
|
||||
void d(BitmapHunter bitmapHunter) {
|
||||
if (MemoryPolicy.shouldWriteToMemoryCache(bitmapHunter.j())) {
|
||||
this.k.a(bitmapHunter.e(), bitmapHunter.m());
|
||||
}
|
||||
this.e.remove(bitmapHunter.e());
|
||||
f(bitmapHunter);
|
||||
if (bitmapHunter.k().n) {
|
||||
Utils.a("Dispatcher", "batched", Utils.a(bitmapHunter), "for completion");
|
||||
}
|
||||
}
|
||||
|
||||
void a(NetworkInfo networkInfo) {
|
||||
Handler handler = this.i;
|
||||
handler.sendMessage(handler.obtainMessage(9, networkInfo));
|
||||
}
|
||||
|
||||
void b(Object obj) {
|
||||
if (this.h.remove(obj)) {
|
||||
ArrayList arrayList = null;
|
||||
Iterator<Action> it = this.g.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
Action next = it.next();
|
||||
if (next.i().equals(obj)) {
|
||||
if (arrayList == null) {
|
||||
arrayList = new ArrayList();
|
||||
}
|
||||
arrayList.add(next);
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
if (arrayList != null) {
|
||||
Handler handler = this.j;
|
||||
handler.sendMessage(handler.obtainMessage(13, arrayList));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void a(boolean z) {
|
||||
Handler handler = this.i;
|
||||
handler.sendMessage(handler.obtainMessage(10, z ? 1 : 0, 0));
|
||||
}
|
||||
|
||||
void a(Action action, boolean z) {
|
||||
if (this.h.contains(action.i())) {
|
||||
this.g.put(action.j(), action);
|
||||
if (action.f().n) {
|
||||
Utils.a("Dispatcher", "paused", action.b.d(), "because tag '" + action.i() + "' is paused");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
BitmapHunter bitmapHunter = this.e.get(action.c());
|
||||
if (bitmapHunter != null) {
|
||||
bitmapHunter.a(action);
|
||||
return;
|
||||
}
|
||||
if (this.c.isShutdown()) {
|
||||
if (action.f().n) {
|
||||
Utils.a("Dispatcher", "ignored", action.b.d(), "because shut down");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
BitmapHunter a = BitmapHunter.a(action.f(), this, this.k, this.l, action);
|
||||
a.n = this.c.submit(a);
|
||||
this.e.put(action.c(), a);
|
||||
if (z) {
|
||||
this.f.remove(action.j());
|
||||
}
|
||||
if (action.f().n) {
|
||||
Utils.a("Dispatcher", "enqueued", action.b.d());
|
||||
}
|
||||
}
|
||||
|
||||
void b(boolean z) {
|
||||
this.p = z;
|
||||
}
|
||||
|
||||
void b(NetworkInfo networkInfo) {
|
||||
ExecutorService executorService = this.c;
|
||||
if (executorService instanceof PicassoExecutorService) {
|
||||
((PicassoExecutorService) executorService).a(networkInfo);
|
||||
}
|
||||
if (networkInfo == null || !networkInfo.isConnected()) {
|
||||
return;
|
||||
}
|
||||
b();
|
||||
}
|
||||
|
||||
private void b() {
|
||||
if (this.f.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Iterator<Action> it = this.f.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
Action next = it.next();
|
||||
it.remove();
|
||||
if (next.f().n) {
|
||||
Utils.a("Dispatcher", "replaying", next.h().d());
|
||||
}
|
||||
a(next, false);
|
||||
}
|
||||
}
|
||||
|
||||
private void e(Action action) {
|
||||
Object j = action.j();
|
||||
if (j != null) {
|
||||
action.k = true;
|
||||
this.f.put(j, action);
|
||||
}
|
||||
}
|
||||
|
||||
void a(Object obj) {
|
||||
if (this.h.add(obj)) {
|
||||
Iterator<BitmapHunter> it = this.e.values().iterator();
|
||||
while (it.hasNext()) {
|
||||
BitmapHunter next = it.next();
|
||||
boolean z = next.k().n;
|
||||
Action a = next.a();
|
||||
List<Action> b = next.b();
|
||||
boolean z2 = (b == null || b.isEmpty()) ? false : true;
|
||||
if (a != null || z2) {
|
||||
if (a != null && a.i().equals(obj)) {
|
||||
next.b(a);
|
||||
this.g.put(a.j(), a);
|
||||
if (z) {
|
||||
Utils.a("Dispatcher", "paused", a.b.d(), "because tag '" + obj + "' was paused");
|
||||
}
|
||||
}
|
||||
if (z2) {
|
||||
for (int size = b.size() - 1; size >= 0; size--) {
|
||||
Action action = b.get(size);
|
||||
if (action.i().equals(obj)) {
|
||||
next.b(action);
|
||||
this.g.put(action.j(), action);
|
||||
if (z) {
|
||||
Utils.a("Dispatcher", "paused", action.b.d(), "because tag '" + obj + "' was paused");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (next.cancel()) {
|
||||
it.remove();
|
||||
if (z) {
|
||||
Utils.a("Dispatcher", "canceled", Utils.a(next), "all actions paused");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void a() {
|
||||
ArrayList arrayList = new ArrayList(this.m);
|
||||
this.m.clear();
|
||||
Handler handler = this.j;
|
||||
handler.sendMessage(handler.obtainMessage(8, arrayList));
|
||||
a((List<BitmapHunter>) arrayList);
|
||||
}
|
||||
|
||||
void a(BitmapHunter bitmapHunter, boolean z) {
|
||||
if (bitmapHunter.k().n) {
|
||||
String a = Utils.a(bitmapHunter);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("for error");
|
||||
sb.append(z ? " (will replay)" : "");
|
||||
Utils.a("Dispatcher", "batched", a, sb.toString());
|
||||
}
|
||||
this.e.remove(bitmapHunter.e());
|
||||
f(bitmapHunter);
|
||||
}
|
||||
|
||||
private void a(List<BitmapHunter> list) {
|
||||
if (list == null || list.isEmpty() || !list.get(0).k().n) {
|
||||
return;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (BitmapHunter bitmapHunter : list) {
|
||||
if (sb.length() > 0) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(Utils.a(bitmapHunter));
|
||||
}
|
||||
Utils.a("Dispatcher", "delivered", sb.toString());
|
||||
}
|
||||
}
|
53
sources/com/squareup/picasso/Downloader.java
Normal file
53
sources/com/squareup/picasso/Downloader.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Downloader {
|
||||
|
||||
public static class Response {
|
||||
final InputStream a;
|
||||
final Bitmap b;
|
||||
final boolean c;
|
||||
final long d;
|
||||
|
||||
public Response(InputStream inputStream, boolean z, long j) {
|
||||
if (inputStream == null) {
|
||||
throw new IllegalArgumentException("Stream may not be null.");
|
||||
}
|
||||
this.a = inputStream;
|
||||
this.b = null;
|
||||
this.c = z;
|
||||
this.d = j;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public Bitmap a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
public long b() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public InputStream c() {
|
||||
return this.a;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ResponseException extends IOException {
|
||||
final boolean localCacheOnly;
|
||||
final int responseCode;
|
||||
|
||||
public ResponseException(String str, int i, int i2) {
|
||||
super(str);
|
||||
this.localCacheOnly = NetworkPolicy.isOfflineOnly(i);
|
||||
this.responseCode = i2;
|
||||
}
|
||||
}
|
||||
|
||||
Response a(Uri uri, int i) throws IOException;
|
||||
}
|
36
sources/com/squareup/picasso/FileRequestHandler.java
Normal file
36
sources/com/squareup/picasso/FileRequestHandler.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.ExifInterface;
|
||||
import android.net.Uri;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestHandler;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class FileRequestHandler extends ContentStreamRequestHandler {
|
||||
FileRequestHandler(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.ContentStreamRequestHandler, com.squareup.picasso.RequestHandler
|
||||
public boolean a(Request request) {
|
||||
return "file".equals(request.d.getScheme());
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.ContentStreamRequestHandler, com.squareup.picasso.RequestHandler
|
||||
public RequestHandler.Result a(Request request, int i) throws IOException {
|
||||
return new RequestHandler.Result(null, c(request), Picasso.LoadedFrom.DISK, a(request.d));
|
||||
}
|
||||
|
||||
static int a(Uri uri) throws IOException {
|
||||
int attributeInt = new ExifInterface(uri.getPath()).getAttributeInt("Orientation", 1);
|
||||
if (attributeInt == 3) {
|
||||
return 180;
|
||||
}
|
||||
if (attributeInt != 6) {
|
||||
return attributeInt != 8 ? 0 : 270;
|
||||
}
|
||||
return 90;
|
||||
}
|
||||
}
|
62
sources/com/squareup/picasso/ImageViewAction.java
Normal file
62
sources/com/squareup/picasso/ImageViewAction.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.widget.ImageView;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ImageViewAction extends Action<ImageView> {
|
||||
Callback m;
|
||||
|
||||
ImageViewAction(Picasso picasso, ImageView imageView, Request request, int i, int i2, int i3, Drawable drawable, String str, Object obj, Callback callback, boolean z) {
|
||||
super(picasso, imageView, request, i, i2, i3, drawable, str, obj, z);
|
||||
this.m = callback;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Action
|
||||
public void a(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
|
||||
if (bitmap == null) {
|
||||
throw new AssertionError(String.format("Attempted to complete action with no result!\n%s", this));
|
||||
}
|
||||
ImageView imageView = (ImageView) this.c.get();
|
||||
if (imageView == null) {
|
||||
return;
|
||||
}
|
||||
Picasso picasso = this.a;
|
||||
PicassoDrawable.a(imageView, picasso.e, bitmap, loadedFrom, this.d, picasso.m);
|
||||
Callback callback = this.m;
|
||||
if (callback != null) {
|
||||
callback.onSuccess();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Action
|
||||
public void b() {
|
||||
ImageView imageView = (ImageView) this.c.get();
|
||||
if (imageView == null) {
|
||||
return;
|
||||
}
|
||||
int i = this.g;
|
||||
if (i != 0) {
|
||||
imageView.setImageResource(i);
|
||||
} else {
|
||||
Drawable drawable = this.h;
|
||||
if (drawable != null) {
|
||||
imageView.setImageDrawable(drawable);
|
||||
}
|
||||
}
|
||||
Callback callback = this.m;
|
||||
if (callback != null) {
|
||||
callback.onError();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Action
|
||||
void a() {
|
||||
super.a();
|
||||
if (this.m != null) {
|
||||
this.m = null;
|
||||
}
|
||||
}
|
||||
}
|
141
sources/com/squareup/picasso/LruCache.java
Normal file
141
sources/com/squareup/picasso/LruCache.java
Normal file
@@ -0,0 +1,141 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class LruCache implements Cache {
|
||||
final LinkedHashMap<String, Bitmap> a;
|
||||
private final int b;
|
||||
private int c;
|
||||
private int d;
|
||||
private int e;
|
||||
private int f;
|
||||
private int g;
|
||||
|
||||
public LruCache(Context context) {
|
||||
this(Utils.a(context));
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Cache
|
||||
public void a(String str, Bitmap bitmap) {
|
||||
if (str == null || bitmap == null) {
|
||||
throw new NullPointerException("key == null || bitmap == null");
|
||||
}
|
||||
synchronized (this) {
|
||||
this.d++;
|
||||
this.c += Utils.a(bitmap);
|
||||
Bitmap put = this.a.put(str, bitmap);
|
||||
if (put != null) {
|
||||
this.c -= Utils.a(put);
|
||||
}
|
||||
}
|
||||
a(this.b);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Cache
|
||||
public Bitmap get(String str) {
|
||||
if (str == null) {
|
||||
throw new NullPointerException("key == null");
|
||||
}
|
||||
synchronized (this) {
|
||||
Bitmap bitmap = this.a.get(str);
|
||||
if (bitmap != null) {
|
||||
this.f++;
|
||||
return bitmap;
|
||||
}
|
||||
this.g++;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Cache
|
||||
public final synchronized int size() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
public LruCache(int i) {
|
||||
if (i <= 0) {
|
||||
throw new IllegalArgumentException("Max size must be positive.");
|
||||
}
|
||||
this.b = i;
|
||||
this.a = new LinkedHashMap<>(0, 0.75f, true);
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:11:0x0070, code lost:
|
||||
|
||||
throw new java.lang.IllegalStateException(getClass().getName() + ".sizeOf() is reporting inconsistent results!");
|
||||
*/
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
private void a(int r4) {
|
||||
/*
|
||||
r3 = this;
|
||||
L0:
|
||||
monitor-enter(r3)
|
||||
int r0 = r3.c // Catch: java.lang.Throwable -> L71
|
||||
if (r0 < 0) goto L52
|
||||
java.util.LinkedHashMap<java.lang.String, android.graphics.Bitmap> r0 = r3.a // Catch: java.lang.Throwable -> L71
|
||||
boolean r0 = r0.isEmpty() // Catch: java.lang.Throwable -> L71
|
||||
if (r0 == 0) goto L11
|
||||
int r0 = r3.c // Catch: java.lang.Throwable -> L71
|
||||
if (r0 != 0) goto L52
|
||||
L11:
|
||||
int r0 = r3.c // Catch: java.lang.Throwable -> L71
|
||||
if (r0 <= r4) goto L50
|
||||
java.util.LinkedHashMap<java.lang.String, android.graphics.Bitmap> r0 = r3.a // Catch: java.lang.Throwable -> L71
|
||||
boolean r0 = r0.isEmpty() // Catch: java.lang.Throwable -> L71
|
||||
if (r0 == 0) goto L1e
|
||||
goto L50
|
||||
L1e:
|
||||
java.util.LinkedHashMap<java.lang.String, android.graphics.Bitmap> r0 = r3.a // Catch: java.lang.Throwable -> L71
|
||||
java.util.Set r0 = r0.entrySet() // Catch: java.lang.Throwable -> L71
|
||||
java.util.Iterator r0 = r0.iterator() // Catch: java.lang.Throwable -> L71
|
||||
java.lang.Object r0 = r0.next() // Catch: java.lang.Throwable -> L71
|
||||
java.util.Map$Entry r0 = (java.util.Map.Entry) r0 // Catch: java.lang.Throwable -> L71
|
||||
java.lang.Object r1 = r0.getKey() // Catch: java.lang.Throwable -> L71
|
||||
java.lang.String r1 = (java.lang.String) r1 // Catch: java.lang.Throwable -> L71
|
||||
java.lang.Object r0 = r0.getValue() // Catch: java.lang.Throwable -> L71
|
||||
android.graphics.Bitmap r0 = (android.graphics.Bitmap) r0 // Catch: java.lang.Throwable -> L71
|
||||
java.util.LinkedHashMap<java.lang.String, android.graphics.Bitmap> r2 = r3.a // Catch: java.lang.Throwable -> L71
|
||||
r2.remove(r1) // Catch: java.lang.Throwable -> L71
|
||||
int r1 = r3.c // Catch: java.lang.Throwable -> L71
|
||||
int r0 = com.squareup.picasso.Utils.a(r0) // Catch: java.lang.Throwable -> L71
|
||||
int r1 = r1 - r0
|
||||
r3.c = r1 // Catch: java.lang.Throwable -> L71
|
||||
int r0 = r3.e // Catch: java.lang.Throwable -> L71
|
||||
int r0 = r0 + 1
|
||||
r3.e = r0 // Catch: java.lang.Throwable -> L71
|
||||
monitor-exit(r3) // Catch: java.lang.Throwable -> L71
|
||||
goto L0
|
||||
L50:
|
||||
monitor-exit(r3) // Catch: java.lang.Throwable -> L71
|
||||
return
|
||||
L52:
|
||||
java.lang.IllegalStateException r4 = new java.lang.IllegalStateException // Catch: java.lang.Throwable -> L71
|
||||
java.lang.StringBuilder r0 = new java.lang.StringBuilder // Catch: java.lang.Throwable -> L71
|
||||
r0.<init>() // Catch: java.lang.Throwable -> L71
|
||||
java.lang.Class r1 = r3.getClass() // Catch: java.lang.Throwable -> L71
|
||||
java.lang.String r1 = r1.getName() // Catch: java.lang.Throwable -> L71
|
||||
r0.append(r1) // Catch: java.lang.Throwable -> L71
|
||||
java.lang.String r1 = ".sizeOf() is reporting inconsistent results!"
|
||||
r0.append(r1) // Catch: java.lang.Throwable -> L71
|
||||
java.lang.String r0 = r0.toString() // Catch: java.lang.Throwable -> L71
|
||||
r4.<init>(r0) // Catch: java.lang.Throwable -> L71
|
||||
throw r4 // Catch: java.lang.Throwable -> L71
|
||||
L71:
|
||||
r4 = move-exception
|
||||
monitor-exit(r3) // Catch: java.lang.Throwable -> L71
|
||||
throw r4
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.squareup.picasso.LruCache.a(int):void");
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Cache
|
||||
public final synchronized int a() {
|
||||
return this.b;
|
||||
}
|
||||
}
|
131
sources/com/squareup/picasso/MarkableInputStream.java
Normal file
131
sources/com/squareup/picasso/MarkableInputStream.java
Normal file
@@ -0,0 +1,131 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import com.ubt.jimu.base.util.FileUtil;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class MarkableInputStream extends InputStream {
|
||||
private final InputStream a;
|
||||
private long b;
|
||||
private long c;
|
||||
private long d;
|
||||
private long e;
|
||||
|
||||
public MarkableInputStream(InputStream inputStream) {
|
||||
this(inputStream, FileUtil.ZIP_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
private void b(long j) {
|
||||
try {
|
||||
if (this.c >= this.b || this.b > this.d) {
|
||||
this.c = this.b;
|
||||
this.a.mark((int) (j - this.b));
|
||||
} else {
|
||||
this.a.reset();
|
||||
this.a.mark((int) (j - this.c));
|
||||
a(this.c, this.b);
|
||||
}
|
||||
this.d = j;
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Unable to mark: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
public long a(int i) {
|
||||
long j = this.b + i;
|
||||
if (this.d < j) {
|
||||
b(j);
|
||||
}
|
||||
return this.b;
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream
|
||||
public int available() throws IOException {
|
||||
return this.a.available();
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream, java.io.Closeable, java.lang.AutoCloseable
|
||||
public void close() throws IOException {
|
||||
this.a.close();
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream
|
||||
public void mark(int i) {
|
||||
this.e = a(i);
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream
|
||||
public boolean markSupported() {
|
||||
return this.a.markSupported();
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream
|
||||
public int read() throws IOException {
|
||||
int read = this.a.read();
|
||||
if (read != -1) {
|
||||
this.b++;
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream
|
||||
public void reset() throws IOException {
|
||||
a(this.e);
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream
|
||||
public long skip(long j) throws IOException {
|
||||
long skip = this.a.skip(j);
|
||||
this.b += skip;
|
||||
return skip;
|
||||
}
|
||||
|
||||
public MarkableInputStream(InputStream inputStream, int i) {
|
||||
this.e = -1L;
|
||||
this.a = inputStream.markSupported() ? inputStream : new BufferedInputStream(inputStream, i);
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream
|
||||
public int read(byte[] bArr) throws IOException {
|
||||
int read = this.a.read(bArr);
|
||||
if (read != -1) {
|
||||
this.b += read;
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
public void a(long j) throws IOException {
|
||||
if (this.b <= this.d && j >= this.c) {
|
||||
this.a.reset();
|
||||
a(this.c, j);
|
||||
this.b = j;
|
||||
return;
|
||||
}
|
||||
throw new IOException("Cannot reset");
|
||||
}
|
||||
|
||||
@Override // java.io.InputStream
|
||||
public int read(byte[] bArr, int i, int i2) throws IOException {
|
||||
int read = this.a.read(bArr, i, i2);
|
||||
if (read != -1) {
|
||||
this.b += read;
|
||||
}
|
||||
return read;
|
||||
}
|
||||
|
||||
private void a(long j, long j2) throws IOException {
|
||||
while (j < j2) {
|
||||
long skip = this.a.skip(j2 - j);
|
||||
if (skip == 0) {
|
||||
if (read() == -1) {
|
||||
return;
|
||||
} else {
|
||||
skip = 1;
|
||||
}
|
||||
}
|
||||
j += skip;
|
||||
}
|
||||
}
|
||||
}
|
131
sources/com/squareup/picasso/MediaStoreRequestHandler.java
Normal file
131
sources/com/squareup/picasso/MediaStoreRequestHandler.java
Normal file
@@ -0,0 +1,131 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentUris;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.provider.MediaStore;
|
||||
import com.ijm.dataencryption.de.DataDecryptTool;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestHandler;
|
||||
import com.unity3d.ads.adunit.AdUnitActivity;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class MediaStoreRequestHandler extends ContentStreamRequestHandler {
|
||||
private static final String[] b = {AdUnitActivity.EXTRA_ORIENTATION};
|
||||
|
||||
enum PicassoKind {
|
||||
MICRO(3, 96, 96),
|
||||
MINI(1, DataDecryptTool.DECRYPT_DB_FILE, 384),
|
||||
FULL(2, -1, -1);
|
||||
|
||||
final int a;
|
||||
final int b;
|
||||
final int c;
|
||||
|
||||
PicassoKind(int i, int i2, int i3) {
|
||||
this.a = i;
|
||||
this.b = i2;
|
||||
this.c = i3;
|
||||
}
|
||||
}
|
||||
|
||||
MediaStoreRequestHandler(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.ContentStreamRequestHandler, com.squareup.picasso.RequestHandler
|
||||
public boolean a(Request request) {
|
||||
Uri uri = request.d;
|
||||
return "content".equals(uri.getScheme()) && "media".equals(uri.getAuthority());
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.ContentStreamRequestHandler, com.squareup.picasso.RequestHandler
|
||||
public RequestHandler.Result a(Request request, int i) throws IOException {
|
||||
Bitmap thumbnail;
|
||||
ContentResolver contentResolver = this.a.getContentResolver();
|
||||
int a = a(contentResolver, request.d);
|
||||
String type = contentResolver.getType(request.d);
|
||||
boolean z = type != null && type.startsWith("video/");
|
||||
if (request.c()) {
|
||||
PicassoKind a2 = a(request.h, request.i);
|
||||
if (!z && a2 == PicassoKind.FULL) {
|
||||
return new RequestHandler.Result(null, c(request), Picasso.LoadedFrom.DISK, a);
|
||||
}
|
||||
long parseId = ContentUris.parseId(request.d);
|
||||
BitmapFactory.Options b2 = RequestHandler.b(request);
|
||||
b2.inJustDecodeBounds = true;
|
||||
RequestHandler.a(request.h, request.i, a2.b, a2.c, b2, request);
|
||||
if (z) {
|
||||
thumbnail = MediaStore.Video.Thumbnails.getThumbnail(contentResolver, parseId, a2 == PicassoKind.FULL ? 1 : a2.a, b2);
|
||||
} else {
|
||||
thumbnail = MediaStore.Images.Thumbnails.getThumbnail(contentResolver, parseId, a2.a, b2);
|
||||
}
|
||||
if (thumbnail != null) {
|
||||
return new RequestHandler.Result(thumbnail, null, Picasso.LoadedFrom.DISK, a);
|
||||
}
|
||||
}
|
||||
return new RequestHandler.Result(null, c(request), Picasso.LoadedFrom.DISK, a);
|
||||
}
|
||||
|
||||
static PicassoKind a(int i, int i2) {
|
||||
PicassoKind picassoKind = PicassoKind.MICRO;
|
||||
if (i <= picassoKind.b && i2 <= picassoKind.c) {
|
||||
return picassoKind;
|
||||
}
|
||||
PicassoKind picassoKind2 = PicassoKind.MINI;
|
||||
return (i > picassoKind2.b || i2 > picassoKind2.c) ? PicassoKind.FULL : picassoKind2;
|
||||
}
|
||||
|
||||
/* JADX WARN: Code restructure failed: missing block: B:15:0x0022, code lost:
|
||||
|
||||
r1.close();
|
||||
*/
|
||||
/*
|
||||
Code decompiled incorrectly, please refer to instructions dump.
|
||||
To view partially-correct code enable 'Show inconsistent code' option in preferences
|
||||
*/
|
||||
static int a(android.content.ContentResolver r8, android.net.Uri r9) {
|
||||
/*
|
||||
r0 = 0
|
||||
r1 = 0
|
||||
java.lang.String[] r4 = com.squareup.picasso.MediaStoreRequestHandler.b // Catch: java.lang.Throwable -> L26 java.lang.RuntimeException -> L2d
|
||||
r5 = 0
|
||||
r6 = 0
|
||||
r7 = 0
|
||||
r2 = r8
|
||||
r3 = r9
|
||||
android.database.Cursor r1 = r2.query(r3, r4, r5, r6, r7) // Catch: java.lang.Throwable -> L26 java.lang.RuntimeException -> L2d
|
||||
if (r1 == 0) goto L20
|
||||
boolean r8 = r1.moveToFirst() // Catch: java.lang.Throwable -> L26 java.lang.RuntimeException -> L2d
|
||||
if (r8 != 0) goto L16
|
||||
goto L20
|
||||
L16:
|
||||
int r8 = r1.getInt(r0) // Catch: java.lang.Throwable -> L26 java.lang.RuntimeException -> L2d
|
||||
if (r1 == 0) goto L1f
|
||||
r1.close()
|
||||
L1f:
|
||||
return r8
|
||||
L20:
|
||||
if (r1 == 0) goto L25
|
||||
r1.close()
|
||||
L25:
|
||||
return r0
|
||||
L26:
|
||||
r8 = move-exception
|
||||
if (r1 == 0) goto L2c
|
||||
r1.close()
|
||||
L2c:
|
||||
throw r8
|
||||
L2d:
|
||||
if (r1 == 0) goto L33
|
||||
r1.close()
|
||||
L33:
|
||||
return r0
|
||||
*/
|
||||
throw new UnsupportedOperationException("Method not decompiled: com.squareup.picasso.MediaStoreRequestHandler.a(android.content.ContentResolver, android.net.Uri):int");
|
||||
}
|
||||
}
|
21
sources/com/squareup/picasso/MemoryPolicy.java
Normal file
21
sources/com/squareup/picasso/MemoryPolicy.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public enum MemoryPolicy {
|
||||
NO_CACHE(1),
|
||||
NO_STORE(2);
|
||||
|
||||
final int index;
|
||||
|
||||
MemoryPolicy(int i) {
|
||||
this.index = i;
|
||||
}
|
||||
|
||||
static boolean shouldReadFromMemoryCache(int i) {
|
||||
return (i & NO_CACHE.index) == 0;
|
||||
}
|
||||
|
||||
static boolean shouldWriteToMemoryCache(int i) {
|
||||
return (i & NO_STORE.index) == 0;
|
||||
}
|
||||
}
|
26
sources/com/squareup/picasso/NetworkPolicy.java
Normal file
26
sources/com/squareup/picasso/NetworkPolicy.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public enum NetworkPolicy {
|
||||
NO_CACHE(1),
|
||||
NO_STORE(2),
|
||||
OFFLINE(4);
|
||||
|
||||
final int index;
|
||||
|
||||
NetworkPolicy(int i) {
|
||||
this.index = i;
|
||||
}
|
||||
|
||||
public static boolean isOfflineOnly(int i) {
|
||||
return (i & OFFLINE.index) != 0;
|
||||
}
|
||||
|
||||
public static boolean shouldReadFromDiskCache(int i) {
|
||||
return (i & NO_CACHE.index) == 0;
|
||||
}
|
||||
|
||||
public static boolean shouldWriteToDiskCache(int i) {
|
||||
return (i & NO_STORE.index) == 0;
|
||||
}
|
||||
}
|
72
sources/com/squareup/picasso/NetworkRequestHandler.java
Normal file
72
sources/com/squareup/picasso/NetworkRequestHandler.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.NetworkInfo;
|
||||
import com.squareup.picasso.Downloader;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestHandler;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class NetworkRequestHandler extends RequestHandler {
|
||||
private final Downloader a;
|
||||
private final Stats b;
|
||||
|
||||
static class ContentLengthException extends IOException {
|
||||
public ContentLengthException(String str) {
|
||||
super(str);
|
||||
}
|
||||
}
|
||||
|
||||
public NetworkRequestHandler(Downloader downloader, Stats stats) {
|
||||
this.a = downloader;
|
||||
this.b = stats;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
int a() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public boolean a(Request request) {
|
||||
String scheme = request.d.getScheme();
|
||||
return "http".equals(scheme) || "https".equals(scheme);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
boolean b() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public RequestHandler.Result a(Request request, int i) throws IOException {
|
||||
Downloader.Response a = this.a.a(request.d, request.c);
|
||||
if (a == null) {
|
||||
return null;
|
||||
}
|
||||
Picasso.LoadedFrom loadedFrom = a.c ? Picasso.LoadedFrom.DISK : Picasso.LoadedFrom.NETWORK;
|
||||
Bitmap a2 = a.a();
|
||||
if (a2 != null) {
|
||||
return new RequestHandler.Result(a2, loadedFrom);
|
||||
}
|
||||
InputStream c = a.c();
|
||||
if (c == null) {
|
||||
return null;
|
||||
}
|
||||
if (loadedFrom == Picasso.LoadedFrom.DISK && a.b() == 0) {
|
||||
Utils.a(c);
|
||||
throw new ContentLengthException("Received response with 0 content-length header.");
|
||||
}
|
||||
if (loadedFrom == Picasso.LoadedFrom.NETWORK && a.b() > 0) {
|
||||
this.b.a(a.b());
|
||||
}
|
||||
return new RequestHandler.Result(c, loadedFrom);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
boolean a(boolean z, NetworkInfo networkInfo) {
|
||||
return networkInfo == null || networkInfo.isConnected();
|
||||
}
|
||||
}
|
78
sources/com/squareup/picasso/OkHttpDownloader.java
Normal file
78
sources/com/squareup/picasso/OkHttpDownloader.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import com.squareup.okhttp.CacheControl;
|
||||
import com.squareup.okhttp.OkHttpClient;
|
||||
import com.squareup.okhttp.Request;
|
||||
import com.squareup.okhttp.Response;
|
||||
import com.squareup.okhttp.ResponseBody;
|
||||
import com.squareup.picasso.Downloader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class OkHttpDownloader implements Downloader {
|
||||
private final OkHttpClient a;
|
||||
|
||||
public OkHttpDownloader(Context context) {
|
||||
this(Utils.b(context));
|
||||
}
|
||||
|
||||
private static OkHttpClient a() {
|
||||
OkHttpClient okHttpClient = new OkHttpClient();
|
||||
okHttpClient.setConnectTimeout(15000L, TimeUnit.MILLISECONDS);
|
||||
okHttpClient.setReadTimeout(20000L, TimeUnit.MILLISECONDS);
|
||||
okHttpClient.setWriteTimeout(20000L, TimeUnit.MILLISECONDS);
|
||||
return okHttpClient;
|
||||
}
|
||||
|
||||
public OkHttpDownloader(File file) {
|
||||
this(file, Utils.a(file));
|
||||
}
|
||||
|
||||
public OkHttpDownloader(File file, long j) {
|
||||
this(a());
|
||||
try {
|
||||
this.a.setCache(new com.squareup.okhttp.Cache(file, j));
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
|
||||
public OkHttpDownloader(OkHttpClient okHttpClient) {
|
||||
this.a = okHttpClient;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Downloader
|
||||
public Downloader.Response a(Uri uri, int i) throws IOException {
|
||||
CacheControl cacheControl;
|
||||
if (i == 0) {
|
||||
cacheControl = null;
|
||||
} else if (NetworkPolicy.isOfflineOnly(i)) {
|
||||
cacheControl = CacheControl.FORCE_CACHE;
|
||||
} else {
|
||||
CacheControl.Builder builder = new CacheControl.Builder();
|
||||
if (!NetworkPolicy.shouldReadFromDiskCache(i)) {
|
||||
builder.noCache();
|
||||
}
|
||||
if (!NetworkPolicy.shouldWriteToDiskCache(i)) {
|
||||
builder.noStore();
|
||||
}
|
||||
cacheControl = builder.build();
|
||||
}
|
||||
Request.Builder url = new Request.Builder().url(uri.toString());
|
||||
if (cacheControl != null) {
|
||||
url.cacheControl(cacheControl);
|
||||
}
|
||||
Response execute = this.a.newCall(url.build()).execute();
|
||||
int code = execute.code();
|
||||
if (code < 300) {
|
||||
boolean z = execute.cacheResponse() != null;
|
||||
ResponseBody body = execute.body();
|
||||
return new Downloader.Response(body.byteStream(), z, body.contentLength());
|
||||
}
|
||||
execute.body().close();
|
||||
throw new Downloader.ResponseException(code + " " + execute.message(), i, code);
|
||||
}
|
||||
}
|
374
sources/com/squareup/picasso/Picasso.java
Normal file
374
sources/com/squareup/picasso/Picasso.java
Normal file
@@ -0,0 +1,374 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.widget.ImageView;
|
||||
import com.squareup.picasso.Action;
|
||||
import com.ubt.jimu.base.entities.Course;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class Picasso {
|
||||
static final Handler p = new Handler(Looper.getMainLooper()) { // from class: com.squareup.picasso.Picasso.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
int i = message.what;
|
||||
if (i == 3) {
|
||||
Action action = (Action) message.obj;
|
||||
if (action.f().n) {
|
||||
Utils.a("Main", "canceled", action.b.d(), "target got garbage collected");
|
||||
}
|
||||
action.a.a(action.j());
|
||||
return;
|
||||
}
|
||||
int i2 = 0;
|
||||
if (i == 8) {
|
||||
List list = (List) message.obj;
|
||||
int size = list.size();
|
||||
while (i2 < size) {
|
||||
BitmapHunter bitmapHunter = (BitmapHunter) list.get(i2);
|
||||
bitmapHunter.b.a(bitmapHunter);
|
||||
i2++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (i != 13) {
|
||||
throw new AssertionError("Unknown handler message received: " + message.what);
|
||||
}
|
||||
List list2 = (List) message.obj;
|
||||
int size2 = list2.size();
|
||||
while (i2 < size2) {
|
||||
Action action2 = (Action) list2.get(i2);
|
||||
action2.a.b(action2);
|
||||
i2++;
|
||||
}
|
||||
}
|
||||
};
|
||||
static volatile Picasso q = null;
|
||||
private final Listener a;
|
||||
private final RequestTransformer b;
|
||||
private final CleanupThread c;
|
||||
private final List<RequestHandler> d;
|
||||
final Context e;
|
||||
final Dispatcher f;
|
||||
final Cache g;
|
||||
final Stats h;
|
||||
final Map<Object, Action> i;
|
||||
final Map<ImageView, DeferredRequestCreator> j;
|
||||
final ReferenceQueue<Object> k;
|
||||
final Bitmap.Config l;
|
||||
boolean m;
|
||||
volatile boolean n;
|
||||
boolean o;
|
||||
|
||||
public static class Builder {
|
||||
private final Context a;
|
||||
private Downloader b;
|
||||
private ExecutorService c;
|
||||
private Cache d;
|
||||
private Listener e;
|
||||
private RequestTransformer f;
|
||||
private List<RequestHandler> g;
|
||||
private Bitmap.Config h;
|
||||
private boolean i;
|
||||
private boolean j;
|
||||
|
||||
public Builder(Context context) {
|
||||
if (context == null) {
|
||||
throw new IllegalArgumentException("Context must not be null.");
|
||||
}
|
||||
this.a = context.getApplicationContext();
|
||||
}
|
||||
|
||||
public Picasso a() {
|
||||
Context context = this.a;
|
||||
if (this.b == null) {
|
||||
this.b = Utils.c(context);
|
||||
}
|
||||
if (this.d == null) {
|
||||
this.d = new LruCache(context);
|
||||
}
|
||||
if (this.c == null) {
|
||||
this.c = new PicassoExecutorService();
|
||||
}
|
||||
if (this.f == null) {
|
||||
this.f = RequestTransformer.a;
|
||||
}
|
||||
Stats stats = new Stats(this.d);
|
||||
return new Picasso(context, new Dispatcher(context, this.c, Picasso.p, this.b, this.d, stats), this.d, this.e, this.f, this.g, stats, this.h, this.i, this.j);
|
||||
}
|
||||
}
|
||||
|
||||
private static class CleanupThread extends Thread {
|
||||
private final ReferenceQueue<Object> a;
|
||||
private final Handler b;
|
||||
|
||||
CleanupThread(ReferenceQueue<Object> referenceQueue, Handler handler) {
|
||||
this.a = referenceQueue;
|
||||
this.b = handler;
|
||||
setDaemon(true);
|
||||
setName("Picasso-refQueue");
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
Process.setThreadPriority(10);
|
||||
while (true) {
|
||||
try {
|
||||
Action.RequestWeakReference requestWeakReference = (Action.RequestWeakReference) this.a.remove(1000L);
|
||||
Message obtainMessage = this.b.obtainMessage();
|
||||
if (requestWeakReference != null) {
|
||||
obtainMessage.what = 3;
|
||||
obtainMessage.obj = requestWeakReference.a;
|
||||
this.b.sendMessage(obtainMessage);
|
||||
} else {
|
||||
obtainMessage.recycle();
|
||||
}
|
||||
} catch (InterruptedException unused) {
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
this.b.post(new Runnable(this) { // from class: com.squareup.picasso.Picasso.CleanupThread.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
void a(Picasso picasso, Uri uri, Exception exc);
|
||||
}
|
||||
|
||||
public enum LoadedFrom {
|
||||
MEMORY(-16711936),
|
||||
DISK(-16776961),
|
||||
NETWORK(-65536);
|
||||
|
||||
final int debugColor;
|
||||
|
||||
LoadedFrom(int i) {
|
||||
this.debugColor = i;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Priority {
|
||||
LOW,
|
||||
NORMAL,
|
||||
HIGH
|
||||
}
|
||||
|
||||
public interface RequestTransformer {
|
||||
public static final RequestTransformer a = new RequestTransformer() { // from class: com.squareup.picasso.Picasso.RequestTransformer.1
|
||||
@Override // com.squareup.picasso.Picasso.RequestTransformer
|
||||
public Request a(Request request) {
|
||||
return request;
|
||||
}
|
||||
};
|
||||
|
||||
Request a(Request request);
|
||||
}
|
||||
|
||||
Picasso(Context context, Dispatcher dispatcher, Cache cache, Listener listener, RequestTransformer requestTransformer, List<RequestHandler> list, Stats stats, Bitmap.Config config, boolean z, boolean z2) {
|
||||
this.e = context;
|
||||
this.f = dispatcher;
|
||||
this.g = cache;
|
||||
this.a = listener;
|
||||
this.b = requestTransformer;
|
||||
this.l = config;
|
||||
ArrayList arrayList = new ArrayList((list != null ? list.size() : 0) + 7);
|
||||
arrayList.add(new ResourceRequestHandler(context));
|
||||
if (list != null) {
|
||||
arrayList.addAll(list);
|
||||
}
|
||||
arrayList.add(new ContactsPhotoRequestHandler(context));
|
||||
arrayList.add(new MediaStoreRequestHandler(context));
|
||||
arrayList.add(new ContentStreamRequestHandler(context));
|
||||
arrayList.add(new AssetRequestHandler(context));
|
||||
arrayList.add(new FileRequestHandler(context));
|
||||
arrayList.add(new NetworkRequestHandler(dispatcher.d, stats));
|
||||
this.d = Collections.unmodifiableList(arrayList);
|
||||
this.h = stats;
|
||||
this.i = new WeakHashMap();
|
||||
this.j = new WeakHashMap();
|
||||
this.m = z;
|
||||
this.n = z2;
|
||||
this.k = new ReferenceQueue<>();
|
||||
this.c = new CleanupThread(this.k, p);
|
||||
this.c.start();
|
||||
}
|
||||
|
||||
Bitmap b(String str) {
|
||||
Bitmap bitmap = this.g.get(str);
|
||||
if (bitmap != null) {
|
||||
this.h.b();
|
||||
} else {
|
||||
this.h.c();
|
||||
}
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
void c(Action action) {
|
||||
this.f.b(action);
|
||||
}
|
||||
|
||||
public void a(ImageView imageView) {
|
||||
a((Object) imageView);
|
||||
}
|
||||
|
||||
public void a(Target target) {
|
||||
a((Object) target);
|
||||
}
|
||||
|
||||
public RequestCreator a(Uri uri) {
|
||||
return new RequestCreator(this, uri, 0);
|
||||
}
|
||||
|
||||
void b(Action action) {
|
||||
Bitmap b = MemoryPolicy.shouldReadFromMemoryCache(action.e) ? b(action.c()) : null;
|
||||
if (b != null) {
|
||||
a(b, LoadedFrom.MEMORY, action);
|
||||
if (this.n) {
|
||||
Utils.a("Main", Course.STATUS_COMPLETED, action.b.d(), "from " + LoadedFrom.MEMORY);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
a(action);
|
||||
if (this.n) {
|
||||
Utils.a("Main", "resumed", action.b.d());
|
||||
}
|
||||
}
|
||||
|
||||
public RequestCreator a(String str) {
|
||||
if (str == null) {
|
||||
return new RequestCreator(this, null, 0);
|
||||
}
|
||||
if (str.trim().length() != 0) {
|
||||
return a(Uri.parse(str));
|
||||
}
|
||||
throw new IllegalArgumentException("Path must not be empty.");
|
||||
}
|
||||
|
||||
List<RequestHandler> a() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
Request a(Request request) {
|
||||
this.b.a(request);
|
||||
if (request != null) {
|
||||
return request;
|
||||
}
|
||||
throw new IllegalStateException("Request transformer " + this.b.getClass().getCanonicalName() + " returned null for " + request);
|
||||
}
|
||||
|
||||
void a(ImageView imageView, DeferredRequestCreator deferredRequestCreator) {
|
||||
this.j.put(imageView, deferredRequestCreator);
|
||||
}
|
||||
|
||||
void a(Action action) {
|
||||
Object j = action.j();
|
||||
if (j != null && this.i.get(j) != action) {
|
||||
a(j);
|
||||
this.i.put(j, action);
|
||||
}
|
||||
c(action);
|
||||
}
|
||||
|
||||
void a(BitmapHunter bitmapHunter) {
|
||||
Action a = bitmapHunter.a();
|
||||
List<Action> b = bitmapHunter.b();
|
||||
boolean z = true;
|
||||
boolean z2 = (b == null || b.isEmpty()) ? false : true;
|
||||
if (a == null && !z2) {
|
||||
z = false;
|
||||
}
|
||||
if (z) {
|
||||
Uri uri = bitmapHunter.c().d;
|
||||
Exception d = bitmapHunter.d();
|
||||
Bitmap m = bitmapHunter.m();
|
||||
LoadedFrom f = bitmapHunter.f();
|
||||
if (a != null) {
|
||||
a(m, f, a);
|
||||
}
|
||||
if (z2) {
|
||||
int size = b.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
a(m, f, b.get(i));
|
||||
}
|
||||
}
|
||||
Listener listener = this.a;
|
||||
if (listener == null || d == null) {
|
||||
return;
|
||||
}
|
||||
listener.a(this, uri, d);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(Bitmap bitmap, LoadedFrom loadedFrom, Action action) {
|
||||
if (action.k()) {
|
||||
return;
|
||||
}
|
||||
if (!action.l()) {
|
||||
this.i.remove(action.j());
|
||||
}
|
||||
if (bitmap == null) {
|
||||
action.b();
|
||||
if (this.n) {
|
||||
Utils.a("Main", "errored", action.b.d());
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (loadedFrom != null) {
|
||||
action.a(bitmap, loadedFrom);
|
||||
if (this.n) {
|
||||
Utils.a("Main", Course.STATUS_COMPLETED, action.b.d(), "from " + loadedFrom);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
throw new AssertionError("LoadedFrom cannot be null.");
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void a(Object obj) {
|
||||
Utils.a();
|
||||
Action remove = this.i.remove(obj);
|
||||
if (remove != null) {
|
||||
remove.a();
|
||||
this.f.a(remove);
|
||||
}
|
||||
if (obj instanceof ImageView) {
|
||||
DeferredRequestCreator remove2 = this.j.remove((ImageView) obj);
|
||||
if (remove2 != null) {
|
||||
remove2.a();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Picasso a(Context context) {
|
||||
if (q == null) {
|
||||
synchronized (Picasso.class) {
|
||||
if (q == null) {
|
||||
q = new Builder(context).a();
|
||||
}
|
||||
}
|
||||
}
|
||||
return q;
|
||||
}
|
||||
}
|
130
sources/com/squareup/picasso/PicassoDrawable.java
Normal file
130
sources/com/squareup/picasso/PicassoDrawable.java
Normal file
@@ -0,0 +1,130 @@
|
||||
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;
|
||||
}
|
||||
}
|
91
sources/com/squareup/picasso/PicassoExecutorService.java
Normal file
91
sources/com/squareup/picasso/PicassoExecutorService.java
Normal file
@@ -0,0 +1,91 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.net.NetworkInfo;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.Utils;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class PicassoExecutorService extends ThreadPoolExecutor {
|
||||
|
||||
private static final class PicassoFutureTask extends FutureTask<BitmapHunter> implements Comparable<PicassoFutureTask> {
|
||||
private final BitmapHunter a;
|
||||
|
||||
public PicassoFutureTask(BitmapHunter bitmapHunter) {
|
||||
super(bitmapHunter, null);
|
||||
this.a = bitmapHunter;
|
||||
}
|
||||
|
||||
@Override // java.lang.Comparable
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public int compareTo(PicassoFutureTask picassoFutureTask) {
|
||||
Picasso.Priority l = this.a.l();
|
||||
Picasso.Priority l2 = picassoFutureTask.a.l();
|
||||
return l == l2 ? this.a.a - picassoFutureTask.a.a : l2.ordinal() - l.ordinal();
|
||||
}
|
||||
}
|
||||
|
||||
PicassoExecutorService() {
|
||||
super(3, 3, 0L, TimeUnit.MILLISECONDS, new PriorityBlockingQueue(), new Utils.PicassoThreadFactory());
|
||||
}
|
||||
|
||||
void a(NetworkInfo networkInfo) {
|
||||
if (networkInfo == null || !networkInfo.isConnectedOrConnecting()) {
|
||||
a(3);
|
||||
return;
|
||||
}
|
||||
int type = networkInfo.getType();
|
||||
if (type != 0) {
|
||||
if (type == 1 || type == 6 || type == 9) {
|
||||
a(4);
|
||||
return;
|
||||
} else {
|
||||
a(3);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int subtype = networkInfo.getSubtype();
|
||||
switch (subtype) {
|
||||
case 1:
|
||||
case 2:
|
||||
a(1);
|
||||
return;
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
break;
|
||||
default:
|
||||
switch (subtype) {
|
||||
case 12:
|
||||
break;
|
||||
case 13:
|
||||
case 14:
|
||||
case 15:
|
||||
a(3);
|
||||
break;
|
||||
default:
|
||||
a(3);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
a(2);
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.AbstractExecutorService, java.util.concurrent.ExecutorService
|
||||
public Future<?> submit(Runnable runnable) {
|
||||
PicassoFutureTask picassoFutureTask = new PicassoFutureTask((BitmapHunter) runnable);
|
||||
execute(picassoFutureTask);
|
||||
return picassoFutureTask;
|
||||
}
|
||||
|
||||
private void a(int i) {
|
||||
setCorePoolSize(i);
|
||||
setMaximumPoolSize(i);
|
||||
}
|
||||
}
|
224
sources/com/squareup/picasso/Request.java
Normal file
224
sources/com/squareup/picasso/Request.java
Normal file
@@ -0,0 +1,224 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public final class Request {
|
||||
private static final long s = TimeUnit.SECONDS.toNanos(5);
|
||||
int a;
|
||||
long b;
|
||||
int c;
|
||||
public final Uri d;
|
||||
public final int e;
|
||||
public final String f;
|
||||
public final List<Transformation> g;
|
||||
public final int h;
|
||||
public final int i;
|
||||
public final boolean j;
|
||||
public final boolean k;
|
||||
public final boolean l;
|
||||
public final float m;
|
||||
public final float n;
|
||||
public final float o;
|
||||
public final boolean p;
|
||||
public final Bitmap.Config q;
|
||||
public final Picasso.Priority r;
|
||||
|
||||
String a() {
|
||||
Uri uri = this.d;
|
||||
return uri != null ? String.valueOf(uri.getPath()) : Integer.toHexString(this.e);
|
||||
}
|
||||
|
||||
boolean b() {
|
||||
return this.g != null;
|
||||
}
|
||||
|
||||
public boolean c() {
|
||||
return (this.h == 0 && this.i == 0) ? false : true;
|
||||
}
|
||||
|
||||
String d() {
|
||||
long nanoTime = System.nanoTime() - this.b;
|
||||
if (nanoTime > s) {
|
||||
return g() + '+' + TimeUnit.NANOSECONDS.toSeconds(nanoTime) + 's';
|
||||
}
|
||||
return g() + '+' + TimeUnit.NANOSECONDS.toMillis(nanoTime) + "ms";
|
||||
}
|
||||
|
||||
boolean e() {
|
||||
return c() || this.m != 0.0f;
|
||||
}
|
||||
|
||||
boolean f() {
|
||||
return e() || b();
|
||||
}
|
||||
|
||||
String g() {
|
||||
return "[R" + this.a + ']';
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder("Request{");
|
||||
int i = this.e;
|
||||
if (i > 0) {
|
||||
sb.append(i);
|
||||
} else {
|
||||
sb.append(this.d);
|
||||
}
|
||||
List<Transformation> list = this.g;
|
||||
if (list != null && !list.isEmpty()) {
|
||||
for (Transformation transformation : this.g) {
|
||||
sb.append(' ');
|
||||
sb.append(transformation.a());
|
||||
}
|
||||
}
|
||||
if (this.f != null) {
|
||||
sb.append(" stableKey(");
|
||||
sb.append(this.f);
|
||||
sb.append(')');
|
||||
}
|
||||
if (this.h > 0) {
|
||||
sb.append(" resize(");
|
||||
sb.append(this.h);
|
||||
sb.append(',');
|
||||
sb.append(this.i);
|
||||
sb.append(')');
|
||||
}
|
||||
if (this.j) {
|
||||
sb.append(" centerCrop");
|
||||
}
|
||||
if (this.k) {
|
||||
sb.append(" centerInside");
|
||||
}
|
||||
if (this.m != 0.0f) {
|
||||
sb.append(" rotation(");
|
||||
sb.append(this.m);
|
||||
if (this.p) {
|
||||
sb.append(" @ ");
|
||||
sb.append(this.n);
|
||||
sb.append(',');
|
||||
sb.append(this.o);
|
||||
}
|
||||
sb.append(')');
|
||||
}
|
||||
if (this.q != null) {
|
||||
sb.append(' ');
|
||||
sb.append(this.q);
|
||||
}
|
||||
sb.append('}');
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private Request(Uri uri, int i, String str, List<Transformation> list, int i2, int i3, boolean z, boolean z2, boolean z3, float f, float f2, float f3, boolean z4, Bitmap.Config config, Picasso.Priority priority) {
|
||||
this.d = uri;
|
||||
this.e = i;
|
||||
this.f = str;
|
||||
if (list == null) {
|
||||
this.g = null;
|
||||
} else {
|
||||
this.g = Collections.unmodifiableList(list);
|
||||
}
|
||||
this.h = i2;
|
||||
this.i = i3;
|
||||
this.j = z;
|
||||
this.k = z2;
|
||||
this.l = z3;
|
||||
this.m = f;
|
||||
this.n = f2;
|
||||
this.o = f3;
|
||||
this.p = z4;
|
||||
this.q = config;
|
||||
this.r = priority;
|
||||
}
|
||||
|
||||
public static final class Builder {
|
||||
private Uri a;
|
||||
private int b;
|
||||
private String c;
|
||||
private int d;
|
||||
private int e;
|
||||
private boolean f;
|
||||
private boolean g;
|
||||
private boolean h;
|
||||
private float i;
|
||||
private float j;
|
||||
private float k;
|
||||
private boolean l;
|
||||
private List<Transformation> m;
|
||||
private Bitmap.Config n;
|
||||
private Picasso.Priority o;
|
||||
|
||||
Builder(Uri uri, int i, Bitmap.Config config) {
|
||||
this.a = uri;
|
||||
this.b = i;
|
||||
this.n = config;
|
||||
}
|
||||
|
||||
public Builder a(int i, int i2) {
|
||||
if (i < 0) {
|
||||
throw new IllegalArgumentException("Width must be positive number or 0.");
|
||||
}
|
||||
if (i2 < 0) {
|
||||
throw new IllegalArgumentException("Height must be positive number or 0.");
|
||||
}
|
||||
if (i2 == 0 && i == 0) {
|
||||
throw new IllegalArgumentException("At least one dimension has to be positive number.");
|
||||
}
|
||||
this.d = i;
|
||||
this.e = i2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder b() {
|
||||
if (this.g) {
|
||||
throw new IllegalStateException("Center crop can not be used after calling centerInside");
|
||||
}
|
||||
this.f = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
boolean c() {
|
||||
return (this.a == null && this.b == 0) ? false : true;
|
||||
}
|
||||
|
||||
boolean d() {
|
||||
return (this.d == 0 && this.e == 0) ? false : true;
|
||||
}
|
||||
|
||||
public Builder a(Transformation transformation) {
|
||||
if (transformation != null) {
|
||||
if (transformation.a() != null) {
|
||||
if (this.m == null) {
|
||||
this.m = new ArrayList(2);
|
||||
}
|
||||
this.m.add(transformation);
|
||||
return this;
|
||||
}
|
||||
throw new IllegalArgumentException("Transformation key must not be null.");
|
||||
}
|
||||
throw new IllegalArgumentException("Transformation must not be null.");
|
||||
}
|
||||
|
||||
public Request a() {
|
||||
if (this.g && this.f) {
|
||||
throw new IllegalStateException("Center crop and center inside can not be used together.");
|
||||
}
|
||||
if (this.f && this.d == 0 && this.e == 0) {
|
||||
throw new IllegalStateException("Center crop requires calling resize with positive width and height.");
|
||||
}
|
||||
if (this.g && this.d == 0 && this.e == 0) {
|
||||
throw new IllegalStateException("Center inside requires calling resize with positive width and height.");
|
||||
}
|
||||
if (this.o == null) {
|
||||
this.o = Picasso.Priority.NORMAL;
|
||||
}
|
||||
return new Request(this.a, this.b, this.c, this.m, this.d, this.e, this.f, this.g, this.h, this.i, this.j, this.k, this.l, this.n, this.o);
|
||||
}
|
||||
}
|
||||
}
|
192
sources/com/squareup/picasso/RequestCreator.java
Normal file
192
sources/com/squareup/picasso/RequestCreator.java
Normal file
@@ -0,0 +1,192 @@
|
||||
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;
|
||||
}
|
||||
}
|
122
sources/com/squareup/picasso/RequestHandler.java
Normal file
122
sources/com/squareup/picasso/RequestHandler.java
Normal file
@@ -0,0 +1,122 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.NetworkInfo;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public abstract class RequestHandler {
|
||||
|
||||
public static final class Result {
|
||||
private final Picasso.LoadedFrom a;
|
||||
private final Bitmap b;
|
||||
private final InputStream c;
|
||||
private final int d;
|
||||
|
||||
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
|
||||
public Result(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
|
||||
this(bitmap, null, loadedFrom, 0);
|
||||
Utils.a(bitmap, "bitmap == null");
|
||||
}
|
||||
|
||||
public Bitmap a() {
|
||||
return this.b;
|
||||
}
|
||||
|
||||
int b() {
|
||||
return this.d;
|
||||
}
|
||||
|
||||
public Picasso.LoadedFrom c() {
|
||||
return this.a;
|
||||
}
|
||||
|
||||
public InputStream d() {
|
||||
return this.c;
|
||||
}
|
||||
|
||||
/* JADX WARN: 'this' call moved to the top of the method (can break code semantics) */
|
||||
public Result(InputStream inputStream, Picasso.LoadedFrom loadedFrom) {
|
||||
this(null, inputStream, loadedFrom, 0);
|
||||
Utils.a(inputStream, "stream == null");
|
||||
}
|
||||
|
||||
Result(Bitmap bitmap, InputStream inputStream, Picasso.LoadedFrom loadedFrom, int i) {
|
||||
if ((inputStream != null) ^ (bitmap != null)) {
|
||||
this.b = bitmap;
|
||||
this.c = inputStream;
|
||||
Utils.a(loadedFrom, "loadedFrom == null");
|
||||
this.a = loadedFrom;
|
||||
this.d = i;
|
||||
return;
|
||||
}
|
||||
throw new AssertionError();
|
||||
}
|
||||
}
|
||||
|
||||
static boolean a(BitmapFactory.Options options) {
|
||||
return options != null && options.inJustDecodeBounds;
|
||||
}
|
||||
|
||||
static BitmapFactory.Options b(Request request) {
|
||||
boolean c = request.c();
|
||||
boolean z = request.q != null;
|
||||
BitmapFactory.Options options = null;
|
||||
if (c || z) {
|
||||
options = new BitmapFactory.Options();
|
||||
options.inJustDecodeBounds = c;
|
||||
if (z) {
|
||||
options.inPreferredConfig = request.q;
|
||||
}
|
||||
}
|
||||
return options;
|
||||
}
|
||||
|
||||
int a() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public abstract Result a(Request request, int i) throws IOException;
|
||||
|
||||
public abstract boolean a(Request request);
|
||||
|
||||
boolean a(boolean z, NetworkInfo networkInfo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean b() {
|
||||
return false;
|
||||
}
|
||||
|
||||
static void a(int i, int i2, BitmapFactory.Options options, Request request) {
|
||||
a(i, i2, options.outWidth, options.outHeight, options, request);
|
||||
}
|
||||
|
||||
static void a(int i, int i2, int i3, int i4, BitmapFactory.Options options, Request request) {
|
||||
int min;
|
||||
double floor;
|
||||
if (i4 > i2 || i3 > i) {
|
||||
if (i2 == 0) {
|
||||
floor = Math.floor(i3 / i);
|
||||
} else if (i == 0) {
|
||||
floor = Math.floor(i4 / i2);
|
||||
} else {
|
||||
int floor2 = (int) Math.floor(i4 / i2);
|
||||
int floor3 = (int) Math.floor(i3 / i);
|
||||
if (request.k) {
|
||||
min = Math.max(floor2, floor3);
|
||||
} else {
|
||||
min = Math.min(floor2, floor3);
|
||||
}
|
||||
}
|
||||
min = (int) floor;
|
||||
} else {
|
||||
min = 1;
|
||||
}
|
||||
options.inSampleSize = min;
|
||||
options.inJustDecodeBounds = false;
|
||||
}
|
||||
}
|
41
sources/com/squareup/picasso/ResourceRequestHandler.java
Normal file
41
sources/com/squareup/picasso/ResourceRequestHandler.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.squareup.picasso.RequestHandler;
|
||||
import java.io.IOException;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class ResourceRequestHandler extends RequestHandler {
|
||||
private final Context a;
|
||||
|
||||
ResourceRequestHandler(Context context) {
|
||||
this.a = context;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public boolean a(Request request) {
|
||||
if (request.e != 0) {
|
||||
return true;
|
||||
}
|
||||
return "android.resource".equals(request.d.getScheme());
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.RequestHandler
|
||||
public RequestHandler.Result a(Request request, int i) throws IOException {
|
||||
Resources a = Utils.a(this.a, request);
|
||||
return new RequestHandler.Result(a(a, Utils.a(a, request), request), Picasso.LoadedFrom.DISK);
|
||||
}
|
||||
|
||||
private static Bitmap a(Resources resources, int i, Request request) {
|
||||
BitmapFactory.Options b = RequestHandler.b(request);
|
||||
if (RequestHandler.a(b)) {
|
||||
BitmapFactory.decodeResource(resources, i, b);
|
||||
RequestHandler.a(request.h, request.i, b, request);
|
||||
}
|
||||
return BitmapFactory.decodeResource(resources, i, b);
|
||||
}
|
||||
}
|
131
sources/com/squareup/picasso/Stats.java
Normal file
131
sources/com/squareup/picasso/Stats.java
Normal file
@@ -0,0 +1,131 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
class Stats {
|
||||
final HandlerThread a = new HandlerThread("Picasso-Stats", 10);
|
||||
final Cache b;
|
||||
final Handler c;
|
||||
long d;
|
||||
long e;
|
||||
long f;
|
||||
long g;
|
||||
long h;
|
||||
long i;
|
||||
long j;
|
||||
long k;
|
||||
int l;
|
||||
int m;
|
||||
int n;
|
||||
|
||||
private static class StatsHandler extends Handler {
|
||||
private final Stats a;
|
||||
|
||||
public StatsHandler(Looper looper, Stats stats) {
|
||||
super(looper);
|
||||
this.a = stats;
|
||||
}
|
||||
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(final Message message) {
|
||||
int i = message.what;
|
||||
if (i == 0) {
|
||||
this.a.d();
|
||||
return;
|
||||
}
|
||||
if (i == 1) {
|
||||
this.a.e();
|
||||
return;
|
||||
}
|
||||
if (i == 2) {
|
||||
this.a.b(message.arg1);
|
||||
return;
|
||||
}
|
||||
if (i == 3) {
|
||||
this.a.c(message.arg1);
|
||||
} else if (i != 4) {
|
||||
Picasso.p.post(new Runnable(this) { // from class: com.squareup.picasso.Stats.StatsHandler.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
throw new AssertionError("Unhandled stats message." + message.what);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.a.a((Long) message.obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Stats(Cache cache) {
|
||||
this.b = cache;
|
||||
this.a.start();
|
||||
Utils.a(this.a.getLooper());
|
||||
this.c = new StatsHandler(this.a.getLooper(), this);
|
||||
}
|
||||
|
||||
void a(Bitmap bitmap) {
|
||||
a(bitmap, 2);
|
||||
}
|
||||
|
||||
void b(Bitmap bitmap) {
|
||||
a(bitmap, 3);
|
||||
}
|
||||
|
||||
void c() {
|
||||
this.c.sendEmptyMessage(1);
|
||||
}
|
||||
|
||||
void d() {
|
||||
this.d++;
|
||||
}
|
||||
|
||||
void e() {
|
||||
this.e++;
|
||||
}
|
||||
|
||||
void a(long j) {
|
||||
Handler handler = this.c;
|
||||
handler.sendMessage(handler.obtainMessage(4, Long.valueOf(j)));
|
||||
}
|
||||
|
||||
void b() {
|
||||
this.c.sendEmptyMessage(0);
|
||||
}
|
||||
|
||||
void c(long j) {
|
||||
this.n++;
|
||||
this.h += j;
|
||||
this.k = a(this.m, this.h);
|
||||
}
|
||||
|
||||
void a(Long l) {
|
||||
this.l++;
|
||||
this.f += l.longValue();
|
||||
this.i = a(this.l, this.f);
|
||||
}
|
||||
|
||||
void b(long j) {
|
||||
this.m++;
|
||||
this.g += j;
|
||||
this.j = a(this.m, this.g);
|
||||
}
|
||||
|
||||
StatsSnapshot a() {
|
||||
return new StatsSnapshot(this.b.a(), this.b.size(), this.d, this.e, this.f, this.g, this.h, this.i, this.j, this.k, this.l, this.m, this.n, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
private void a(Bitmap bitmap, int i) {
|
||||
int a = Utils.a(bitmap);
|
||||
Handler handler = this.c;
|
||||
handler.sendMessage(handler.obtainMessage(i, a, 0));
|
||||
}
|
||||
|
||||
private static long a(int i, long j) {
|
||||
return j / i;
|
||||
}
|
||||
}
|
79
sources/com/squareup/picasso/StatsSnapshot.java
Normal file
79
sources/com/squareup/picasso/StatsSnapshot.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class StatsSnapshot {
|
||||
public final int a;
|
||||
public final int b;
|
||||
public final long c;
|
||||
public final long d;
|
||||
public final long e;
|
||||
public final long f;
|
||||
public final long g;
|
||||
public final long h;
|
||||
public final long i;
|
||||
public final long j;
|
||||
public final int k;
|
||||
public final int l;
|
||||
public final int m;
|
||||
public final long n;
|
||||
|
||||
public StatsSnapshot(int i, int i2, long j, long j2, long j3, long j4, long j5, long j6, long j7, long j8, int i3, int i4, int i5, long j9) {
|
||||
this.a = i;
|
||||
this.b = i2;
|
||||
this.c = j;
|
||||
this.d = j2;
|
||||
this.e = j3;
|
||||
this.f = j4;
|
||||
this.g = j5;
|
||||
this.h = j6;
|
||||
this.i = j7;
|
||||
this.j = j8;
|
||||
this.k = i3;
|
||||
this.l = i4;
|
||||
this.m = i5;
|
||||
this.n = j9;
|
||||
}
|
||||
|
||||
public void a(PrintWriter printWriter) {
|
||||
printWriter.println("===============BEGIN PICASSO STATS ===============");
|
||||
printWriter.println("Memory Cache Stats");
|
||||
printWriter.print(" Max Cache Size: ");
|
||||
printWriter.println(this.a);
|
||||
printWriter.print(" Cache Size: ");
|
||||
printWriter.println(this.b);
|
||||
printWriter.print(" Cache % Full: ");
|
||||
printWriter.println((int) Math.ceil((this.b / this.a) * 100.0f));
|
||||
printWriter.print(" Cache Hits: ");
|
||||
printWriter.println(this.c);
|
||||
printWriter.print(" Cache Misses: ");
|
||||
printWriter.println(this.d);
|
||||
printWriter.println("Network Stats");
|
||||
printWriter.print(" Download Count: ");
|
||||
printWriter.println(this.k);
|
||||
printWriter.print(" Total Download Size: ");
|
||||
printWriter.println(this.e);
|
||||
printWriter.print(" Average Download Size: ");
|
||||
printWriter.println(this.h);
|
||||
printWriter.println("Bitmap Stats");
|
||||
printWriter.print(" Total Bitmaps Decoded: ");
|
||||
printWriter.println(this.l);
|
||||
printWriter.print(" Total Bitmap Size: ");
|
||||
printWriter.println(this.f);
|
||||
printWriter.print(" Total Transformed Bitmaps: ");
|
||||
printWriter.println(this.m);
|
||||
printWriter.print(" Total Transformed Bitmap Size: ");
|
||||
printWriter.println(this.g);
|
||||
printWriter.print(" Average Bitmap Size: ");
|
||||
printWriter.println(this.i);
|
||||
printWriter.print(" Average Transformed Bitmap Size: ");
|
||||
printWriter.println(this.j);
|
||||
printWriter.println("===============END PICASSO STATS ===============");
|
||||
printWriter.flush();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "StatsSnapshot{maxSize=" + this.a + ", size=" + this.b + ", cacheHits=" + this.c + ", cacheMisses=" + this.d + ", downloadCount=" + this.k + ", totalDownloadSize=" + this.e + ", averageDownloadSize=" + this.h + ", totalOriginalBitmapSize=" + this.f + ", totalTransformedBitmapSize=" + this.g + ", averageOriginalBitmapSize=" + this.i + ", averageTransformedBitmapSize=" + this.j + ", originalBitmapCount=" + this.l + ", transformedBitmapCount=" + this.m + ", timeStamp=" + this.n + '}';
|
||||
}
|
||||
}
|
14
sources/com/squareup/picasso/Target.java
Normal file
14
sources/com/squareup/picasso/Target.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Target {
|
||||
void a(Bitmap bitmap, Picasso.LoadedFrom loadedFrom);
|
||||
|
||||
void a(Drawable drawable);
|
||||
|
||||
void b(Drawable drawable);
|
||||
}
|
38
sources/com/squareup/picasso/TargetAction.java
Normal file
38
sources/com/squareup/picasso/TargetAction.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import com.squareup.picasso.Picasso;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class TargetAction extends Action<Target> {
|
||||
TargetAction(Picasso picasso, Target target, Request request, int i, int i2, Drawable drawable, String str, Object obj, int i3) {
|
||||
super(picasso, target, request, i, i2, i3, drawable, str, obj, false);
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Action
|
||||
void a(Bitmap bitmap, Picasso.LoadedFrom loadedFrom) {
|
||||
if (bitmap == null) {
|
||||
throw new AssertionError(String.format("Attempted to complete action with no result!\n%s", this));
|
||||
}
|
||||
Target j = j();
|
||||
if (j != null) {
|
||||
j.a(bitmap, loadedFrom);
|
||||
if (bitmap.isRecycled()) {
|
||||
throw new IllegalStateException("Target callback must not recycle bitmap!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Action
|
||||
void b() {
|
||||
Target j = j();
|
||||
if (j != null) {
|
||||
if (this.g != 0) {
|
||||
j.a(this.a.e.getResources().getDrawable(this.g));
|
||||
} else {
|
||||
j.a(this.h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
10
sources/com/squareup/picasso/Transformation.java
Normal file
10
sources/com/squareup/picasso/Transformation.java
Normal file
@@ -0,0 +1,10 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public interface Transformation {
|
||||
Bitmap a(Bitmap bitmap);
|
||||
|
||||
String a();
|
||||
}
|
92
sources/com/squareup/picasso/UrlConnectionDownloader.java
Normal file
92
sources/com/squareup/picasso/UrlConnectionDownloader.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.net.http.HttpResponseCache;
|
||||
import android.os.Build;
|
||||
import com.squareup.picasso.Downloader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class UrlConnectionDownloader implements Downloader {
|
||||
static volatile Object b;
|
||||
private static final Object c = new Object();
|
||||
private static final ThreadLocal<StringBuilder> d = new ThreadLocal<StringBuilder>() { // from class: com.squareup.picasso.UrlConnectionDownloader.1
|
||||
/* JADX INFO: Access modifiers changed from: protected */
|
||||
@Override // java.lang.ThreadLocal
|
||||
public StringBuilder initialValue() {
|
||||
return new StringBuilder();
|
||||
}
|
||||
};
|
||||
private final Context a;
|
||||
|
||||
private static class ResponseCacheIcs {
|
||||
static Object a(Context context) throws IOException {
|
||||
File b = Utils.b(context);
|
||||
HttpResponseCache installed = HttpResponseCache.getInstalled();
|
||||
return installed == null ? HttpResponseCache.install(b, Utils.a(b)) : installed;
|
||||
}
|
||||
}
|
||||
|
||||
public UrlConnectionDownloader(Context context) {
|
||||
this.a = context.getApplicationContext();
|
||||
}
|
||||
|
||||
protected HttpURLConnection a(Uri uri) throws IOException {
|
||||
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(uri.toString()).openConnection();
|
||||
httpURLConnection.setConnectTimeout(15000);
|
||||
httpURLConnection.setReadTimeout(20000);
|
||||
return httpURLConnection;
|
||||
}
|
||||
|
||||
@Override // com.squareup.picasso.Downloader
|
||||
public Downloader.Response a(Uri uri, int i) throws IOException {
|
||||
String sb;
|
||||
if (Build.VERSION.SDK_INT >= 14) {
|
||||
a(this.a);
|
||||
}
|
||||
HttpURLConnection a = a(uri);
|
||||
a.setUseCaches(true);
|
||||
if (i != 0) {
|
||||
if (NetworkPolicy.isOfflineOnly(i)) {
|
||||
sb = "only-if-cached,max-age=2147483647";
|
||||
} else {
|
||||
StringBuilder sb2 = d.get();
|
||||
sb2.setLength(0);
|
||||
if (!NetworkPolicy.shouldReadFromDiskCache(i)) {
|
||||
sb2.append("no-cache");
|
||||
}
|
||||
if (!NetworkPolicy.shouldWriteToDiskCache(i)) {
|
||||
if (sb2.length() > 0) {
|
||||
sb2.append(',');
|
||||
}
|
||||
sb2.append("no-store");
|
||||
}
|
||||
sb = sb2.toString();
|
||||
}
|
||||
a.setRequestProperty("Cache-Control", sb);
|
||||
}
|
||||
int responseCode = a.getResponseCode();
|
||||
if (responseCode < 300) {
|
||||
return new Downloader.Response(a.getInputStream(), Utils.a(a.getHeaderField("X-Android-Response-Source")), a.getHeaderFieldInt("Content-Length", -1));
|
||||
}
|
||||
a.disconnect();
|
||||
throw new Downloader.ResponseException(responseCode + " " + a.getResponseMessage(), i, responseCode);
|
||||
}
|
||||
|
||||
private static void a(Context context) {
|
||||
if (b == null) {
|
||||
try {
|
||||
synchronized (c) {
|
||||
if (b == null) {
|
||||
b = ResponseCacheIcs.a(context);
|
||||
}
|
||||
}
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
342
sources/com/squareup/picasso/Utils.java
Normal file
342
sources/com/squareup/picasso/Utils.java
Normal file
@@ -0,0 +1,342 @@
|
||||
package com.squareup.picasso;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.Process;
|
||||
import android.os.StatFs;
|
||||
import android.provider.Settings;
|
||||
import android.util.Log;
|
||||
import com.ubt.jimu.base.util.FileUtil;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
final class Utils {
|
||||
static final StringBuilder a = new StringBuilder();
|
||||
|
||||
@TargetApi(11)
|
||||
private static class ActivityManagerHoneycomb {
|
||||
static int a(ActivityManager activityManager) {
|
||||
return activityManager.getLargeMemoryClass();
|
||||
}
|
||||
}
|
||||
|
||||
@TargetApi(12)
|
||||
private static class BitmapHoneycombMR1 {
|
||||
static int a(Bitmap bitmap) {
|
||||
return bitmap.getByteCount();
|
||||
}
|
||||
}
|
||||
|
||||
private static class OkHttpLoaderCreator {
|
||||
static Downloader a(Context context) {
|
||||
return new OkHttpDownloader(context);
|
||||
}
|
||||
}
|
||||
|
||||
private static class PicassoThread extends Thread {
|
||||
public PicassoThread(Runnable runnable) {
|
||||
super(runnable);
|
||||
}
|
||||
|
||||
@Override // java.lang.Thread, java.lang.Runnable
|
||||
public void run() {
|
||||
Process.setThreadPriority(10);
|
||||
super.run();
|
||||
}
|
||||
}
|
||||
|
||||
static class PicassoThreadFactory implements ThreadFactory {
|
||||
PicassoThreadFactory() {
|
||||
}
|
||||
|
||||
@Override // java.util.concurrent.ThreadFactory
|
||||
public Thread newThread(Runnable runnable) {
|
||||
return new PicassoThread(runnable);
|
||||
}
|
||||
}
|
||||
|
||||
static int a(Bitmap bitmap) {
|
||||
int a2 = Build.VERSION.SDK_INT >= 12 ? BitmapHoneycombMR1.a(bitmap) : bitmap.getRowBytes() * bitmap.getHeight();
|
||||
if (a2 >= 0) {
|
||||
return a2;
|
||||
}
|
||||
throw new IllegalStateException("Negative size: " + bitmap);
|
||||
}
|
||||
|
||||
static boolean b() {
|
||||
return Looper.getMainLooper().getThread() == Thread.currentThread();
|
||||
}
|
||||
|
||||
static Downloader c(Context context) {
|
||||
try {
|
||||
Class.forName("com.squareup.okhttp.OkHttpClient");
|
||||
return OkHttpLoaderCreator.a(context);
|
||||
} catch (ClassNotFoundException unused) {
|
||||
return new UrlConnectionDownloader(context);
|
||||
}
|
||||
}
|
||||
|
||||
static boolean d(Context context) {
|
||||
try {
|
||||
return Settings.System.getInt(context.getContentResolver(), "airplane_mode_on", 0) != 0;
|
||||
} catch (NullPointerException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static File b(Context context) {
|
||||
File file = new File(context.getApplicationContext().getCacheDir(), "picasso-cache");
|
||||
if (!file.exists()) {
|
||||
file.mkdirs();
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
static byte[] c(InputStream inputStream) throws IOException {
|
||||
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
|
||||
byte[] bArr = new byte[FileUtil.ZIP_BUFFER_SIZE];
|
||||
while (true) {
|
||||
int read = inputStream.read(bArr);
|
||||
if (-1 != read) {
|
||||
byteArrayOutputStream.write(bArr, 0, read);
|
||||
} else {
|
||||
return byteArrayOutputStream.toByteArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static <T> T a(T t, String str) {
|
||||
if (t != null) {
|
||||
return t;
|
||||
}
|
||||
throw new NullPointerException(str);
|
||||
}
|
||||
|
||||
static boolean b(Context context, String str) {
|
||||
return context.checkCallingOrSelfPermission(str) == 0;
|
||||
}
|
||||
|
||||
static void a() {
|
||||
if (!b()) {
|
||||
throw new IllegalStateException("Method call should happen from the main thread.");
|
||||
}
|
||||
}
|
||||
|
||||
static boolean b(InputStream inputStream) throws IOException {
|
||||
byte[] bArr = new byte[12];
|
||||
return inputStream.read(bArr, 0, 12) == 12 && "RIFF".equals(new String(bArr, 0, 4, "US-ASCII")) && "WEBP".equals(new String(bArr, 8, 4, "US-ASCII"));
|
||||
}
|
||||
|
||||
static String a(BitmapHunter bitmapHunter) {
|
||||
return a(bitmapHunter, "");
|
||||
}
|
||||
|
||||
static String a(BitmapHunter bitmapHunter, String str) {
|
||||
StringBuilder sb = new StringBuilder(str);
|
||||
Action a2 = bitmapHunter.a();
|
||||
if (a2 != null) {
|
||||
sb.append(a2.b.d());
|
||||
}
|
||||
List<Action> b = bitmapHunter.b();
|
||||
if (b != null) {
|
||||
int size = b.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (i > 0 || a2 != null) {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(b.get(i).b.d());
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static void a(String str, String str2, String str3) {
|
||||
a(str, str2, str3, "");
|
||||
}
|
||||
|
||||
static void a(String str, String str2, String str3, String str4) {
|
||||
Log.d("Picasso", String.format("%1$-11s %2$-12s %3$s %4$s", str, str2, str3, str4));
|
||||
}
|
||||
|
||||
static String a(Request request) {
|
||||
String a2 = a(request, a);
|
||||
a.setLength(0);
|
||||
return a2;
|
||||
}
|
||||
|
||||
static String a(Request request, StringBuilder sb) {
|
||||
String str = request.f;
|
||||
if (str != null) {
|
||||
sb.ensureCapacity(str.length() + 50);
|
||||
sb.append(request.f);
|
||||
} else {
|
||||
Uri uri = request.d;
|
||||
if (uri != null) {
|
||||
String uri2 = uri.toString();
|
||||
sb.ensureCapacity(uri2.length() + 50);
|
||||
sb.append(uri2);
|
||||
} else {
|
||||
sb.ensureCapacity(50);
|
||||
sb.append(request.e);
|
||||
}
|
||||
}
|
||||
sb.append('\n');
|
||||
if (request.m != 0.0f) {
|
||||
sb.append("rotation:");
|
||||
sb.append(request.m);
|
||||
if (request.p) {
|
||||
sb.append('@');
|
||||
sb.append(request.n);
|
||||
sb.append('x');
|
||||
sb.append(request.o);
|
||||
}
|
||||
sb.append('\n');
|
||||
}
|
||||
if (request.c()) {
|
||||
sb.append("resize:");
|
||||
sb.append(request.h);
|
||||
sb.append('x');
|
||||
sb.append(request.i);
|
||||
sb.append('\n');
|
||||
}
|
||||
if (request.j) {
|
||||
sb.append("centerCrop");
|
||||
sb.append('\n');
|
||||
} else if (request.k) {
|
||||
sb.append("centerInside");
|
||||
sb.append('\n');
|
||||
}
|
||||
List<Transformation> list = request.g;
|
||||
if (list != null) {
|
||||
int size = list.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
sb.append(request.g.get(i).a());
|
||||
sb.append('\n');
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
static void a(InputStream inputStream) {
|
||||
if (inputStream == null) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException unused) {
|
||||
}
|
||||
}
|
||||
|
||||
static boolean a(String str) {
|
||||
if (str == null) {
|
||||
return false;
|
||||
}
|
||||
String[] split = str.split(" ", 2);
|
||||
if ("CACHE".equals(split[0])) {
|
||||
return true;
|
||||
}
|
||||
if (split.length == 1) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
if ("CONDITIONAL_CACHE".equals(split[0])) {
|
||||
return Integer.parseInt(split[1]) == 304;
|
||||
}
|
||||
return false;
|
||||
} catch (NumberFormatException unused) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static long a(File file) {
|
||||
long j;
|
||||
try {
|
||||
StatFs statFs = new StatFs(file.getAbsolutePath());
|
||||
j = (statFs.getBlockCount() * statFs.getBlockSize()) / 50;
|
||||
} catch (IllegalArgumentException unused) {
|
||||
j = 5242880;
|
||||
}
|
||||
return Math.max(Math.min(j, 52428800L), 5242880L);
|
||||
}
|
||||
|
||||
static int a(Context context) {
|
||||
ActivityManager activityManager = (ActivityManager) a(context, "activity");
|
||||
boolean z = (context.getApplicationInfo().flags & 1048576) != 0;
|
||||
int memoryClass = activityManager.getMemoryClass();
|
||||
if (z && Build.VERSION.SDK_INT >= 11) {
|
||||
memoryClass = ActivityManagerHoneycomb.a(activityManager);
|
||||
}
|
||||
return (memoryClass * 1048576) / 7;
|
||||
}
|
||||
|
||||
static <T> T a(Context context, String str) {
|
||||
return (T) context.getSystemService(str);
|
||||
}
|
||||
|
||||
static int a(Resources resources, Request request) throws FileNotFoundException {
|
||||
Uri uri;
|
||||
if (request.e == 0 && (uri = request.d) != null) {
|
||||
String authority = uri.getAuthority();
|
||||
if (authority != null) {
|
||||
List<String> pathSegments = request.d.getPathSegments();
|
||||
if (pathSegments != null && !pathSegments.isEmpty()) {
|
||||
if (pathSegments.size() == 1) {
|
||||
try {
|
||||
return Integer.parseInt(pathSegments.get(0));
|
||||
} catch (NumberFormatException unused) {
|
||||
throw new FileNotFoundException("Last path segment is not a resource ID: " + request.d);
|
||||
}
|
||||
}
|
||||
if (pathSegments.size() == 2) {
|
||||
return resources.getIdentifier(pathSegments.get(1), pathSegments.get(0), authority);
|
||||
}
|
||||
throw new FileNotFoundException("More than two path segments: " + request.d);
|
||||
}
|
||||
throw new FileNotFoundException("No path segments: " + request.d);
|
||||
}
|
||||
throw new FileNotFoundException("No package provided: " + request.d);
|
||||
}
|
||||
return request.e;
|
||||
}
|
||||
|
||||
static Resources a(Context context, Request request) throws FileNotFoundException {
|
||||
Uri uri;
|
||||
if (request.e == 0 && (uri = request.d) != null) {
|
||||
String authority = uri.getAuthority();
|
||||
if (authority != null) {
|
||||
try {
|
||||
return context.getPackageManager().getResourcesForApplication(authority);
|
||||
} catch (PackageManager.NameNotFoundException unused) {
|
||||
throw new FileNotFoundException("Unable to obtain resources for package: " + request.d);
|
||||
}
|
||||
}
|
||||
throw new FileNotFoundException("No package provided: " + request.d);
|
||||
}
|
||||
return context.getResources();
|
||||
}
|
||||
|
||||
static void a(Looper looper) {
|
||||
Handler handler = new Handler(looper) { // from class: com.squareup.picasso.Utils.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
sendMessageDelayed(obtainMessage(), 1000L);
|
||||
}
|
||||
};
|
||||
handler.sendMessageDelayed(handler.obtainMessage(), 1000L);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user