146 lines
6.9 KiB
Java
146 lines
6.9 KiB
Java
package com.discord.widgets.chat.input.sticker;
|
|
|
|
import android.content.Context;
|
|
import android.view.ViewGroup;
|
|
import androidx.recyclerview.widget.GridLayoutManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import com.discord.app.AppComponent;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerDataPayload;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
|
|
import com.discord.widgets.chat.input.expression.WidgetExpressionPickerAdapter;
|
|
import d0.t.m0;
|
|
import d0.t.u;
|
|
import d0.z.d.m;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.subjects.BehaviorSubject;
|
|
/* compiled from: WidgetStickerAdapter.kt */
|
|
public final class WidgetStickerAdapter extends WidgetExpressionPickerAdapter {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final int DEFAULT_NUM_COLUMNS = 4;
|
|
public static final int ITEM_TYPE_OWNED_HEADER = 0;
|
|
public static final int ITEM_TYPE_STICKER = 1;
|
|
public static final int ITEM_TYPE_STORE_HEADER = 2;
|
|
private final AppComponent appComponent;
|
|
private final GridLayoutManager layoutManager;
|
|
private final int numColumns;
|
|
private final Function1<StoreHeaderItem, Unit> onStickerHeaderItemsClicked;
|
|
private final Function1<StickerItem, Unit> onStickerItemSelected;
|
|
private final BehaviorSubject<Boolean> recyclerScrollingWithinThresholdSubject;
|
|
private final boolean showStickerPackDescriptions;
|
|
|
|
/* compiled from: WidgetStickerAdapter.kt */
|
|
/* renamed from: com.discord.widgets.chat.input.sticker.WidgetStickerAdapter$1 reason: invalid class name */
|
|
public static final class AnonymousClass1 extends GridLayoutManager.SpanSizeLookup {
|
|
public final /* synthetic */ WidgetStickerAdapter this$0;
|
|
|
|
public AnonymousClass1(WidgetStickerAdapter widgetStickerAdapter) {
|
|
this.this$0 = widgetStickerAdapter;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.GridLayoutManager.SpanSizeLookup
|
|
public int getSpanSize(int i) {
|
|
int itemViewType = this.this$0.getItemViewType(i);
|
|
if (itemViewType == 0 || itemViewType == 2) {
|
|
return this.this$0.getNumColumns();
|
|
}
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetStickerAdapter.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* JADX DEBUG: Multi-variable search result rejected for r3v0, resolved type: kotlin.jvm.functions.Function1<? super com.discord.widgets.chat.input.sticker.StickerItem, kotlin.Unit> */
|
|
/* JADX DEBUG: Multi-variable search result rejected for r4v0, resolved type: kotlin.jvm.functions.Function1<? super com.discord.widgets.chat.input.sticker.StoreHeaderItem, kotlin.Unit> */
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetStickerAdapter(RecyclerView recyclerView, Function1<? super StickerItem, Unit> function1, Function1<? super StoreHeaderItem, Unit> function12, BehaviorSubject<Boolean> behaviorSubject, AppComponent appComponent, boolean z2) {
|
|
super(recyclerView, m0.setOf(0));
|
|
m.checkNotNullParameter(recyclerView, "recycler");
|
|
m.checkNotNullParameter(function1, "onStickerItemSelected");
|
|
m.checkNotNullParameter(appComponent, "appComponent");
|
|
this.onStickerItemSelected = function1;
|
|
this.onStickerHeaderItemsClicked = function12;
|
|
this.recyclerScrollingWithinThresholdSubject = behaviorSubject;
|
|
this.appComponent = appComponent;
|
|
this.showStickerPackDescriptions = z2;
|
|
Context context = recyclerView.getContext();
|
|
m.checkNotNullExpressionValue(context, "recycler.context");
|
|
this.numColumns = WidgetExpressionPickerAdapter.Companion.calculateNumOfColumns(recyclerView, context.getResources().getDimension(2131165316), 4);
|
|
this.layoutManager = new GridLayoutManager(recyclerView.getContext(), getNumColumns());
|
|
getLayoutManager().setSpanSizeLookup(new AnonymousClass1(this));
|
|
recyclerView.setLayoutManager(getLayoutManager());
|
|
recyclerView.setAdapter(this);
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ WidgetStickerAdapter(RecyclerView recyclerView, Function1 function1, Function1 function12, BehaviorSubject behaviorSubject, AppComponent appComponent, boolean z2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(recyclerView, function1, (i & 4) != 0 ? null : function12, (i & 8) != 0 ? null : behaviorSubject, appComponent, (i & 32) != 0 ? false : z2);
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.input.expression.WidgetExpressionPickerAdapter
|
|
public OwnedHeaderViewHolder createStickyHeaderViewHolder(WidgetExpressionPickerAdapter widgetExpressionPickerAdapter) {
|
|
m.checkNotNullParameter(widgetExpressionPickerAdapter, "adapter");
|
|
return new OwnedHeaderViewHolder((WidgetStickerAdapter) widgetExpressionPickerAdapter);
|
|
}
|
|
|
|
public final AppComponent getAppComponent() {
|
|
return this.appComponent;
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.input.expression.WidgetExpressionPickerAdapter
|
|
public GridLayoutManager getLayoutManager() {
|
|
return this.layoutManager;
|
|
}
|
|
|
|
@Override // com.discord.widgets.chat.input.expression.WidgetExpressionPickerAdapter
|
|
public int getNumColumns() {
|
|
return this.numColumns;
|
|
}
|
|
|
|
public final Function1<StoreHeaderItem, Unit> getOnStickerHeaderItemsClicked() {
|
|
return this.onStickerHeaderItemsClicked;
|
|
}
|
|
|
|
public final Function1<StickerItem, Unit> getOnStickerItemSelected() {
|
|
return this.onStickerItemSelected;
|
|
}
|
|
|
|
public final BehaviorSubject<Boolean> getRecyclerScrollingWithinThresholdSubject() {
|
|
return this.recyclerScrollingWithinThresholdSubject;
|
|
}
|
|
|
|
public final boolean getShowStickerPackDescriptions() {
|
|
return this.showStickerPackDescriptions;
|
|
}
|
|
|
|
@Override // com.discord.utilities.views.StickyHeaderItemDecoration.StickyHeaderAdapter
|
|
public boolean isHeader(int i) {
|
|
return ((MGRecyclerDataPayload) u.getOrNull(getInternalData(), i)) instanceof HeaderItem;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public MGRecyclerViewHolder<WidgetStickerAdapter, MGRecyclerDataPayload> onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
m.checkNotNullParameter(viewGroup, "parent");
|
|
if (i == 0) {
|
|
return new OwnedHeaderViewHolder(this);
|
|
}
|
|
if (i == 1) {
|
|
return new StickerViewHolder(i, this, this.recyclerScrollingWithinThresholdSubject, this.appComponent);
|
|
}
|
|
if (i == 2) {
|
|
return new StoreHeaderViewHolder(this);
|
|
}
|
|
throw invalidViewTypeException(i);
|
|
}
|
|
}
|