2021-06-27 20:44:35 +00:00
|
|
|
package com.lytefast.flexinput.adapters;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
import c.b.a.d.j;
|
|
|
|
import c.b.a.e.b;
|
|
|
|
import c.f.g.a.a.d;
|
|
|
|
import c.f.j.d.e;
|
|
|
|
import c.f.j.d.f;
|
|
|
|
import com.discord.utilities.drawable.DrawableCompat;
|
|
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
|
|
import com.facebook.imagepipeline.request.ImageRequestBuilder;
|
|
|
|
import com.lytefast.flexinput.R;
|
|
|
|
import com.lytefast.flexinput.model.Attachment;
|
|
|
|
import com.lytefast.flexinput.model.Media;
|
|
|
|
import com.lytefast.flexinput.utils.SelectionAggregator;
|
|
|
|
import d0.z.d.m;
|
|
|
|
import java.util.Objects;
|
|
|
|
import kotlin.jvm.functions.Function1;
|
|
|
|
/* compiled from: AttachmentPreviewAdapter.kt */
|
|
|
|
public final class AttachmentPreviewAdapter<T extends Attachment<? extends Object>> extends RecyclerView.Adapter<AttachmentPreviewAdapter<T>.a> {
|
|
|
|
public final SelectionAggregator<T> a;
|
|
|
|
|
|
|
|
/* compiled from: AttachmentPreviewAdapter.kt */
|
|
|
|
public final class a extends j {
|
|
|
|
public final b o;
|
|
|
|
public final /* synthetic */ AttachmentPreviewAdapter p;
|
|
|
|
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
|
|
public a(AttachmentPreviewAdapter attachmentPreviewAdapter, b bVar) {
|
|
|
|
super(r5);
|
|
|
|
m.checkNotNullParameter(bVar, "binding");
|
|
|
|
this.p = attachmentPreviewAdapter;
|
|
|
|
SimpleDraweeView simpleDraweeView = bVar.a;
|
|
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.root");
|
|
|
|
this.o = bVar;
|
|
|
|
Context context = a().getContext();
|
|
|
|
m.checkNotNullExpressionValue(context, "imageView.context");
|
2021-07-03 23:36:06 +00:00
|
|
|
a().getHierarchy().p(DrawableCompat.getThemedDrawableRes$default(context, R.b.ic_flex_input_file, 0, 2, (Object) null));
|
2021-06-27 20:44:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // c.b.a.d.j
|
|
|
|
public SimpleDraweeView a() {
|
|
|
|
SimpleDraweeView simpleDraweeView = this.o.a;
|
|
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.root");
|
|
|
|
return simpleDraweeView;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public AttachmentPreviewAdapter() {
|
|
|
|
this(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public AttachmentPreviewAdapter(Function1<? super AttachmentPreviewAdapter<T>, ? extends SelectionAggregator<T>> function1) {
|
|
|
|
SelectionAggregator<T> selectionAggregator;
|
|
|
|
this.a = (function1 == null || (selectionAggregator = (SelectionAggregator) function1.invoke(this)) == null) ? new SelectionAggregator<>(this, null, null, null, 14, null) : selectionAggregator;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
|
|
public int getItemCount() {
|
|
|
|
return this.a.getSize();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* JADX WARNING: Unknown variable types count: 1 */
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
|
|
public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
|
|
|
|
a aVar = (a) viewHolder;
|
|
|
|
m.checkNotNullParameter(aVar, "holder");
|
|
|
|
T t = this.a.get(i);
|
|
|
|
Objects.requireNonNull(aVar);
|
|
|
|
m.checkNotNullParameter(t, "item");
|
|
|
|
if (t instanceof Media) {
|
2021-06-27 20:53:42 +00:00
|
|
|
aVar.a().setController(null);
|
2021-06-27 20:44:35 +00:00
|
|
|
aVar.c((Media) t, null, null);
|
|
|
|
} else {
|
|
|
|
int i2 = aVar.a().getLayoutParams().height;
|
|
|
|
ImageRequestBuilder b = ImageRequestBuilder.b(t.getUri());
|
|
|
|
b.d = f.a;
|
2021-07-13 20:23:20 +00:00
|
|
|
b.f2196c = new e(i2, i2);
|
2021-06-27 20:44:35 +00:00
|
|
|
d a2 = c.f.g.a.a.b.a();
|
|
|
|
a2.n = aVar.a().getController();
|
|
|
|
a2.m = true;
|
|
|
|
a2.h = b.a();
|
|
|
|
aVar.a().setController(a2.a());
|
|
|
|
}
|
|
|
|
aVar.o.a.setOnClickListener(new c.b.a.d.e(aVar, t));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
|
|
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
|
|
m.checkNotNullParameter(viewGroup, "parent");
|
|
|
|
View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.f.view_attachment_preview_item, viewGroup, false);
|
|
|
|
Objects.requireNonNull(inflate, "rootView");
|
|
|
|
b bVar = new b((SimpleDraweeView) inflate);
|
|
|
|
m.checkNotNullExpressionValue(bVar, "ViewAttachmentPreviewIte….context), parent, false)");
|
|
|
|
return new a(this, bVar);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
|
|
public void onViewRecycled(RecyclerView.ViewHolder viewHolder) {
|
|
|
|
a aVar = (a) viewHolder;
|
|
|
|
m.checkNotNullParameter(aVar, "holder");
|
|
|
|
super.onViewRecycled(aVar);
|
|
|
|
aVar.b();
|
|
|
|
}
|
|
|
|
}
|