380 lines
16 KiB
Java
380 lines
16 KiB
Java
package c.b.a.d;
|
|
|
|
import android.animation.Animator;
|
|
import android.animation.AnimatorInflater;
|
|
import android.animation.AnimatorSet;
|
|
import android.content.AsyncQueryHandler;
|
|
import android.content.ContentResolver;
|
|
import android.content.Context;
|
|
import android.database.Cursor;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.net.Uri;
|
|
import android.os.Build;
|
|
import android.provider.MediaStore;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.TextView;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.b.a.e.c;
|
|
import com.discord.utilities.time.TimeUtils;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import com.lytefast.flexinput.R;
|
|
import com.lytefast.flexinput.model.Media;
|
|
import com.lytefast.flexinput.utils.SelectionCoordinator;
|
|
import d0.z.d.m;
|
|
import d0.z.d.o;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
/* compiled from: MediaCursorAdapter.kt */
|
|
public final class i extends RecyclerView.Adapter<a> {
|
|
public final SelectionCoordinator<?, Media> a;
|
|
public Cursor b;
|
|
|
|
/* renamed from: c reason: collision with root package name */
|
|
public int f254c;
|
|
public int d;
|
|
public int e;
|
|
public int f;
|
|
public Integer g;
|
|
public final int h;
|
|
public final int i;
|
|
|
|
/* compiled from: MediaCursorAdapter.kt */
|
|
public final class a extends j implements View.OnClickListener {
|
|
public Media o;
|
|
public final AnimatorSet p;
|
|
public final AnimatorSet q;
|
|
public final c r;
|
|
|
|
/* renamed from: s reason: collision with root package name */
|
|
public final /* synthetic */ i f255s;
|
|
|
|
/* compiled from: MediaCursorAdapter.kt */
|
|
/* renamed from: c.b.a.d.i$a$a reason: collision with other inner class name */
|
|
public static final class C0052a extends o implements Function1<AnimatorSet, Unit> {
|
|
public final /* synthetic */ boolean $isAnimationRequested;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public C0052a(boolean z2) {
|
|
super(1);
|
|
this.$isAnimationRequested = z2;
|
|
}
|
|
|
|
public final void a(AnimatorSet animatorSet) {
|
|
m.checkNotNullParameter(animatorSet, "animation");
|
|
animatorSet.start();
|
|
if (!this.$isAnimationRequested) {
|
|
animatorSet.end();
|
|
}
|
|
}
|
|
|
|
/* 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 /* bridge */ /* synthetic */ Unit invoke(AnimatorSet animatorSet) {
|
|
a(animatorSet);
|
|
return Unit.a;
|
|
}
|
|
}
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public a(i iVar, c cVar) {
|
|
super(r4);
|
|
m.checkNotNullParameter(cVar, "binding");
|
|
this.f255s = iVar;
|
|
FrameLayout frameLayout = cVar.a;
|
|
m.checkNotNullExpressionValue(frameLayout, "binding.root");
|
|
this.r = cVar;
|
|
cVar.a.setOnClickListener(this);
|
|
FrameLayout frameLayout2 = cVar.a;
|
|
m.checkNotNullExpressionValue(frameLayout2, "binding.root");
|
|
Animator loadAnimator = AnimatorInflater.loadAnimator(frameLayout2.getContext(), R.a.selection_shrink);
|
|
Objects.requireNonNull(loadAnimator, "null cannot be cast to non-null type android.animation.AnimatorSet");
|
|
AnimatorSet animatorSet = (AnimatorSet) loadAnimator;
|
|
this.p = animatorSet;
|
|
animatorSet.setTarget(cVar.b);
|
|
FrameLayout frameLayout3 = cVar.a;
|
|
m.checkNotNullExpressionValue(frameLayout3, "binding.root");
|
|
Animator loadAnimator2 = AnimatorInflater.loadAnimator(frameLayout3.getContext(), R.a.selection_grow);
|
|
Objects.requireNonNull(loadAnimator2, "null cannot be cast to non-null type android.animation.AnimatorSet");
|
|
AnimatorSet animatorSet2 = (AnimatorSet) loadAnimator2;
|
|
this.q = animatorSet2;
|
|
animatorSet2.setTarget(cVar.b);
|
|
}
|
|
|
|
@Override // c.b.a.d.j
|
|
public SimpleDraweeView a() {
|
|
SimpleDraweeView simpleDraweeView = this.r.f258c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.contentIv");
|
|
return simpleDraweeView;
|
|
}
|
|
|
|
public final void d(boolean z2, boolean z3) {
|
|
FrameLayout frameLayout = this.r.a;
|
|
m.checkNotNullExpressionValue(frameLayout, "binding.root");
|
|
frameLayout.setSelected(z2);
|
|
C0052a aVar = new C0052a(z3);
|
|
if (z2) {
|
|
SimpleDraweeView simpleDraweeView = this.r.d;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.itemCheckIndicator");
|
|
simpleDraweeView.setVisibility(0);
|
|
FrameLayout frameLayout2 = this.r.b;
|
|
m.checkNotNullExpressionValue(frameLayout2, "binding.contentContainer");
|
|
if (frameLayout2.getScaleX() == 1.0f) {
|
|
aVar.a(this.p);
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
SimpleDraweeView simpleDraweeView2 = this.r.d;
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.itemCheckIndicator");
|
|
simpleDraweeView2.setVisibility(8);
|
|
FrameLayout frameLayout3 = this.r.b;
|
|
m.checkNotNullExpressionValue(frameLayout3, "binding.contentContainer");
|
|
if (frameLayout3.getScaleX() != 1.0f) {
|
|
aVar.a(this.q);
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
m.checkNotNullParameter(view, "v");
|
|
SelectionCoordinator<?, Media> selectionCoordinator = this.f255s.a;
|
|
Media media = this.o;
|
|
int adapterPosition = getAdapterPosition();
|
|
Objects.requireNonNull(selectionCoordinator);
|
|
if (media != null && !selectionCoordinator.d(media)) {
|
|
selectionCoordinator.c(media, adapterPosition);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: MediaCursorAdapter.kt */
|
|
public static final class b extends AsyncQueryHandler {
|
|
public final /* synthetic */ i a;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public b(i iVar, ContentResolver contentResolver) {
|
|
super(contentResolver);
|
|
this.a = iVar;
|
|
}
|
|
|
|
@Override // android.content.AsyncQueryHandler
|
|
public void onQueryComplete(int i, Object obj, Cursor cursor) {
|
|
m.checkNotNullParameter(obj, "cookie");
|
|
if (cursor != null) {
|
|
i iVar = this.a;
|
|
iVar.f254c = cursor.getColumnIndex("_id");
|
|
iVar.d = cursor.getColumnIndex("_data");
|
|
iVar.e = cursor.getColumnIndex("_display_name");
|
|
iVar.f = cursor.getColumnIndex("media_type");
|
|
if (Build.VERSION.SDK_INT >= 29) {
|
|
iVar.g = Integer.valueOf(cursor.getColumnIndex("duration"));
|
|
}
|
|
iVar.b = cursor;
|
|
this.a.notifyDataSetChanged();
|
|
}
|
|
}
|
|
}
|
|
|
|
public i(SelectionCoordinator<?, Media> selectionCoordinator, int i, int i2) {
|
|
m.checkNotNullParameter(selectionCoordinator, "selectionCoordinator");
|
|
this.h = i;
|
|
this.i = i2;
|
|
Objects.requireNonNull(selectionCoordinator);
|
|
m.checkNotNullParameter(this, "adapter");
|
|
selectionCoordinator.a = this;
|
|
this.a = selectionCoordinator;
|
|
setHasStableIds(true);
|
|
}
|
|
|
|
public final Media a(int i) {
|
|
String str;
|
|
Cursor cursor = this.b;
|
|
Media media = null;
|
|
r1 = null;
|
|
Long l = null;
|
|
if (cursor != null) {
|
|
cursor.moveToPosition(i);
|
|
long j = cursor.getLong(this.f254c);
|
|
boolean z2 = cursor.getInt(this.f) == 3;
|
|
Uri withAppendedPath = z2 ? Uri.withAppendedPath(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, String.valueOf(j)) : Uri.withAppendedPath(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, String.valueOf(j));
|
|
String str2 = z2 ? "vid" : "img";
|
|
Integer num = this.g;
|
|
if (z2 && num != null) {
|
|
l = Long.valueOf(cursor.getLong(num.intValue()));
|
|
}
|
|
m.checkNotNullExpressionValue(withAppendedPath, "fileUri");
|
|
String string = cursor.getString(this.e);
|
|
if (string != null) {
|
|
str = string;
|
|
} else {
|
|
str = str2 + '-' + j;
|
|
}
|
|
media = new Media(j, withAppendedPath, str, cursor.getString(this.d), z2, l);
|
|
}
|
|
return media;
|
|
}
|
|
|
|
public final void b(ContentResolver contentResolver) {
|
|
m.checkNotNullParameter(contentResolver, "contentResolver");
|
|
int i = Build.VERSION.SDK_INT;
|
|
new b(this, contentResolver).startQuery(1, this, MediaStore.Files.getContentUri("external"), i >= 29 ? new String[]{"_id", "_data", "_display_name", "media_type", "duration"} : new String[]{"_id", "_data", "_display_name", "media_type"}, i >= 29 ? "media_type = 1 OR media_type = 3" : "media_type = 1", null, "date_added DESC");
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public int getItemCount() {
|
|
Cursor cursor = this.b;
|
|
if (cursor != null) {
|
|
return cursor.getCount();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public long getItemId(int i) {
|
|
Media a2 = a(i);
|
|
if (a2 != null) {
|
|
return a2.getId();
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public void onAttachedToRecyclerView(RecyclerView recyclerView) {
|
|
m.checkNotNullParameter(recyclerView, "recyclerView");
|
|
super.onAttachedToRecyclerView(recyclerView);
|
|
Context context = recyclerView.getContext();
|
|
m.checkNotNullExpressionValue(context, "recyclerView.context");
|
|
ContentResolver contentResolver = context.getContentResolver();
|
|
m.checkNotNullExpressionValue(contentResolver, "recyclerView.context.contentResolver");
|
|
b(contentResolver);
|
|
}
|
|
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [androidx.recyclerview.widget.RecyclerView$ViewHolder, int] */
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public void onBindViewHolder(a aVar, int i) {
|
|
Long l;
|
|
a aVar2 = aVar;
|
|
m.checkNotNullParameter(aVar2, "holder");
|
|
Media a2 = a(i);
|
|
aVar2.o = a2;
|
|
FrameLayout frameLayout = aVar2.r.a;
|
|
m.checkNotNullExpressionValue(frameLayout, "binding.root");
|
|
Context context = frameLayout.getContext();
|
|
int i2 = 0;
|
|
if (a2 != null) {
|
|
aVar2.d(aVar2.f255s.a.a(a2, aVar2.getAdapterPosition()), false);
|
|
}
|
|
aVar2.c(a2, Integer.valueOf(aVar2.f255s.h), Integer.valueOf(aVar2.f255s.i));
|
|
boolean z2 = true;
|
|
if (a2 == null || !a2.i) {
|
|
z2 = false;
|
|
}
|
|
TextView textView = aVar2.r.e;
|
|
m.checkNotNullExpressionValue(textView, "binding.itemVideoIndicator");
|
|
if (!z2) {
|
|
i2 = 8;
|
|
}
|
|
textView.setVisibility(i2);
|
|
if (z2) {
|
|
TextView textView2 = aVar2.r.e;
|
|
m.checkNotNullExpressionValue(textView2, "binding.itemVideoIndicator");
|
|
Drawable background = textView2.getBackground();
|
|
m.checkNotNullExpressionValue(background, "binding.itemVideoIndicator.background");
|
|
background.setAlpha(127);
|
|
long longValue = (a2 == null || (l = a2.j) == null) ? 0 : l.longValue();
|
|
TextView textView3 = aVar2.r.e;
|
|
m.checkNotNullExpressionValue(textView3, "binding.itemVideoIndicator");
|
|
textView3.setText(longValue > 0 ? TimeUtils.toFriendlyStringSimple$default(TimeUtils.INSTANCE, longValue, null, null, 6, null) : context.getString(R.g.video));
|
|
}
|
|
SimpleDraweeView simpleDraweeView = aVar2.r.f258c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.contentIv");
|
|
simpleDraweeView.setContentDescription(context.getString(z2 ? R.g.video : R.g.image));
|
|
}
|
|
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [androidx.recyclerview.widget.RecyclerView$ViewHolder, int, java.util.List] */
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public void onBindViewHolder(a aVar, int i, List list) {
|
|
SelectionCoordinator.a aVar2;
|
|
Object obj;
|
|
a aVar3 = aVar;
|
|
m.checkNotNullParameter(aVar3, "holder");
|
|
m.checkNotNullParameter(list, "payloads");
|
|
Iterator it = list.iterator();
|
|
while (true) {
|
|
aVar2 = null;
|
|
if (!it.hasNext()) {
|
|
obj = null;
|
|
break;
|
|
}
|
|
obj = it.next();
|
|
if (obj instanceof SelectionCoordinator.a) {
|
|
break;
|
|
}
|
|
}
|
|
if (obj != null) {
|
|
if (obj instanceof SelectionCoordinator.a) {
|
|
aVar2 = obj;
|
|
}
|
|
SelectionCoordinator.a aVar4 = aVar2;
|
|
if (aVar4 != null) {
|
|
aVar3.d(aVar4.b, true);
|
|
return;
|
|
}
|
|
}
|
|
super.onBindViewHolder(aVar3, i, list);
|
|
}
|
|
|
|
/* Return type fixed from 'androidx.recyclerview.widget.RecyclerView$ViewHolder' to match base method */
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public a onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
m.checkNotNullParameter(viewGroup, "parent");
|
|
View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.f.view_grid_image, viewGroup, false);
|
|
int i2 = R.e.content_container;
|
|
FrameLayout frameLayout = (FrameLayout) inflate.findViewById(i2);
|
|
if (frameLayout != null) {
|
|
i2 = R.e.content_iv;
|
|
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) inflate.findViewById(i2);
|
|
if (simpleDraweeView != null) {
|
|
i2 = R.e.item_check_indicator;
|
|
SimpleDraweeView simpleDraweeView2 = (SimpleDraweeView) inflate.findViewById(i2);
|
|
if (simpleDraweeView2 != null) {
|
|
i2 = R.e.item_video_indicator;
|
|
TextView textView = (TextView) inflate.findViewById(i2);
|
|
if (textView != null) {
|
|
c cVar = new c((FrameLayout) inflate, frameLayout, simpleDraweeView, simpleDraweeView2, textView);
|
|
m.checkNotNullExpressionValue(cVar, "ViewGridImageBinding.inf….context), parent, false)");
|
|
return new a(this, cVar);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2)));
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public void onDetachedFromRecyclerView(RecyclerView recyclerView) {
|
|
m.checkNotNullParameter(recyclerView, "recyclerView");
|
|
Cursor cursor = this.b;
|
|
if (cursor != null) {
|
|
cursor.close();
|
|
}
|
|
super.onDetachedFromRecyclerView(recyclerView);
|
|
}
|
|
|
|
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [androidx.recyclerview.widget.RecyclerView$ViewHolder] */
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public void onViewRecycled(a aVar) {
|
|
a aVar2 = aVar;
|
|
m.checkNotNullParameter(aVar2, "holder");
|
|
super.onViewRecycled(aVar2);
|
|
aVar2.b();
|
|
}
|
|
}
|