131 lines
6.3 KiB
Java
131 lines
6.3 KiB
Java
package com.discord.widgets.chat.input.gifpicker;
|
|
|
|
import android.content.Context;
|
|
import android.view.View;
|
|
import androidx.core.view.ViewCompat;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import androidx.recyclerview.widget.GridLayoutManager;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.a.d.h0;
|
|
import c.a.d.j0;
|
|
import c.d.b.a.a;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetGifPickerBinding;
|
|
import com.discord.utilities.dimen.DimenUtils;
|
|
import com.discord.utilities.recycler.GridColumnSpaceItemDecoration;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.widgets.chat.input.gifpicker.GifPickerViewModel;
|
|
import d0.z.d.a0;
|
|
import d0.z.d.m;
|
|
import kotlin.Lazy;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.reflect.KProperty;
|
|
/* compiled from: WidgetGifPicker.kt */
|
|
public final class WidgetGifPicker extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetGifPicker.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGifPickerBinding;", 0)};
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGifPicker$binding$2.INSTANCE, null, 2, null);
|
|
private GifCategoryAdapter categoryAdapter;
|
|
private Function1<? super GifCategoryItem, Unit> onSelectGifCategory;
|
|
private final Lazy viewModel$delegate;
|
|
|
|
public WidgetGifPicker() {
|
|
super(2131559020);
|
|
WidgetGifPicker$viewModel$2 widgetGifPicker$viewModel$2 = WidgetGifPicker$viewModel$2.INSTANCE;
|
|
h0 h0Var = new h0(this);
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(GifPickerViewModel.class), new WidgetGifPicker$appViewModels$$inlined$viewModels$1(h0Var), new j0(widgetGifPicker$viewModel$2));
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetGifPickerBinding access$getBinding$p(WidgetGifPicker widgetGifPicker) {
|
|
return widgetGifPicker.getBinding();
|
|
}
|
|
|
|
public static final /* synthetic */ void access$handleViewState(WidgetGifPicker widgetGifPicker, GifPickerViewModel.ViewState viewState) {
|
|
widgetGifPicker.handleViewState(viewState);
|
|
}
|
|
|
|
private final WidgetGifPickerBinding getBinding() {
|
|
return (WidgetGifPickerBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
private final GifPickerViewModel getViewModel() {
|
|
return (GifPickerViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
private final void handleViewState(GifPickerViewModel.ViewState viewState) {
|
|
RecyclerView recyclerView = getBinding().b;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.gifPickerCategoryRecycler");
|
|
int i = 0;
|
|
recyclerView.setVisibility(viewState.isLoaded() ? 0 : 8);
|
|
GifLoadingView gifLoadingView = getBinding().d;
|
|
m.checkNotNullExpressionValue(gifLoadingView, "binding.gifPickerLoadingView");
|
|
if (!(!viewState.isLoaded())) {
|
|
i = 8;
|
|
}
|
|
gifLoadingView.setVisibility(i);
|
|
GifCategoryAdapter gifCategoryAdapter = this.categoryAdapter;
|
|
if (gifCategoryAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryAdapter");
|
|
}
|
|
gifCategoryAdapter.setItems(viewState.getGifCategoryItems());
|
|
}
|
|
|
|
private final void setUpCategoryRecycler() {
|
|
RecyclerView recyclerView = getBinding().b;
|
|
m.checkNotNullExpressionValue(recyclerView, "binding.gifPickerCategoryRecycler");
|
|
recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
|
|
RecyclerView recyclerView2 = getBinding().b;
|
|
m.checkNotNullExpressionValue(recyclerView2, "binding.gifPickerCategoryRecycler");
|
|
recyclerView2.setItemAnimator(null);
|
|
this.categoryAdapter = new GifCategoryAdapter(this, this.onSelectGifCategory, null, 4, null);
|
|
RecyclerView recyclerView3 = getBinding().b;
|
|
m.checkNotNullExpressionValue(recyclerView3, "binding.gifPickerCategoryRecycler");
|
|
GifCategoryAdapter gifCategoryAdapter = this.categoryAdapter;
|
|
if (gifCategoryAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryAdapter");
|
|
}
|
|
recyclerView3.setAdapter(gifCategoryAdapter);
|
|
getBinding().b.addItemDecoration(new GridColumnSpaceItemDecoration(DimenUtils.dpToPixels(8), 2));
|
|
}
|
|
|
|
private final void setWindowInsetsListeners() {
|
|
ViewCompat.setOnApplyWindowInsetsListener(getBinding().b, WidgetGifPicker$setWindowInsetsListeners$1.INSTANCE);
|
|
ViewCompat.setOnApplyWindowInsetsListener(getBinding().d, WidgetGifPicker$setWindowInsetsListeners$2.INSTANCE);
|
|
ViewCompat.setOnApplyWindowInsetsListener(getBinding().f1786c, new WidgetGifPicker$setWindowInsetsListeners$3(this));
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
setUpCategoryRecycler();
|
|
setWindowInsetsListeners();
|
|
GifLoadingView.updateView$default(getBinding().d, 2, 0, 2, null);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeViewState(), this), WidgetGifPicker.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGifPicker$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
}
|
|
|
|
public final void scrollToTop() {
|
|
GifCategoryAdapter gifCategoryAdapter = this.categoryAdapter;
|
|
if (gifCategoryAdapter == null) {
|
|
m.throwUninitializedPropertyAccessException("categoryAdapter");
|
|
}
|
|
if (gifCategoryAdapter.getItemCount() > 0) {
|
|
getBinding().b.scrollToPosition(0);
|
|
}
|
|
}
|
|
|
|
public final void setOnSelectGifCategory(Function1<? super GifCategoryItem, Unit> function1) {
|
|
m.checkNotNullParameter(function1, "onGifCategorySelected");
|
|
this.onSelectGifCategory = function1;
|
|
}
|
|
}
|