176 lines
9.4 KiB
Java
176 lines
9.4 KiB
Java
package com.discord.widgets.chat.input.gifpicker;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.cardview.widget.CardView;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
|
import c.a.i.o;
|
|
import c.a.l.b;
|
|
import com.discord.databinding.GifItemViewBinding;
|
|
import com.discord.databinding.GifSuggestedTermViewBinding;
|
|
import com.discord.models.gifpicker.dto.ModelGif;
|
|
import com.discord.utilities.dimen.DimenUtils;
|
|
import com.discord.utilities.drawable.DrawableCompat;
|
|
import com.discord.utilities.images.MGImages;
|
|
import com.discord.widgets.chat.input.gifpicker.GifAdapterItem;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import com.google.android.flexbox.FlexboxLayout;
|
|
import d0.z.d.m;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: GifViewHolder.kt */
|
|
public abstract class GifViewHolder extends RecyclerView.ViewHolder {
|
|
|
|
/* compiled from: GifViewHolder.kt */
|
|
public static final class Gif extends GifViewHolder {
|
|
private final GifItemViewBinding binding;
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public Gif(GifItemViewBinding gifItemViewBinding) {
|
|
super(r0, null);
|
|
m.checkNotNullParameter(gifItemViewBinding, "binding");
|
|
CardView cardView = gifItemViewBinding.a;
|
|
m.checkNotNullExpressionValue(cardView, "binding.root");
|
|
this.binding = gifItemViewBinding;
|
|
this.itemView.setOnTouchListener(new ViewScalingOnTouchListener(0.9f));
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.chat.input.gifpicker.GifViewHolder$Gif */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
public static /* synthetic */ void configure$default(Gif gif, GifAdapterItem.GifItem gifItem, int i, Function1 function1, int i2, Object obj) {
|
|
if ((i2 & 4) != 0) {
|
|
function1 = null;
|
|
}
|
|
gif.configure(gifItem, i, function1);
|
|
}
|
|
|
|
private final void setGifImage(ModelGif modelGif) {
|
|
String gifImageUrl = modelGif.getGifImageUrl();
|
|
SimpleDraweeView simpleDraweeView = this.binding.b;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.gifItemImage");
|
|
MGImages.setImage$default(simpleDraweeView, d0.t.m.listOf(gifImageUrl), 0, 0, false, null, null, null, 252, null);
|
|
}
|
|
|
|
public final void configure(GifAdapterItem.GifItem gifItem, int i, Function1<? super GifAdapterItem.GifItem, Unit> function1) {
|
|
m.checkNotNullParameter(gifItem, "gifItem");
|
|
ModelGif gif = gifItem.getGif();
|
|
float height = ((float) i) * (((float) gif.getHeight()) / ((float) gif.getWidth()));
|
|
CardView cardView = this.binding.a;
|
|
m.checkNotNullExpressionValue(cardView, "binding.root");
|
|
cardView.getLayoutParams().height = (int) height;
|
|
setGifImage(gif);
|
|
this.binding.a.setOnClickListener(new GifViewHolder$Gif$configure$1(function1, gifItem));
|
|
}
|
|
}
|
|
|
|
/* compiled from: GifViewHolder.kt */
|
|
public static final class SuggestedTerms extends GifViewHolder {
|
|
private final GifSuggestedTermViewBinding binding;
|
|
|
|
/* JADX WARNING: Illegal instructions before constructor call */
|
|
public SuggestedTerms(GifSuggestedTermViewBinding gifSuggestedTermViewBinding) {
|
|
super(r0, null);
|
|
m.checkNotNullParameter(gifSuggestedTermViewBinding, "binding");
|
|
LinearLayout linearLayout = gifSuggestedTermViewBinding.a;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.root");
|
|
this.binding = gifSuggestedTermViewBinding;
|
|
}
|
|
|
|
private final void configureSearchTerms(GifAdapterItem.SuggestedTermsItem suggestedTermsItem, Function1<? super String, Unit> function1, int i) {
|
|
List<String> terms = suggestedTermsItem.getTerms();
|
|
TextView textView = this.binding.f1607c;
|
|
m.checkNotNullExpressionValue(textView, "binding.gifSearchSuggestedTermsIconText");
|
|
b.m(textView, suggestedTermsItem.getTitleResId(), new Object[0], null, 4);
|
|
int size = terms.size();
|
|
if (size > 0) {
|
|
for (int i2 = 0; i2 < size; i2++) {
|
|
FlexboxLayout flexboxLayout = this.binding.b;
|
|
m.checkNotNullExpressionValue(flexboxLayout, "binding.gifSearchSuggestedTermsFlexBox");
|
|
int childCount = flexboxLayout.getChildCount();
|
|
String str = terms.get(i2);
|
|
if (i2 >= childCount) {
|
|
LinearLayout linearLayout = this.binding.a;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.root");
|
|
View inflate = LayoutInflater.from(linearLayout.getContext()).inflate(2131558508, (ViewGroup) this.binding.b, false);
|
|
Objects.requireNonNull(inflate, "rootView");
|
|
TextView textView2 = (TextView) inflate;
|
|
m.checkNotNullExpressionValue(new o(textView2), "GifSearchEmptyStateTextB… false\n )");
|
|
m.checkNotNullExpressionValue(textView2, "GifSearchEmptyStateTextB… false\n ).root");
|
|
this.binding.b.addView(textView2, i2);
|
|
}
|
|
View childAt = this.binding.b.getChildAt(i2);
|
|
Objects.requireNonNull(childAt, "null cannot be cast to non-null type android.widget.TextView");
|
|
TextView textView3 = (TextView) childAt;
|
|
textView3.setText(str);
|
|
textView3.setOnClickListener(new GifViewHolder$SuggestedTerms$configureSearchTerms$1(function1, str));
|
|
}
|
|
}
|
|
FlexboxLayout flexboxLayout2 = this.binding.b;
|
|
m.checkNotNullExpressionValue(flexboxLayout2, "binding.gifSearchSuggestedTermsFlexBox");
|
|
if (size < flexboxLayout2.getChildCount()) {
|
|
FlexboxLayout flexboxLayout3 = this.binding.b;
|
|
m.checkNotNullExpressionValue(flexboxLayout3, "binding.gifSearchSuggestedTermsFlexBox");
|
|
if (flexboxLayout3.getChildCount() > 0) {
|
|
FlexboxLayout flexboxLayout4 = this.binding.b;
|
|
m.checkNotNullExpressionValue(flexboxLayout4, "binding.gifSearchSuggestedTermsFlexBox");
|
|
int childCount2 = flexboxLayout4.getChildCount() - 1;
|
|
if (childCount2 >= size) {
|
|
while (true) {
|
|
this.binding.b.removeViewAt(childCount2);
|
|
if (childCount2 == size) {
|
|
break;
|
|
}
|
|
childCount2--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
StaggeredGridLayoutManager.LayoutParams layoutParams = new StaggeredGridLayoutManager.LayoutParams(-1, i);
|
|
layoutParams.setFullSpan(true);
|
|
View view = this.itemView;
|
|
m.checkNotNullExpressionValue(view, "itemView");
|
|
view.setLayoutParams(layoutParams);
|
|
}
|
|
|
|
public final void configure(GifAdapterItem.SuggestedTermsItem.SuggestedTermsEmptyResults suggestedTermsEmptyResults, Function1<? super String, Unit> function1) {
|
|
m.checkNotNullParameter(suggestedTermsEmptyResults, "termsItem");
|
|
TextView textView = this.binding.f1607c;
|
|
m.checkNotNullExpressionValue(textView, "binding.gifSearchSuggestedTermsIconText");
|
|
View view = this.itemView;
|
|
m.checkNotNullExpressionValue(view, "itemView");
|
|
DrawableCompat.setCompoundDrawablesCompat$default(textView, 0, DrawableCompat.getThemedDrawableRes$default(view, 2130970183, 0, 2, (Object) null), 0, 0, 13, (Object) null);
|
|
configureSearchTerms(suggestedTermsEmptyResults, function1, -1);
|
|
View view2 = this.itemView;
|
|
m.checkNotNullExpressionValue(view2, "itemView");
|
|
view2.setPadding(view2.getPaddingLeft(), 0, view2.getPaddingRight(), 0);
|
|
}
|
|
|
|
public final void configure(GifAdapterItem.SuggestedTermsItem.SuggestedTermsNonEmptyResults suggestedTermsNonEmptyResults, Function1<? super String, Unit> function1) {
|
|
m.checkNotNullParameter(suggestedTermsNonEmptyResults, "termsItem");
|
|
TextView textView = this.binding.f1607c;
|
|
m.checkNotNullExpressionValue(textView, "binding.gifSearchSuggestedTermsIconText");
|
|
DrawableCompat.setCompoundDrawablesCompat$default(textView, (Drawable) null, (Drawable) null, (Drawable) null, (Drawable) null, 13, (Object) null);
|
|
configureSearchTerms(suggestedTermsNonEmptyResults, function1, -2);
|
|
View view = this.itemView;
|
|
m.checkNotNullExpressionValue(view, "itemView");
|
|
view.setPadding(view.getPaddingLeft(), DimenUtils.dpToPixels(32), view.getPaddingRight(), DimenUtils.dpToPixels(40));
|
|
}
|
|
}
|
|
|
|
private GifViewHolder(View view) {
|
|
super(view);
|
|
}
|
|
|
|
public /* synthetic */ GifViewHolder(View view, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(view);
|
|
}
|
|
}
|