what-the-bank/sources/com/google/android/gms/common/images/ImageManager.java

125 lines
4.5 KiB
Java

package com.google.android.gms.common.images;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.ParcelFileDescriptor;
import android.os.ResultReceiver;
import android.widget.ImageView;
import com.google.android.gms.common.internal.Asserts;
import com.google.android.gms.common.internal.Constants;
import com.google.android.gms.internal.base.zak;
import com.google.android.gms.internal.base.zap;
import com.google.android.gms.internal.base.zaq;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ExecutorService;
/* loaded from: classes.dex */
public final class ImageManager {
private static final Object zaa = new Object();
private static HashSet<Uri> zab = new HashSet<>();
private static ImageManager zac;
private final Context zad;
private final Handler zae = new zaq(Looper.getMainLooper());
private final ExecutorService zaf = zap.zaa().zab(4, 2);
private final zak zag = new zak();
private final Map<zag, ImageReceiver> zah = new HashMap();
private final Map<Uri, ImageReceiver> zai = new HashMap();
private final Map<Uri, Long> zaj = new HashMap();
/* loaded from: classes.dex */
public interface OnImageLoadedListener {
void onImageLoaded(Uri uri, Drawable drawable, boolean z);
}
private ImageManager(Context context, boolean z) {
this.zad = context.getApplicationContext();
}
public static ImageManager create(Context context) {
if (zac == null) {
zac = new ImageManager(context, false);
}
return zac;
}
public final void loadImage(ImageView imageView, int i) {
zaj(new zae(imageView, i));
}
public final void zaj(zag zagVar) {
Asserts.checkMainThread("ImageManager.loadImage() must be called in the main thread");
new zab(this, zagVar).run();
}
public final void loadImage(ImageView imageView, Uri uri) {
zaj(new zae(imageView, uri));
}
public final void loadImage(ImageView imageView, Uri uri, int i) {
zae zaeVar = new zae(imageView, uri);
zaeVar.zab = i;
zaj(zaeVar);
}
public final void loadImage(OnImageLoadedListener onImageLoadedListener, Uri uri) {
zaj(new zaf(onImageLoadedListener, uri));
}
public final void loadImage(OnImageLoadedListener onImageLoadedListener, Uri uri, int i) {
zaf zafVar = new zaf(onImageLoadedListener, uri);
zafVar.zab = i;
zaj(zafVar);
}
/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes.dex */
public final class ImageReceiver extends ResultReceiver {
final ImageManager zaa;
private final Uri zab;
private final ArrayList<zag> zac;
/* JADX INFO: Access modifiers changed from: package-private */
/* JADX WARN: 'super' call moved to the top of the method (can break code semantics) */
public ImageReceiver(ImageManager imageManager, Uri uri) {
super(new zaq(Looper.getMainLooper()));
this.zaa = imageManager;
this.zab = uri;
this.zac = new ArrayList<>();
}
@Override // android.os.ResultReceiver
public final void onReceiveResult(int i, Bundle bundle) {
ParcelFileDescriptor parcelFileDescriptor = (ParcelFileDescriptor) bundle.getParcelable("com.google.android.gms.extra.fileDescriptor");
ImageManager imageManager = this.zaa;
imageManager.zaf.execute(new zaa(imageManager, this.zab, parcelFileDescriptor));
}
public final void zab(zag zagVar) {
Asserts.checkMainThread("ImageReceiver.addImageRequest() must be called in the main thread");
this.zac.add(zagVar);
}
public final void zac(zag zagVar) {
Asserts.checkMainThread("ImageReceiver.removeImageRequest() must be called in the main thread");
this.zac.remove(zagVar);
}
public final void zad() {
Intent intent = new Intent(Constants.ACTION_LOAD_IMAGE);
intent.setPackage("com.google.android.gms");
intent.putExtra(Constants.EXTRA_URI, this.zab);
intent.putExtra(Constants.EXTRA_RESULT_RECEIVER, this);
intent.putExtra(Constants.EXTRA_PRIORITY, 3);
this.zaa.zad.sendBroadcast(intent);
}
}
}