698 lines
38 KiB
Java
698 lines
38 KiB
Java
package com.discord.widgets.chat.input.sticker;
|
|
|
|
import android.content.Context;
|
|
import android.os.Build;
|
|
import android.os.Bundle;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.TextView;
|
|
import androidx.appcompat.widget.Toolbar;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import androidx.coordinatorlayout.widget.CoordinatorLayout;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentManager;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.a.d.g0;
|
|
import c.a.j.a;
|
|
import c.b.a.c;
|
|
import c.d.b.a.a;
|
|
import com.discord.api.sticker.Sticker;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.app.AppLog;
|
|
import com.discord.app.AppViewFlipper;
|
|
import com.discord.databinding.WidgetStickerPickerBinding;
|
|
import com.discord.tooltips.TooltipManager;
|
|
import com.discord.utilities.analytics.AnalyticsTracker;
|
|
import com.discord.utilities.dimen.DimenUtils;
|
|
import com.discord.utilities.recycler.SelfHealingLinearLayoutManager;
|
|
import com.discord.utilities.recycler.SpeedOnScrollListener;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.view.text.LinkifiedTextView;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.utilities.views.StickyHeaderItemDecoration;
|
|
import com.discord.views.SearchInputView;
|
|
import com.discord.views.sticker.StickerView;
|
|
import com.discord.widgets.chat.input.OnBackspacePressedListener;
|
|
import com.discord.widgets.chat.input.expression.WidgetExpressionPickerAdapter;
|
|
import com.discord.widgets.chat.input.sticker.StickerCategoryItem;
|
|
import com.discord.widgets.chat.input.sticker.StickerPickerViewModel;
|
|
import com.discord.widgets.chat.input.sticker.WidgetStickerPickerSheet;
|
|
import com.discord.widgets.stickers.WidgetStickerPackDetailsDialog;
|
|
import com.google.android.material.appbar.AppBarLayout;
|
|
import d0.g;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import j0.l.e.j;
|
|
import java.io.Serializable;
|
|
import java.lang.ref.WeakReference;
|
|
import java.util.List;
|
|
import java.util.Objects;
|
|
import java.util.Set;
|
|
import java.util.concurrent.TimeUnit;
|
|
import kotlin.Lazy;
|
|
import kotlin.Pair;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.ranges.IntRange;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.Observable;
|
|
import rx.subjects.BehaviorSubject;
|
|
import rx.subjects.PublishSubject;
|
|
/* compiled from: WidgetStickerPicker.kt */
|
|
public final class WidgetStickerPicker extends AppFragment implements c {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetStickerPicker.class, "binding", "getBinding()Lcom/discord/databinding/WidgetStickerPickerBinding;", 0)};
|
|
public static final String ARG_MODE = "MODE";
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int STICKER_PICKER_VIEW_FLIPPER_EMPTY_STATE = 1;
|
|
private static final int STICKER_PICKER_VIEW_FLIPPER_EMPTY_STATE_PHASE_1 = 2;
|
|
private static final int STICKER_PICKER_VIEW_FLIPPER_RESULTS = 0;
|
|
public static final String VIEW_TYPE = "VIEW_TYPE";
|
|
private Long autoscrollToPackId;
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetStickerPicker$binding$2.INSTANCE, null, 2, null);
|
|
private boolean canHandleIsShown;
|
|
private StickerCategoryAdapter categoryAdapter;
|
|
private LinearLayoutManager categoryLayoutManager;
|
|
private final Lazy initialStickerPackId$delegate = g.lazy(new WidgetStickerPicker$initialStickerPackId$2(this));
|
|
private OnBackspacePressedListener onBackspacePressedListener;
|
|
private StickerPickerViewModel.ViewState previousViewState;
|
|
private final BehaviorSubject<Boolean> recyclerScrollingWithinThresholdSubject;
|
|
private boolean restoredSearchQueryFromViewModel;
|
|
private Function0<Unit> scrollExpressionPickerToTop = WidgetStickerPicker$scrollExpressionPickerToTop$1.INSTANCE;
|
|
private Function1<? super Boolean, Unit> showSearchBar;
|
|
private WidgetStickerAdapter stickerAdapter;
|
|
private final PublishSubject<Unit> stickerCategoryScrollSubject = PublishSubject.k0();
|
|
private StickerPickerListener stickerPickerListener;
|
|
private StickerPickerMode stickerPickerMode;
|
|
private final TooltipManager tooltipManager;
|
|
private final Lazy viewModelForInline$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(StickerPickerInlineViewModel.class), new WidgetStickerPicker$appActivityViewModels$$inlined$activityViewModels$1(this), new g0(new WidgetStickerPicker$viewModelForInline$2(this)));
|
|
private final Lazy viewModelForSheet$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(StickerPickerSheetViewModel.class), new WidgetStickerPicker$appActivityViewModels$$inlined$activityViewModels$3(this), new g0(new WidgetStickerPicker$viewModelForSheet$2(this)));
|
|
private boolean wasActive;
|
|
|
|
/* compiled from: WidgetStickerPicker.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
public WidgetStickerPicker() {
|
|
super(2131559247);
|
|
TooltipManager tooltipManager = null;
|
|
AppLog appLog = AppLog.g;
|
|
m.checkNotNullParameter(appLog, "logger");
|
|
WeakReference<c.a.j.a> weakReference = a.b.a;
|
|
c.a.j.a aVar = weakReference != null ? weakReference.get() : null;
|
|
if (aVar == null) {
|
|
aVar = new c.a.j.a(appLog);
|
|
a.b.a = new WeakReference<>(aVar);
|
|
}
|
|
TooltipManager.a aVar2 = TooltipManager.a.d;
|
|
m.checkNotNullParameter(aVar, "floatingViewManager");
|
|
WeakReference<TooltipManager> weakReference2 = TooltipManager.a.a;
|
|
tooltipManager = weakReference2 != null ? weakReference2.get() : tooltipManager;
|
|
if (tooltipManager == null) {
|
|
tooltipManager = new TooltipManager((c.a.w.a) TooltipManager.a.b.getValue(), (Set) TooltipManager.a.f2107c.getValue(), 0, aVar, 4);
|
|
TooltipManager.a.a = new WeakReference<>(tooltipManager);
|
|
}
|
|
this.tooltipManager = tooltipManager;
|
|
this.recyclerScrollingWithinThresholdSubject = BehaviorSubject.l0(Boolean.TRUE);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetStickerPicker widgetStickerPicker, StickerPickerViewModel.ViewState viewState) {
|
|
widgetStickerPicker.configureUI(viewState);
|
|
}
|
|
|
|
public static final /* synthetic */ int access$getAdditionalBottomPaddingPx(WidgetStickerPicker widgetStickerPicker) {
|
|
return widgetStickerPicker.getAdditionalBottomPaddingPx();
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetStickerPickerBinding access$getBinding$p(WidgetStickerPicker widgetStickerPicker) {
|
|
return widgetStickerPicker.getBinding();
|
|
}
|
|
|
|
public static final /* synthetic */ Long access$getInitialStickerPackId$p(WidgetStickerPicker widgetStickerPicker) {
|
|
return widgetStickerPicker.getInitialStickerPackId();
|
|
}
|
|
|
|
public static final /* synthetic */ BehaviorSubject access$getRecyclerScrollingWithinThresholdSubject$p(WidgetStickerPicker widgetStickerPicker) {
|
|
return widgetStickerPicker.recyclerScrollingWithinThresholdSubject;
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetStickerAdapter access$getStickerAdapter$p(WidgetStickerPicker widgetStickerPicker) {
|
|
WidgetStickerAdapter widgetStickerAdapter = widgetStickerPicker.stickerAdapter;
|
|
if (widgetStickerAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("stickerAdapter");
|
|
}
|
|
return widgetStickerAdapter;
|
|
}
|
|
|
|
public static final /* synthetic */ PublishSubject access$getStickerCategoryScrollSubject$p(WidgetStickerPicker widgetStickerPicker) {
|
|
return widgetStickerPicker.stickerCategoryScrollSubject;
|
|
}
|
|
|
|
public static final /* synthetic */ StickerPickerMode access$getStickerPickerMode$p(WidgetStickerPicker widgetStickerPicker) {
|
|
return widgetStickerPicker.stickerPickerMode;
|
|
}
|
|
|
|
public static final /* synthetic */ StickerPickerViewModel access$getViewModel$p(WidgetStickerPicker widgetStickerPicker) {
|
|
return widgetStickerPicker.getViewModel();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleEvent(WidgetStickerPicker widgetStickerPicker, StickerPickerViewModel.Event event) {
|
|
widgetStickerPicker.handleEvent(event);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleNewStickerRecyclerScrollPosition(WidgetStickerPicker widgetStickerPicker, int i, List list) {
|
|
widgetStickerPicker.handleNewStickerRecyclerScrollPosition(i, list);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$launchBottomSheet(WidgetStickerPicker widgetStickerPicker) {
|
|
widgetStickerPicker.launchBottomSheet();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onGuildClicked(WidgetStickerPicker widgetStickerPicker, StickerCategoryItem.GuildItem guildItem) {
|
|
widgetStickerPicker.onGuildClicked(guildItem);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onPackClicked(WidgetStickerPicker widgetStickerPicker, StickerCategoryItem.PackItem packItem) {
|
|
widgetStickerPicker.onPackClicked(packItem);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onRecentClicked(WidgetStickerPicker widgetStickerPicker) {
|
|
widgetStickerPicker.onRecentClicked();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onSelectedCategoryAdapterPositionUpdated(WidgetStickerPicker widgetStickerPicker, int i) {
|
|
widgetStickerPicker.onSelectedCategoryAdapterPositionUpdated(i);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onStickerHeaderItemsClicked(WidgetStickerPicker widgetStickerPicker, StoreHeaderItem storeHeaderItem) {
|
|
widgetStickerPicker.onStickerHeaderItemsClicked(storeHeaderItem);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onStickerItemSelected(WidgetStickerPicker widgetStickerPicker, StickerItem stickerItem) {
|
|
widgetStickerPicker.onStickerItemSelected(stickerItem);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setStickerAdapter$p(WidgetStickerPicker widgetStickerPicker, WidgetStickerAdapter widgetStickerAdapter) {
|
|
widgetStickerPicker.stickerAdapter = widgetStickerAdapter;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setStickerPickerMode$p(WidgetStickerPicker widgetStickerPicker, StickerPickerMode stickerPickerMode) {
|
|
widgetStickerPicker.stickerPickerMode = stickerPickerMode;
|
|
}
|
|
|
|
private final void configureUI(StickerPickerViewModel.ViewState viewState) {
|
|
String searchQuery = viewState != null ? viewState.getSearchQuery() : null;
|
|
if (!this.restoredSearchQueryFromViewModel && searchQuery != null) {
|
|
this.restoredSearchQueryFromViewModel = true;
|
|
getBinding().r.setText(searchQuery);
|
|
}
|
|
if (viewState != null) {
|
|
int i = 0;
|
|
if (viewState instanceof StickerPickerViewModel.ViewState.Phase1RolloutNotPremium) {
|
|
AppViewFlipper appViewFlipper = getBinding().l;
|
|
m.checkNotNullExpressionValue(appViewFlipper, "binding.chatInputStickerPickerViewFlipper");
|
|
appViewFlipper.setDisplayedChild(2);
|
|
Function1<? super Boolean, Unit> function1 = this.showSearchBar;
|
|
if (function1 != null) {
|
|
function1.invoke(Boolean.FALSE);
|
|
}
|
|
this.scrollExpressionPickerToTop.mo1invoke();
|
|
StickerPickerViewModel.ViewState.Phase1RolloutNotPremium phase1RolloutNotPremium = (StickerPickerViewModel.ViewState.Phase1RolloutNotPremium) viewState;
|
|
StickerView.d(getBinding().d, phase1RolloutNotPremium.getEmptyStateStickers().get(0), null, 2);
|
|
StickerView.d(getBinding().e, phase1RolloutNotPremium.getEmptyStateStickers().get(1), null, 2);
|
|
StickerView.d(getBinding().f, phase1RolloutNotPremium.getEmptyStateStickers().get(2), null, 2);
|
|
StickerView.d(getBinding().g, phase1RolloutNotPremium.getEmptyStateStickers().get(3), null, 2);
|
|
showCategoryBottomBar(false);
|
|
} else if (viewState instanceof StickerPickerViewModel.ViewState.EmptySearchResults) {
|
|
AppViewFlipper appViewFlipper2 = getBinding().l;
|
|
m.checkNotNullExpressionValue(appViewFlipper2, "binding.chatInputStickerPickerViewFlipper");
|
|
appViewFlipper2.setDisplayedChild(1);
|
|
Function1<? super Boolean, Unit> function12 = this.showSearchBar;
|
|
if (function12 != null) {
|
|
function12.invoke(Boolean.TRUE);
|
|
}
|
|
this.scrollExpressionPickerToTop.mo1invoke();
|
|
getBinding().b.setImageResource(2131232247);
|
|
TextView textView = getBinding().j;
|
|
m.checkNotNullExpressionValue(textView, "binding.chatInputStickerPickerEmptyTitle");
|
|
textView.setVisibility(8);
|
|
TextView textView2 = getBinding().i;
|
|
m.checkNotNullExpressionValue(textView2, "binding.chatInputStickerPickerEmptySubtitle");
|
|
textView2.setText(getString(2131891489));
|
|
LinkifiedTextView linkifiedTextView = getBinding().f1967c;
|
|
m.checkNotNullExpressionValue(linkifiedTextView, "binding.chatInputStickerPickerEmptyLink");
|
|
linkifiedTextView.setVisibility(8);
|
|
showCategoryBottomBar(true);
|
|
StickerCategoryAdapter stickerCategoryAdapter = this.categoryAdapter;
|
|
if (stickerCategoryAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryAdapter");
|
|
}
|
|
stickerCategoryAdapter.setItems(((StickerPickerViewModel.ViewState.EmptySearchResults) viewState).getCategoryItems());
|
|
} else if (viewState instanceof StickerPickerViewModel.ViewState.Stickers) {
|
|
AppViewFlipper appViewFlipper3 = getBinding().l;
|
|
m.checkNotNullExpressionValue(appViewFlipper3, "binding.chatInputStickerPickerViewFlipper");
|
|
appViewFlipper3.setDisplayedChild(0);
|
|
Function1<? super Boolean, Unit> function13 = this.showSearchBar;
|
|
if (function13 != null) {
|
|
function13.invoke(Boolean.TRUE);
|
|
}
|
|
WidgetStickerAdapter widgetStickerAdapter = this.stickerAdapter;
|
|
if (widgetStickerAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("stickerAdapter");
|
|
}
|
|
StickerPickerViewModel.ViewState.Stickers stickers = (StickerPickerViewModel.ViewState.Stickers) viewState;
|
|
widgetStickerAdapter.setData(stickers.getStickerItems());
|
|
this.tooltipManager.c(StickerPackStoreTooltip.INSTANCE);
|
|
SearchInputView searchInputView = getBinding().r;
|
|
m.checkNotNullExpressionValue(searchInputView, "binding.stickerSearchInput");
|
|
if (!(this.stickerPickerMode != StickerPickerMode.INLINE)) {
|
|
i = 8;
|
|
}
|
|
searchInputView.setVisibility(i);
|
|
WidgetStickerAdapter widgetStickerAdapter2 = this.stickerAdapter;
|
|
if (widgetStickerAdapter2 == null) {
|
|
m.throwUninitializedPropertyAccessException("stickerAdapter");
|
|
}
|
|
widgetStickerAdapter2.setOnScrollPositionListener(new WidgetStickerPicker$configureUI$1(this, viewState));
|
|
WidgetStickerAdapter widgetStickerAdapter3 = this.stickerAdapter;
|
|
if (widgetStickerAdapter3 == null) {
|
|
m.throwUninitializedPropertyAccessException("stickerAdapter");
|
|
}
|
|
widgetStickerAdapter3.setOnScrollListener(null);
|
|
showCategoryBottomBar(true);
|
|
StickerCategoryAdapter stickerCategoryAdapter2 = this.categoryAdapter;
|
|
if (stickerCategoryAdapter2 == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryAdapter");
|
|
}
|
|
stickerCategoryAdapter2.setItems(stickers.getCategoryItems());
|
|
if (this.stickerPickerMode == StickerPickerMode.BOTTOM_SHEET) {
|
|
RecyclerView recyclerView = getBinding().k;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.chatInputStickerPickerRecycler");
|
|
ViewGroup.LayoutParams layoutParams = recyclerView.getLayoutParams();
|
|
Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.widget.FrameLayout.LayoutParams");
|
|
FrameLayout.LayoutParams layoutParams2 = (FrameLayout.LayoutParams) layoutParams;
|
|
layoutParams2.topMargin = DimenUtils.dpToPixels(72);
|
|
RecyclerView recyclerView2 = getBinding().k;
|
|
m.checkNotNullExpressionValue(recyclerView2, "binding.chatInputStickerPickerRecycler");
|
|
recyclerView2.setLayoutParams(layoutParams2);
|
|
}
|
|
}
|
|
this.previousViewState = viewState;
|
|
}
|
|
}
|
|
|
|
private final int getAdditionalBottomPaddingPx() {
|
|
if (Build.VERSION.SDK_INT >= 29) {
|
|
return DimenUtils.dpToPixels(8);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
private final WidgetStickerPickerBinding getBinding() {
|
|
return (WidgetStickerPickerBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final Long getInitialStickerPackId() {
|
|
return (Long) this.initialStickerPackId$delegate.getValue();
|
|
}
|
|
|
|
private final StickerPickerMode getMode() {
|
|
Bundle arguments = getArguments();
|
|
StickerPickerMode stickerPickerMode = null;
|
|
Serializable serializable = arguments != null ? arguments.getSerializable("MODE") : null;
|
|
if (serializable instanceof StickerPickerMode) {
|
|
stickerPickerMode = serializable;
|
|
}
|
|
StickerPickerMode stickerPickerMode2 = stickerPickerMode;
|
|
return stickerPickerMode2 != null ? stickerPickerMode2 : StickerPickerMode.INLINE;
|
|
}
|
|
|
|
private final StickerPickerViewModel getViewModel() {
|
|
return getMode() == StickerPickerMode.INLINE ? getViewModelForInline() : getViewModelForSheet();
|
|
}
|
|
|
|
private final StickerPickerInlineViewModel getViewModelForInline() {
|
|
return (StickerPickerInlineViewModel) this.viewModelForInline$delegate.getValue();
|
|
}
|
|
|
|
private final StickerPickerSheetViewModel getViewModelForSheet() {
|
|
return (StickerPickerSheetViewModel) this.viewModelForSheet$delegate.getValue();
|
|
}
|
|
|
|
private final void handleEvent(StickerPickerViewModel.Event event) {
|
|
if (event instanceof StickerPickerViewModel.Event.ScrollToStickerItemPosition) {
|
|
WidgetStickerAdapter widgetStickerAdapter = this.stickerAdapter;
|
|
if (widgetStickerAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("stickerAdapter");
|
|
}
|
|
widgetStickerAdapter.scrollToPosition(((StickerPickerViewModel.Event.ScrollToStickerItemPosition) event).getPosition());
|
|
}
|
|
}
|
|
|
|
private final void handleNewStickerRecyclerScrollPosition(int i, List<? extends StickerCategoryItem> list) {
|
|
for (StickerCategoryItem stickerCategoryItem : list) {
|
|
if (stickerCategoryItem instanceof StickerCategoryItem.PackItem) {
|
|
StickerCategoryItem.PackItem packItem = (StickerCategoryItem.PackItem) stickerCategoryItem;
|
|
Pair<Integer, Integer> categoryRange = packItem.getCategoryRange();
|
|
int intValue = categoryRange.getFirst().intValue();
|
|
int intValue2 = categoryRange.getSecond().intValue();
|
|
if (intValue <= i && intValue2 > i) {
|
|
Long l = this.autoscrollToPackId;
|
|
if (l != null) {
|
|
long id2 = packItem.getPack().getId();
|
|
if (l != null && l.longValue() == id2) {
|
|
}
|
|
}
|
|
this.autoscrollToPackId = null;
|
|
if (!stickerCategoryItem.isSelected()) {
|
|
selectPackById(((StickerCategoryItem.PackItem) stickerCategoryItem).getPack().getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private final void initializeSearchBar() {
|
|
AppBarLayout appBarLayout = getBinding().m;
|
|
m.checkNotNullExpressionValue(appBarLayout, "binding.stickerAppBar");
|
|
StickerPickerMode stickerPickerMode = this.stickerPickerMode;
|
|
StickerPickerMode stickerPickerMode2 = StickerPickerMode.INLINE;
|
|
int i = 0;
|
|
appBarLayout.setVisibility(stickerPickerMode != stickerPickerMode2 ? 0 : 8);
|
|
SearchInputView searchInputView = getBinding().r;
|
|
m.checkNotNullExpressionValue(searchInputView, "binding.stickerSearchInput");
|
|
if (!(this.stickerPickerMode != stickerPickerMode2)) {
|
|
i = 8;
|
|
}
|
|
searchInputView.setVisibility(i);
|
|
getBinding().r.setOnClearClicked(new WidgetStickerPicker$initializeSearchBar$1(this));
|
|
if (this.stickerPickerMode == StickerPickerMode.BOTTOM_SHEET) {
|
|
getBinding().r.j.f78c.requestFocus();
|
|
showKeyboard(getBinding().r.getEditText());
|
|
}
|
|
Bundle arguments = getArguments();
|
|
String string = arguments != null ? arguments.getString("com.discord.intent.extra.EXTRA_TEXT") : null;
|
|
if (string != null) {
|
|
getBinding().r.setText(string);
|
|
getViewModel().setSearchText(string);
|
|
this.restoredSearchQueryFromViewModel = true;
|
|
}
|
|
}
|
|
|
|
private final void launchBottomSheet() {
|
|
WidgetStickerPickerSheet.Companion companion = WidgetStickerPickerSheet.Companion;
|
|
FragmentManager parentFragmentManager = getParentFragmentManager();
|
|
m.checkNotNullExpressionValue(parentFragmentManager, "parentFragmentManager");
|
|
WidgetStickerPickerSheet.Companion.show$default(companion, parentFragmentManager, this.stickerPickerListener, null, null, null, 28, null);
|
|
}
|
|
|
|
private final void onGuildClicked(StickerCategoryItem.GuildItem guildItem) {
|
|
AnalyticsTracker.INSTANCE.guildCategorySelected(guildItem.getGuild().getId());
|
|
this.autoscrollToPackId = Long.valueOf(guildItem.getGuild().getId());
|
|
selectPackById(guildItem.getGuild().getId());
|
|
Pair<Integer, Integer> categoryRange = guildItem.getCategoryRange();
|
|
Observable<T> q = new j(Unit.a).q(200, TimeUnit.MILLISECONDS);
|
|
m.checkNotNullExpressionValue(q, "Observable.just(Unit)\n …0, TimeUnit.MILLISECONDS)");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(q, this, null, 2, null), WidgetStickerPicker.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetStickerPicker$onGuildClicked$1(this, categoryRange), 62, (Object) null);
|
|
}
|
|
|
|
private final void onPackClicked(StickerCategoryItem.PackItem packItem) {
|
|
AnalyticsTracker.INSTANCE.stickerPackCategorySelected(packItem.getPack().getId());
|
|
this.autoscrollToPackId = Long.valueOf(packItem.getPack().getId());
|
|
selectPackById(packItem.getPack().getId());
|
|
Pair<Integer, Integer> categoryRange = packItem.getCategoryRange();
|
|
Observable<T> q = new j(Unit.a).q(200, TimeUnit.MILLISECONDS);
|
|
m.checkNotNullExpressionValue(q, "Observable.just(Unit)\n …0, TimeUnit.MILLISECONDS)");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(q, this, null, 2, null), WidgetStickerPicker.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetStickerPicker$onPackClicked$1(this, categoryRange), 62, (Object) null);
|
|
}
|
|
|
|
private final void onRecentClicked() {
|
|
selectPackById(-1);
|
|
WidgetStickerAdapter widgetStickerAdapter = this.stickerAdapter;
|
|
if (widgetStickerAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("stickerAdapter");
|
|
}
|
|
widgetStickerAdapter.scrollToPosition(0);
|
|
}
|
|
|
|
private final void onSelectedCategoryAdapterPositionUpdated(int i) {
|
|
LinearLayoutManager linearLayoutManager = this.categoryLayoutManager;
|
|
if (linearLayoutManager == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryLayoutManager");
|
|
}
|
|
int findFirstCompletelyVisibleItemPosition = linearLayoutManager.findFirstCompletelyVisibleItemPosition();
|
|
LinearLayoutManager linearLayoutManager2 = this.categoryLayoutManager;
|
|
if (linearLayoutManager2 == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryLayoutManager");
|
|
}
|
|
int findLastCompletelyVisibleItemPosition = linearLayoutManager2.findLastCompletelyVisibleItemPosition();
|
|
int i2 = findLastCompletelyVisibleItemPosition - findFirstCompletelyVisibleItemPosition;
|
|
if (!new IntRange(findFirstCompletelyVisibleItemPosition, findLastCompletelyVisibleItemPosition).contains(i)) {
|
|
int max = Math.max(i < findFirstCompletelyVisibleItemPosition ? i - i2 : i + i2, 0);
|
|
StickerCategoryAdapter stickerCategoryAdapter = this.categoryAdapter;
|
|
if (stickerCategoryAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryAdapter");
|
|
}
|
|
getBinding().p.scrollToPosition(Math.min(max, stickerCategoryAdapter.getItemCount() - 1));
|
|
}
|
|
}
|
|
|
|
private final void onStickerHeaderItemsClicked(StoreHeaderItem storeHeaderItem) {
|
|
WidgetStickerPackDetailsDialog.Companion companion = WidgetStickerPackDetailsDialog.Companion;
|
|
FragmentManager childFragmentManager = getChildFragmentManager();
|
|
m.checkNotNullExpressionValue(childFragmentManager, "childFragmentManager");
|
|
WidgetStickerPackDetailsDialog.Companion.show$default(companion, childFragmentManager, storeHeaderItem.getPack().getId(), null, 4, null);
|
|
}
|
|
|
|
private final void onStickerItemSelected(StickerItem stickerItem) {
|
|
Sticker sticker = stickerItem.getSticker();
|
|
StickerPickerListener stickerPickerListener = this.stickerPickerListener;
|
|
if (stickerPickerListener != null) {
|
|
stickerPickerListener.onStickerPicked(sticker);
|
|
}
|
|
getViewModel().onStickerSelected(sticker);
|
|
}
|
|
|
|
private final void setUpCategoryRecycler() {
|
|
RecyclerView recyclerView = getBinding().p;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.stickerPickerCategoryRecycler");
|
|
recyclerView.setItemAnimator(null);
|
|
StickerCategoryAdapter stickerCategoryAdapter = new StickerCategoryAdapter(new WidgetStickerPicker$setUpCategoryRecycler$1(this), new WidgetStickerPicker$setUpCategoryRecycler$2(this), new WidgetStickerPicker$setUpCategoryRecycler$3(this), new WidgetStickerPicker$setUpCategoryRecycler$4(this), this, null, 32, null);
|
|
this.categoryAdapter = stickerCategoryAdapter;
|
|
if (stickerCategoryAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryAdapter");
|
|
}
|
|
stickerCategoryAdapter.setHasStableIds(true);
|
|
RecyclerView recyclerView2 = getBinding().p;
|
|
m.checkNotNullExpressionValue(recyclerView2, "binding.stickerPickerCategoryRecycler");
|
|
StickerCategoryAdapter stickerCategoryAdapter2 = this.categoryAdapter;
|
|
if (stickerCategoryAdapter2 == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryAdapter");
|
|
}
|
|
recyclerView2.setAdapter(stickerCategoryAdapter2);
|
|
RecyclerView recyclerView3 = getBinding().p;
|
|
m.checkNotNullExpressionValue(recyclerView3, "binding.stickerPickerCategoryRecycler");
|
|
StickerCategoryAdapter stickerCategoryAdapter3 = this.categoryAdapter;
|
|
if (stickerCategoryAdapter3 == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryAdapter");
|
|
}
|
|
this.categoryLayoutManager = new SelfHealingLinearLayoutManager(recyclerView3, stickerCategoryAdapter3, 0, false, 8, null);
|
|
RecyclerView recyclerView4 = getBinding().p;
|
|
m.checkNotNullExpressionValue(recyclerView4, "binding.stickerPickerCategoryRecycler");
|
|
LinearLayoutManager linearLayoutManager = this.categoryLayoutManager;
|
|
if (linearLayoutManager == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryLayoutManager");
|
|
}
|
|
recyclerView4.setLayoutManager(linearLayoutManager);
|
|
getBinding().p.addOnScrollListener(new WidgetStickerPicker$setUpCategoryRecycler$5(this));
|
|
}
|
|
|
|
private final void setUpStickerRecycler() {
|
|
RecyclerView recyclerView = getBinding().k;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.chatInputStickerPickerRecycler");
|
|
recyclerView.setItemAnimator(null);
|
|
RecyclerView recyclerView2 = getBinding().k;
|
|
m.checkNotNullExpressionValue(recyclerView2, "binding.chatInputStickerPickerRecycler");
|
|
WidgetStickerAdapter widgetStickerAdapter = new WidgetStickerAdapter(recyclerView2, new WidgetStickerPicker$setUpStickerRecycler$1(this), new WidgetStickerPicker$setUpStickerRecycler$2(this), this.recyclerScrollingWithinThresholdSubject, this, false, 32, null);
|
|
this.stickerAdapter = widgetStickerAdapter;
|
|
if (widgetStickerAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("stickerAdapter");
|
|
}
|
|
StickyHeaderItemDecoration stickyHeaderItemDecoration = new StickyHeaderItemDecoration(widgetStickerAdapter);
|
|
getBinding().k.addItemDecoration(stickyHeaderItemDecoration);
|
|
RecyclerView recyclerView3 = getBinding().k;
|
|
m.checkNotNullExpressionValue(recyclerView3, "binding.chatInputStickerPickerRecycler");
|
|
stickyHeaderItemDecoration.blockClicks(recyclerView3);
|
|
getBinding().k.setHasFixedSize(true);
|
|
getBinding().k.setRecyclerListener(WidgetStickerPicker$setUpStickerRecycler$3.INSTANCE);
|
|
getBinding().k.addOnScrollListener(new SpeedOnScrollListener(0, new WidgetStickerPicker$setUpStickerRecycler$4(this), 0, null, 13, null));
|
|
}
|
|
|
|
private final void setWindowInsetsListeners() {
|
|
ViewCompat.setOnApplyWindowInsetsListener(getBinding().q, new WidgetStickerPicker$setWindowInsetsListeners$1(this));
|
|
}
|
|
|
|
public static /* synthetic */ void setupForInlineSearchAndScroll$default(WidgetStickerPicker widgetStickerPicker, String str, long j, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
str = "";
|
|
}
|
|
widgetStickerPicker.setupForInlineSearchAndScroll(str, j);
|
|
}
|
|
|
|
private final void showCategoryBottomBar(boolean z2) {
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = new ViewGroup.MarginLayoutParams(-1, -1);
|
|
int i = 0;
|
|
marginLayoutParams.bottomMargin = z2 ? DimenUtils.dpToPixels(48) : 0;
|
|
AppViewFlipper appViewFlipper = getBinding().l;
|
|
m.checkNotNullExpressionValue(appViewFlipper, "binding.chatInputStickerPickerViewFlipper");
|
|
appViewFlipper.setLayoutParams(new CoordinatorLayout.LayoutParams(marginLayoutParams));
|
|
ConstraintLayout constraintLayout = getBinding().n;
|
|
m.checkNotNullExpressionValue(constraintLayout, "binding.stickerPickerBottomBar");
|
|
constraintLayout.setVisibility(z2 ? 0 : 8);
|
|
View view = getBinding().o;
|
|
m.checkNotNullExpressionValue(view, "binding.stickerPickerBottomBarDivider");
|
|
if (!z2) {
|
|
i = 8;
|
|
}
|
|
view.setVisibility(i);
|
|
}
|
|
|
|
public final void clearSearchInput() {
|
|
getViewModel().setSearchText("");
|
|
}
|
|
|
|
public final boolean getCanHandleIsShown() {
|
|
return this.canHandleIsShown;
|
|
}
|
|
|
|
@Override // c.b.a.c
|
|
public void isShown(boolean z2) {
|
|
if (z2 && !this.wasActive) {
|
|
getBinding().m.setExpanded(true);
|
|
scrollToTop();
|
|
}
|
|
try {
|
|
getViewModel().setSelectedPackId(-1);
|
|
clearSearchInput();
|
|
} catch (Exception unused) {
|
|
}
|
|
this.wasActive = z2;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.Fragment
|
|
public void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
System.gc();
|
|
this.stickerPickerMode = getMode();
|
|
this.canHandleIsShown = true;
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
CoordinatorLayout coordinatorLayout = getBinding().q;
|
|
m.checkNotNullExpressionValue(coordinatorLayout, "binding.stickerPickerContainer");
|
|
coordinatorLayout.setPadding(coordinatorLayout.getPaddingLeft(), coordinatorLayout.getPaddingTop(), coordinatorLayout.getPaddingRight(), getAdditionalBottomPaddingPx());
|
|
StickerPickerMode mode = getMode();
|
|
StickerPickerMode stickerPickerMode = StickerPickerMode.INLINE;
|
|
if (mode == stickerPickerMode) {
|
|
setWindowInsetsListeners();
|
|
}
|
|
initializeSearchBar();
|
|
Toolbar toolbar = getBinding().f1968s;
|
|
m.checkNotNullExpressionValue(toolbar, "binding.stickerToolbar");
|
|
ViewGroup.LayoutParams layoutParams = toolbar.getLayoutParams();
|
|
Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type com.google.android.material.appbar.AppBarLayout.LayoutParams");
|
|
((AppBarLayout.LayoutParams) layoutParams).setScrollFlags(this.stickerPickerMode == stickerPickerMode ? 5 : 0);
|
|
setUpStickerRecycler();
|
|
setUpCategoryRecycler();
|
|
getBinding().r.a(this, new WidgetStickerPicker$onViewBound$1(this));
|
|
Bundle arguments = getArguments();
|
|
Long valueOf = arguments != null ? Long.valueOf(arguments.getLong("com.discord.intent.EXTRA_STICKER_PACK_ID")) : null;
|
|
getViewModel().setSelectedPackId(valueOf != null ? valueOf.longValue() : -1);
|
|
RecyclerView recyclerView = getBinding().p;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.stickerPickerCategoryRecycler");
|
|
recyclerView.setLayoutParams(new ConstraintLayout.LayoutParams(-1, -1));
|
|
getBinding().h.setIsLoading(false);
|
|
getBinding().h.setOnClickListener(new WidgetStickerPicker$onViewBound$2(this));
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
StickerPickerViewModel viewModel = getViewModel();
|
|
WidgetExpressionPickerAdapter.Companion companion = WidgetExpressionPickerAdapter.Companion;
|
|
RecyclerView recyclerView = getBinding().k;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.chatInputStickerPickerRecycler");
|
|
viewModel.setStickerCountToDisplayForStore(companion.calculateNumOfColumns(recyclerView, getResources().getDimension(2131165316), 4));
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeViewState(), this), WidgetStickerPicker.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetStickerPicker$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeEvents(), this), WidgetStickerPicker.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetStickerPicker$onViewBoundOrOnResume$2(this), 62, (Object) null);
|
|
}
|
|
|
|
public final void scrollToPack(Long l) {
|
|
getViewModel().scrollToPackId(l);
|
|
}
|
|
|
|
public final void scrollToTop() {
|
|
RecyclerView recyclerView = getBinding().k;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.chatInputStickerPickerRecycler");
|
|
if (!ViewCompat.isLaidOut(recyclerView) || recyclerView.isLayoutRequested()) {
|
|
recyclerView.addOnLayoutChangeListener(new WidgetStickerPicker$scrollToTop$$inlined$doOnLayout$1(this));
|
|
} else {
|
|
access$getBinding$p(this).k.scrollToPosition(0);
|
|
}
|
|
}
|
|
|
|
public final void selectPackById(long j) {
|
|
getViewModel().setSelectedPackId(j);
|
|
}
|
|
|
|
public final void setListener(StickerPickerListener stickerPickerListener) {
|
|
this.stickerPickerListener = stickerPickerListener;
|
|
}
|
|
|
|
public final void setOnBackspacePressedListener(OnBackspacePressedListener onBackspacePressedListener) {
|
|
this.onBackspacePressedListener = onBackspacePressedListener;
|
|
}
|
|
|
|
public final void setScrollExpressionPickerToTop(Function0<Unit> function0) {
|
|
m.checkNotNullParameter(function0, "scrollExpressionPickerToTop");
|
|
this.scrollExpressionPickerToTop = function0;
|
|
}
|
|
|
|
public final void setShowSearchBar(Function1<? super Boolean, Unit> function1) {
|
|
this.showSearchBar = function1;
|
|
}
|
|
|
|
public final void setupForInlineSearchAndScroll(String str, long j) {
|
|
m.checkNotNullParameter(str, "searchText");
|
|
RecyclerView recyclerView = getBinding().k;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.chatInputStickerPickerRecycler");
|
|
if (!ViewCompat.isLaidOut(recyclerView) || recyclerView.isLayoutRequested()) {
|
|
recyclerView.addOnLayoutChangeListener(new WidgetStickerPicker$setupForInlineSearchAndScroll$$inlined$doOnLayout$1(this, str, j));
|
|
return;
|
|
}
|
|
access$getViewModel$p(this).setSearchText(str);
|
|
access$getViewModel$p(this).setSelectedPackId(j);
|
|
RecyclerView recyclerView2 = access$getBinding$p(this).k;
|
|
m.checkNotNullExpressionValue(recyclerView2, "binding.chatInputStickerPickerRecycler");
|
|
if (!ViewCompat.isLaidOut(recyclerView2) || recyclerView2.isLayoutRequested()) {
|
|
recyclerView2.addOnLayoutChangeListener(new WidgetStickerPicker$setupForInlineSearchAndScroll$$inlined$doOnLayout$lambda$1(this, str, j));
|
|
} else {
|
|
scrollToPack(Long.valueOf(j));
|
|
}
|
|
}
|
|
}
|