219 lines
8.1 KiB
Java
219 lines
8.1 KiB
Java
package c.b.a.d;
|
|
|
|
import android.content.ContentResolver;
|
|
import android.content.ContentUris;
|
|
import android.content.Context;
|
|
import android.database.Cursor;
|
|
import android.graphics.Bitmap;
|
|
import android.graphics.drawable.BitmapDrawable;
|
|
import android.graphics.drawable.ColorDrawable;
|
|
import android.net.Uri;
|
|
import android.os.AsyncTask;
|
|
import android.os.Build;
|
|
import android.os.CancellationSignal;
|
|
import android.provider.MediaStore;
|
|
import android.view.View;
|
|
import androidx.annotation.RequiresApi;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.f.g.e.r;
|
|
import c.f.g.e.s;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.facebook.drawee.drawable.ScalingUtils$ScaleType;
|
|
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import com.lytefast.flexinput.R;
|
|
import com.lytefast.flexinput.model.Media;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlinx.coroutines.CoroutineDispatcher;
|
|
import kotlinx.coroutines.Job;
|
|
import s.a.a.n;
|
|
import s.a.j0;
|
|
import s.a.w0;
|
|
/* compiled from: ThumbnailViewHolder.kt */
|
|
public abstract class j extends RecyclerView.ViewHolder {
|
|
public static int i;
|
|
public static int j;
|
|
public static ColorDrawable k;
|
|
public static final a l = new a(null);
|
|
public b m;
|
|
public c n;
|
|
|
|
/* compiled from: ThumbnailViewHolder.kt */
|
|
public static final class a {
|
|
public a(DefaultConstructorMarker defaultConstructorMarker) {
|
|
}
|
|
|
|
public static final boolean a(a aVar) {
|
|
return Build.VERSION.SDK_INT >= 29;
|
|
}
|
|
}
|
|
|
|
/* compiled from: ThumbnailViewHolder.kt */
|
|
@RequiresApi(29)
|
|
public static final class b {
|
|
public Job a;
|
|
public CancellationSignal b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public Bitmap f244c;
|
|
public final ContentResolver d;
|
|
|
|
public b(ContentResolver contentResolver) {
|
|
m.checkNotNullParameter(contentResolver, "contentResolver");
|
|
this.d = contentResolver;
|
|
}
|
|
|
|
public final void a() {
|
|
if (a.a(j.l)) {
|
|
Job job = this.a;
|
|
if (job != null) {
|
|
c.q.a.k.a.k(job, null, 1, null);
|
|
}
|
|
CancellationSignal cancellationSignal = this.b;
|
|
if (cancellationSignal != null) {
|
|
cancellationSignal.cancel();
|
|
}
|
|
}
|
|
Bitmap bitmap = this.f244c;
|
|
if (bitmap != null) {
|
|
bitmap.recycle();
|
|
}
|
|
this.f244c = null;
|
|
}
|
|
}
|
|
|
|
/* compiled from: ThumbnailViewHolder.kt */
|
|
public static final class c {
|
|
public final ContentResolver a;
|
|
|
|
public c(ContentResolver contentResolver) {
|
|
m.checkNotNullParameter(contentResolver, "contentResolver");
|
|
this.a = contentResolver;
|
|
}
|
|
}
|
|
|
|
/* compiled from: ThumbnailViewHolder.kt */
|
|
public static final class d extends o implements Function1<Bitmap, Unit> {
|
|
public final /* synthetic */ j this$0;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public d(j jVar) {
|
|
super(1);
|
|
this.this$0 = jVar;
|
|
}
|
|
|
|
/* Return type fixed from 'java.lang.Object' to match base method */
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
|
|
@Override // kotlin.jvm.functions.Function1
|
|
public Unit invoke(Bitmap bitmap) {
|
|
BitmapDrawable bitmapDrawable = new BitmapDrawable(this.this$0.a().getResources(), bitmap);
|
|
GenericDraweeHierarchy hierarchy = this.this$0.a().getHierarchy();
|
|
ScalingUtils$ScaleType scalingUtils$ScaleType = ScalingUtils$ScaleType.a;
|
|
ScalingUtils$ScaleType scalingUtils$ScaleType2 = s.l;
|
|
hierarchy.o(1, bitmapDrawable);
|
|
hierarchy.l(1).r(scalingUtils$ScaleType2);
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public j(View view) {
|
|
super(view);
|
|
m.checkNotNullParameter(view, "itemView");
|
|
if (Build.VERSION.SDK_INT >= 29) {
|
|
Context context = view.getContext();
|
|
m.checkNotNullExpressionValue(context, "itemView.context");
|
|
ContentResolver contentResolver = context.getContentResolver();
|
|
m.checkNotNullExpressionValue(contentResolver, "itemView.context.contentResolver");
|
|
this.m = new b(contentResolver);
|
|
return;
|
|
}
|
|
Context context2 = view.getContext();
|
|
m.checkNotNullExpressionValue(context2, "itemView.context");
|
|
ContentResolver contentResolver2 = context2.getContentResolver();
|
|
m.checkNotNullExpressionValue(contentResolver2, "itemView.context.contentResolver");
|
|
this.n = new c(contentResolver2);
|
|
}
|
|
|
|
public abstract SimpleDraweeView a();
|
|
|
|
public final void b() {
|
|
b bVar;
|
|
if ((Build.VERSION.SDK_INT >= 29) && (bVar = this.m) != null) {
|
|
bVar.a();
|
|
}
|
|
}
|
|
|
|
/* JADX WARNING: Code restructure failed: missing block: B:30:0x00d0, code lost:
|
|
r13 = move-exception;
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:31:0x00d1, code lost:
|
|
d0.y.b.closeFinally(r0, r12);
|
|
*/
|
|
/* JADX WARNING: Code restructure failed: missing block: B:32:0x00d4, code lost:
|
|
throw r13;
|
|
*/
|
|
public final void c(Media media, Integer num, Integer num2) {
|
|
if (k == null) {
|
|
View view = this.itemView;
|
|
m.checkNotNullExpressionValue(view, "itemView");
|
|
k = new ColorDrawable(ColorCompat.getThemedColor(view, R.b.flexInputDialogBackground));
|
|
}
|
|
if (num != null) {
|
|
i = num.intValue();
|
|
}
|
|
if (num2 != null) {
|
|
j = num2.intValue();
|
|
}
|
|
if (media != null) {
|
|
Uri uri = null;
|
|
if (Build.VERSION.SDK_INT >= 29) {
|
|
GenericDraweeHierarchy hierarchy = a().getHierarchy();
|
|
ColorDrawable colorDrawable = k;
|
|
ScalingUtils$ScaleType scalingUtils$ScaleType = ScalingUtils$ScaleType.a;
|
|
ScalingUtils$ScaleType scalingUtils$ScaleType2 = r.l;
|
|
hierarchy.o(1, colorDrawable);
|
|
hierarchy.l(1).r(scalingUtils$ScaleType2);
|
|
b bVar = this.m;
|
|
if (bVar != null) {
|
|
Uri uri2 = media.getUri();
|
|
d dVar = new d(this);
|
|
m.checkNotNullParameter(uri2, "uri");
|
|
m.checkNotNullParameter(dVar, "onGenerate");
|
|
bVar.a();
|
|
w0 w0Var = w0.i;
|
|
CoroutineDispatcher coroutineDispatcher = j0.a;
|
|
bVar.a = c.q.a.k.a.G(w0Var, n.b, null, new k(bVar, uri2, dVar, null), 2, null);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
c cVar = this.n;
|
|
if (cVar != null) {
|
|
long id2 = media.getId();
|
|
Uri uri3 = media.getUri();
|
|
m.checkNotNullParameter(uri3, "uri");
|
|
n nVar = new n(id2);
|
|
Cursor query = cVar.a.query(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, new String[]{"_id"}, "image_id = ? AND KIND = ?", new String[]{String.valueOf(id2), String.valueOf(1)}, null);
|
|
if (query == null || !query.moveToFirst()) {
|
|
ContentResolver contentResolver = cVar.a;
|
|
m.checkNotNullParameter(contentResolver, "contentResolver");
|
|
AsyncTask.execute(new m(nVar, contentResolver));
|
|
if (query != null) {
|
|
query.close();
|
|
}
|
|
} else {
|
|
uri3 = ContentUris.withAppendedId(MediaStore.Images.Thumbnails.EXTERNAL_CONTENT_URI, query.getLong(0));
|
|
d0.y.b.closeFinally(query, null);
|
|
}
|
|
uri = uri3;
|
|
}
|
|
a().setImageURI(uri, a().getContext());
|
|
}
|
|
}
|
|
}
|