142 lines
6.7 KiB
Java
142 lines
6.7 KiB
Java
|
package com.discord.widgets.stage.start;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.content.Intent;
|
||
|
import android.view.View;
|
||
|
import androidx.activity.result.ActivityResultLauncher;
|
||
|
import androidx.fragment.app.Fragment;
|
||
|
import androidx.fragment.app.FragmentActivity;
|
||
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||
|
import androidx.recyclerview.widget.RecyclerView;
|
||
|
import c.a.d.h0;
|
||
|
import c.a.d.j0;
|
||
|
import c.a.d.l;
|
||
|
import c.d.b.a.a;
|
||
|
import com.discord.app.AppFragment;
|
||
|
import com.discord.app.AppTransitionActivity;
|
||
|
import com.discord.databinding.WidgetStartStageBinding;
|
||
|
import com.discord.utilities.intent.IntentUtilsKt;
|
||
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
||
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
||
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
||
|
import com.discord.widgets.stage.settings.WidgetStageSettings;
|
||
|
import com.discord.widgets.stage.start.StartStageItem;
|
||
|
import com.discord.widgets.stage.start.StartStageViewModel;
|
||
|
import com.discord.widgets.voice.fullscreen.WidgetCallFullscreen;
|
||
|
import d0.g;
|
||
|
import d0.z.d.a0;
|
||
|
import d0.z.d.m;
|
||
|
import kotlin.Lazy;
|
||
|
import kotlin.jvm.functions.Function0;
|
||
|
import kotlin.jvm.functions.Function1;
|
||
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||
|
import kotlin.reflect.KProperty;
|
||
|
/* compiled from: WidgetStartStage.kt */
|
||
|
public final class WidgetStartStage extends AppFragment {
|
||
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.V(WidgetStartStage.class, "binding", "getBinding()Lcom/discord/databinding/WidgetStartStageBinding;", 0)};
|
||
|
public static final Companion Companion = new Companion(null);
|
||
|
private static final String INTENT_EXTRA_CHANNEL_ID = "INTENT_EXTRA_CHANNEL_ID";
|
||
|
private StartStageAdapter adapter;
|
||
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetStartStage$binding$2.INSTANCE, null, 2, null);
|
||
|
private final Lazy channelId$delegate = g.lazy(new WidgetStartStage$channelId$2(this));
|
||
|
private final ActivityResultLauncher<Intent> settingsLauncher;
|
||
|
private final Lazy viewModel$delegate;
|
||
|
|
||
|
/* compiled from: WidgetStartStage.kt */
|
||
|
public static final class Companion {
|
||
|
private Companion() {
|
||
|
}
|
||
|
|
||
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this();
|
||
|
}
|
||
|
|
||
|
public final void launch(Context context, long j) {
|
||
|
m.checkNotNullParameter(context, "context");
|
||
|
Intent intent = new Intent();
|
||
|
intent.putExtra("INTENT_EXTRA_CHANNEL_ID", j);
|
||
|
l.d(context, WidgetStartStage.class, intent);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public WidgetStartStage() {
|
||
|
super(2131559263);
|
||
|
WidgetStartStage$viewModel$2 widgetStartStage$viewModel$2 = WidgetStartStage$viewModel$2.INSTANCE;
|
||
|
h0 h0Var = new h0(this);
|
||
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(StartStageViewModel.class), new WidgetStartStage$appViewModels$$inlined$viewModels$1(h0Var), new j0(widgetStartStage$viewModel$2));
|
||
|
this.settingsLauncher = WidgetStageSettings.Companion.registerForResult(this, new WidgetStartStage$settingsLauncher$1(this));
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ void access$configureUi(WidgetStartStage widgetStartStage, StartStageViewModel.ViewState viewState) {
|
||
|
widgetStartStage.configureUi(viewState);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ void access$handleListItemClick(WidgetStartStage widgetStartStage, StartStageItem startStageItem) {
|
||
|
widgetStartStage.handleListItemClick(startStageItem);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ void access$handleStageSettingsResult(WidgetStartStage widgetStartStage, Intent intent) {
|
||
|
widgetStartStage.handleStageSettingsResult(intent);
|
||
|
}
|
||
|
|
||
|
private final void configureUi(StartStageViewModel.ViewState viewState) {
|
||
|
StartStageAdapter startStageAdapter = this.adapter;
|
||
|
if (startStageAdapter == null) {
|
||
|
m.throwUninitializedPropertyAccessException("adapter");
|
||
|
}
|
||
|
startStageAdapter.setData(viewState.getItems());
|
||
|
}
|
||
|
|
||
|
private final WidgetStartStageBinding getBinding() {
|
||
|
return (WidgetStartStageBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
||
|
}
|
||
|
|
||
|
private final long getChannelId() {
|
||
|
return ((Number) this.channelId$delegate.getValue()).longValue();
|
||
|
}
|
||
|
|
||
|
private final StartStageViewModel getViewModel() {
|
||
|
return (StartStageViewModel) this.viewModel$delegate.getValue();
|
||
|
}
|
||
|
|
||
|
private final void handleListItemClick(StartStageItem startStageItem) {
|
||
|
if (startStageItem instanceof StartStageItem.ListItem.StartStage) {
|
||
|
WidgetStageSettings.Companion.launch(requireContext(), getChannelId(), false, this.settingsLauncher);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private final void handleStageSettingsResult(Intent intent) {
|
||
|
Long longExtraOrNull;
|
||
|
if (!(intent == null || (longExtraOrNull = IntentUtilsKt.getLongExtraOrNull(intent, "com.discord.intent.extra.EXTRA_CHANNEL_ID")) == null)) {
|
||
|
WidgetCallFullscreen.Companion.launch$default(WidgetCallFullscreen.Companion, requireContext(), longExtraOrNull.longValue(), true, null, AppTransitionActivity.Transition.TYPE_SLIDE_VERTICAL_WITH_FADE, 8, null);
|
||
|
}
|
||
|
FragmentActivity activity = getActivity();
|
||
|
if (activity != null) {
|
||
|
activity.finish();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.app.AppFragment
|
||
|
public void onViewBound(View view) {
|
||
|
m.checkNotNullParameter(view, "view");
|
||
|
super.onViewBound(view);
|
||
|
RecyclerView recyclerView = getBinding().b;
|
||
|
m.checkNotNullExpressionValue(recyclerView, "binding.recyclerView");
|
||
|
this.adapter = new StartStageAdapter(recyclerView, new WidgetStartStage$onViewBound$1(this));
|
||
|
RecyclerView recyclerView2 = getBinding().b;
|
||
|
recyclerView2.setLayoutManager(new LinearLayoutManager(recyclerView2.getContext()));
|
||
|
StartStageAdapter startStageAdapter = this.adapter;
|
||
|
if (startStageAdapter == null) {
|
||
|
m.throwUninitializedPropertyAccessException("adapter");
|
||
|
}
|
||
|
recyclerView2.setAdapter(startStageAdapter);
|
||
|
}
|
||
|
|
||
|
@Override // com.discord.app.AppFragment
|
||
|
public void onViewBoundOrOnResume() {
|
||
|
super.onViewBoundOrOnResume();
|
||
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeViewState(), this), WidgetStartStage.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetStartStage$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
||
|
}
|
||
|
}
|