discord-jadx/app/src/main/java/com/discord/widgets/channels/WidgetChannelPickerBottomSh...

228 lines
12 KiB
Java

package com.discord.widgets.channels;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentKt;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentViewModelLazyKt;
import androidx.recyclerview.widget.RecyclerView;
import c.a.d.f0;
import c.a.d.h0;
import c.d.b.a.a;
import com.discord.R;
import com.discord.app.AppBottomSheet;
import com.discord.app.AppViewFlipper;
import com.discord.databinding.WidgetChannelPickerSheetBinding;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
import com.discord.views.SearchInputView;
import com.discord.widgets.channels.WidgetChannelPickerBottomSheetViewModel;
import d0.g;
import d0.t.k;
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.jvm.functions.Function3;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
import rx.subscriptions.CompositeSubscription;
/* compiled from: WidgetChannelPickerBottomSheet.kt */
public final class WidgetChannelPickerBottomSheet extends AppBottomSheet {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.a0(WidgetChannelPickerBottomSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChannelPickerSheetBinding;", 0)};
private static final String ARG_CHANNEL_PICKER_GUILD_ID = "ARG_CHANNEL_PICKER_GUILD_ID";
private static final String ARG_REQUEST_KEY = "INTENT_EXTRA_REQUEST_CODE";
private static final String ARG_SELECTED_CHANNEL_ID = "ARG_SELECTED_CHANNEL_ID";
private static final int CHANNEL_PICKER_VIEW_FLIPPER_LOADING_STATE = 0;
private static final int CHANNEL_PICKER_VIEW_FLIPPER_RESULT = 1;
public static final Companion Companion = new Companion(null);
private static final String RESULT_EXTRA_CHANNEL_ICON_RES_ID = "RESULT_EXTRA_CHANNEL_ICON_RES_ID";
private static final String RESULT_EXTRA_CHANNEL_ID = "RESULT_EXTRA_CHANNEL_ID";
private static final String RESULT_EXTRA_CHANNEL_NAME = "RESULT_EXTRA_CHANNEL_NAME";
private static final String RESULT_EXTRA_SELECTION_TYPE = "RESULT_EXTRA_SELECTION_TYPE";
private WidgetchannelPickerAdapter adapter;
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetChannelPickerBottomSheet$binding$2.INSTANCE, null, 2, null);
private final Lazy guildId$delegate = g.lazy(new WidgetChannelPickerBottomSheet$guildId$2(this));
private final WidgetChannelPickerBottomSheet$itemClickListener$1 itemClickListener;
private final Lazy selectedChannelId$delegate = g.lazy(new WidgetChannelPickerBottomSheet$selectedChannelId$2(this));
private final Lazy viewModel$delegate;
/* compiled from: WidgetChannelPickerBottomSheet.kt */
public static final class Companion {
public final /* synthetic */ class WhenMappings {
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
static {
SelectionType.values();
int[] iArr = new int[3];
$EnumSwitchMapping$0 = iArr;
iArr[SelectionType.CREATE_CHANNEL.ordinal()] = 1;
iArr[SelectionType.CHANNEL.ordinal()] = 2;
iArr[SelectionType.UNKNOWN.ordinal()] = 3;
}
}
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public static /* synthetic */ void launch$default(Companion companion, Fragment fragment, String str, long j, Long l, int i, Object obj) {
if ((i & 8) != 0) {
l = null;
}
companion.launch(fragment, str, j, l);
}
public final void launch(Fragment fragment, String str, long j, Long l) {
m.checkNotNullParameter(fragment, "fragment");
m.checkNotNullParameter(str, "requestKey");
WidgetChannelPickerBottomSheet widgetChannelPickerBottomSheet = new WidgetChannelPickerBottomSheet();
Bundle bundle = new Bundle();
bundle.putString(WidgetChannelPickerBottomSheet.ARG_REQUEST_KEY, str);
bundle.putLong(WidgetChannelPickerBottomSheet.ARG_CHANNEL_PICKER_GUILD_ID, j);
if (l != null) {
bundle.putLong(WidgetChannelPickerBottomSheet.ARG_SELECTED_CHANNEL_ID, l.longValue());
}
widgetChannelPickerBottomSheet.setArguments(bundle);
FragmentManager parentFragmentManager = fragment.getParentFragmentManager();
m.checkNotNullExpressionValue(parentFragmentManager, "fragment.parentFragmentManager");
widgetChannelPickerBottomSheet.show(parentFragmentManager, WidgetChannelPickerBottomSheet.class.getName());
}
public final void registerForResult(Fragment fragment, String str, Function3<? super Long, ? super String, ? super Integer, Unit> function3, Function0<Unit> function0) {
m.checkNotNullParameter(fragment, "fragment");
m.checkNotNullParameter(str, "requestKey");
m.checkNotNullParameter(function3, "onChannelSelected");
m.checkNotNullParameter(function0, "onCreateChannelSelected");
FragmentKt.setFragmentResultListener(fragment, str, new WidgetChannelPickerBottomSheet$Companion$registerForResult$1(str, function0, function3));
}
}
/* compiled from: WidgetChannelPickerBottomSheet.kt */
public enum SelectionType {
UNKNOWN,
CREATE_CHANNEL,
CHANNEL;
public static final Companion Companion = new Companion(null);
/* compiled from: WidgetChannelPickerBottomSheet.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final SelectionType fromInt(int i) {
SelectionType selectionType = (SelectionType) k.getOrNull(SelectionType.values(), i);
return selectionType != null ? selectionType : SelectionType.UNKNOWN;
}
}
}
public WidgetChannelPickerBottomSheet() {
super(false, 1, null);
WidgetChannelPickerBottomSheet$viewModel$2 widgetChannelPickerBottomSheet$viewModel$2 = new WidgetChannelPickerBottomSheet$viewModel$2(this);
f0 f0Var = new f0(this);
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetChannelPickerBottomSheetViewModel.class), new WidgetChannelPickerBottomSheet$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetChannelPickerBottomSheet$viewModel$2));
this.itemClickListener = new WidgetChannelPickerBottomSheet$itemClickListener$1(this);
}
public static final /* synthetic */ void access$configureUI(WidgetChannelPickerBottomSheet widgetChannelPickerBottomSheet, WidgetChannelPickerBottomSheetViewModel.ViewState viewState) {
widgetChannelPickerBottomSheet.configureUI(viewState);
}
public static final /* synthetic */ Bundle access$getArgumentsOrDefault$p(WidgetChannelPickerBottomSheet widgetChannelPickerBottomSheet) {
return widgetChannelPickerBottomSheet.getArgumentsOrDefault();
}
public static final /* synthetic */ long access$getGuildId$p(WidgetChannelPickerBottomSheet widgetChannelPickerBottomSheet) {
return widgetChannelPickerBottomSheet.getGuildId();
}
public static final /* synthetic */ long access$getSelectedChannelId$p(WidgetChannelPickerBottomSheet widgetChannelPickerBottomSheet) {
return widgetChannelPickerBottomSheet.getSelectedChannelId();
}
public static final /* synthetic */ WidgetChannelPickerBottomSheetViewModel access$getViewModel$p(WidgetChannelPickerBottomSheet widgetChannelPickerBottomSheet) {
return widgetChannelPickerBottomSheet.getViewModel();
}
private final void configureUI(WidgetChannelPickerBottomSheetViewModel.ViewState viewState) {
if (viewState instanceof WidgetChannelPickerBottomSheetViewModel.ViewState.Loading) {
AppViewFlipper appViewFlipper = getBinding().b;
m.checkNotNullExpressionValue(appViewFlipper, "binding.channelPickerAppFlipper");
appViewFlipper.setDisplayedChild(0);
SearchInputView searchInputView = getBinding().d;
m.checkNotNullExpressionValue(searchInputView, "binding.channelPickerSearchInput");
searchInputView.setVisibility(8);
} else if (viewState instanceof WidgetChannelPickerBottomSheetViewModel.ViewState.Loaded) {
SearchInputView searchInputView2 = getBinding().d;
m.checkNotNullExpressionValue(searchInputView2, "binding.channelPickerSearchInput");
searchInputView2.setVisibility(0);
AppViewFlipper appViewFlipper2 = getBinding().b;
m.checkNotNullExpressionValue(appViewFlipper2, "binding.channelPickerAppFlipper");
appViewFlipper2.setDisplayedChild(1);
WidgetchannelPickerAdapter widgetchannelPickerAdapter = this.adapter;
if (widgetchannelPickerAdapter == null) {
m.throwUninitializedPropertyAccessException("adapter");
}
widgetchannelPickerAdapter.setItems(((WidgetChannelPickerBottomSheetViewModel.ViewState.Loaded) viewState).getAdapterItems());
}
}
private final WidgetChannelPickerSheetBinding getBinding() {
return (WidgetChannelPickerSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final long getGuildId() {
return ((Number) this.guildId$delegate.getValue()).longValue();
}
private final long getSelectedChannelId() {
return ((Number) this.selectedChannelId$delegate.getValue()).longValue();
}
private final WidgetChannelPickerBottomSheetViewModel getViewModel() {
return (WidgetChannelPickerBottomSheetViewModel) this.viewModel$delegate.getValue();
}
@Override // com.discord.app.AppBottomSheet
public void bindSubscriptions(CompositeSubscription compositeSubscription) {
m.checkNotNullParameter(compositeSubscription, "compositeSubscription");
super.bindSubscriptions(compositeSubscription);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null), WidgetChannelPickerBottomSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelPickerBottomSheet$bindSubscriptions$1(this), 62, (Object) null);
}
@Override // com.discord.app.AppBottomSheet
public int getContentViewResId() {
return R.layout.widget_channel_picker_sheet;
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public void onViewCreated(View view, Bundle bundle) {
m.checkNotNullParameter(view, "view");
super.onViewCreated(view, bundle);
this.adapter = new WidgetchannelPickerAdapter(this.itemClickListener, this, null, 4, null);
RecyclerView recyclerView = getBinding().f1736c;
m.checkNotNullExpressionValue(recyclerView, "binding.channelPickerRecycler");
WidgetchannelPickerAdapter widgetchannelPickerAdapter = this.adapter;
if (widgetchannelPickerAdapter == null) {
m.throwUninitializedPropertyAccessException("adapter");
}
recyclerView.setAdapter(widgetchannelPickerAdapter);
getBinding().d.a(this, new WidgetChannelPickerBottomSheet$onViewCreated$1(this));
}
}