2021-08-20 05:39:29 +00:00
|
|
|
package com.discord.widgets.directories;
|
|
|
|
|
|
|
|
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.FragmentViewModelLazyKt;
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
import c.a.d.e0;
|
|
|
|
import c.d.b.a.a;
|
2021-10-15 06:18:26 +00:00
|
|
|
import c0.g;
|
|
|
|
import c0.t.n;
|
|
|
|
import c0.t.o;
|
|
|
|
import c0.t.u;
|
|
|
|
import c0.z.d.a0;
|
|
|
|
import c0.z.d.m;
|
2021-08-20 05:39:29 +00:00
|
|
|
import com.discord.R;
|
2021-10-29 07:19:59 +00:00
|
|
|
import com.discord.api.channel.Channel;
|
|
|
|
import com.discord.api.channel.ChannelUtils;
|
2021-08-20 05:39:29 +00:00
|
|
|
import com.discord.app.AppFragment;
|
|
|
|
import com.discord.databinding.WidgetDirectoryCategoryBinding;
|
|
|
|
import com.discord.models.hubs.DirectoryEntryCategory;
|
2021-10-29 07:19:59 +00:00
|
|
|
import com.discord.utilities.features.GrowthTeamFeatures;
|
2021-08-20 05:39:29 +00:00
|
|
|
import com.discord.utilities.hubs.HubUtilsKt;
|
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
|
|
import com.discord.widgets.directories.DirectoryChannelItem;
|
|
|
|
import com.discord.widgets.directories.WidgetDirectoriesViewModel;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.List;
|
|
|
|
import kotlin.Lazy;
|
|
|
|
import kotlin.jvm.functions.Function0;
|
|
|
|
import kotlin.jvm.functions.Function1;
|
|
|
|
import kotlin.reflect.KProperty;
|
|
|
|
/* compiled from: WidgetDirectoryCategory.kt */
|
|
|
|
public final class WidgetDirectoryCategory extends AppFragment {
|
2021-10-09 06:29:02 +00:00
|
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.Z(WidgetDirectoryCategory.class, "binding", "getBinding()Lcom/discord/databinding/WidgetDirectoryCategoryBinding;", 0)};
|
2021-08-20 05:39:29 +00:00
|
|
|
private final ActivityResultLauncher<Intent> activityResult = HubUtilsKt.getAddServerActivityResultHandler(this);
|
|
|
|
private final WidgetDirectoryChannelAdapter adapter = new WidgetDirectoryChannelAdapter(new WidgetDirectoryCategory$adapter$1(this));
|
|
|
|
private final Lazy args$delegate = g.lazy(new WidgetDirectoryCategory$$special$$inlined$args$1(this, "intent_args_key"));
|
|
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetDirectoryCategory$binding$2.INSTANCE, null, 2, null);
|
|
|
|
private final Lazy viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetDirectoriesViewModel.class), new WidgetDirectoryCategory$appActivityViewModels$$inlined$activityViewModels$1(this), new e0(WidgetDirectoryCategory$viewModel$2.INSTANCE));
|
|
|
|
|
|
|
|
public final /* synthetic */ class WhenMappings {
|
|
|
|
public static final /* synthetic */ int[] $EnumSwitchMapping$0;
|
|
|
|
|
|
|
|
static {
|
|
|
|
DirectoryEntryCategory.values();
|
2021-10-08 22:11:56 +00:00
|
|
|
int[] iArr = new int[11];
|
2021-08-20 05:39:29 +00:00
|
|
|
$EnumSwitchMapping$0 = iArr;
|
|
|
|
iArr[DirectoryEntryCategory.Home.ordinal()] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public WidgetDirectoryCategory() {
|
|
|
|
super(R.layout.widget_directory_category);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$configureUi(WidgetDirectoryCategory widgetDirectoryCategory, WidgetDirectoriesViewModel.ViewState viewState) {
|
|
|
|
widgetDirectoryCategory.configureUi(viewState);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ ActivityResultLauncher access$getActivityResult$p(WidgetDirectoryCategory widgetDirectoryCategory) {
|
|
|
|
return widgetDirectoryCategory.activityResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void configureUi(WidgetDirectoriesViewModel.ViewState viewState) {
|
|
|
|
List<DirectoryEntryData> list;
|
2021-10-29 07:19:59 +00:00
|
|
|
Channel channel;
|
2021-08-20 05:39:29 +00:00
|
|
|
if (getArgs().getDirectoryCategory().ordinal() != 0) {
|
2021-10-08 22:11:56 +00:00
|
|
|
list = viewState.getDirectoryEntryData().get(Integer.valueOf(getArgs().getDirectoryCategory().getKey()));
|
2021-08-20 05:39:29 +00:00
|
|
|
if (list == null) {
|
|
|
|
list = n.emptyList();
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
list = viewState.getAllDirectoryEntryData();
|
|
|
|
}
|
2021-10-29 07:19:59 +00:00
|
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(list, 10));
|
2021-08-20 05:39:29 +00:00
|
|
|
for (DirectoryEntryData directoryEntryData : list) {
|
|
|
|
arrayList.add(new DirectoryChannelItem.DirectoryItem(directoryEntryData));
|
|
|
|
}
|
2021-10-29 07:19:59 +00:00
|
|
|
List<? extends DirectoryChannelItem> mutableList = u.toMutableList((Collection) arrayList);
|
|
|
|
boolean z2 = true;
|
|
|
|
if (getArgs().getDirectoryCategory() != DirectoryEntryCategory.Home || !(!list.isEmpty()) || (((channel = viewState.getChannel()) != null && ChannelUtils.t(channel)) || !GrowthTeamFeatures.INSTANCE.hubRecommendationsEnabled())) {
|
|
|
|
z2 = false;
|
2021-10-15 06:18:26 +00:00
|
|
|
}
|
2021-10-29 07:19:59 +00:00
|
|
|
if (viewState.getHasAddGuildPermissions() && !z2) {
|
|
|
|
mutableList.add(DirectoryChannelItem.AddServer.INSTANCE);
|
|
|
|
}
|
|
|
|
if (z2) {
|
|
|
|
String string = getString(R.string.directory_hub_recommendation_header);
|
|
|
|
m.checkNotNullExpressionValue(string, "getString(R.string.direc…ub_recommendation_header)");
|
|
|
|
mutableList.add(0, new DirectoryChannelItem.SectionHeader(string));
|
|
|
|
}
|
|
|
|
this.adapter.setDirectoryChannelItems(mutableList);
|
2021-08-20 05:39:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public final WidgetDirectoryChannelAdapter getAdapter() {
|
|
|
|
return this.adapter;
|
|
|
|
}
|
|
|
|
|
|
|
|
public final DirectoryCategoryArgs getArgs() {
|
|
|
|
return (DirectoryCategoryArgs) this.args$delegate.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final WidgetDirectoryCategoryBinding getBinding() {
|
|
|
|
return (WidgetDirectoryCategoryBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public final WidgetDirectoriesViewModel getViewModel() {
|
|
|
|
return (WidgetDirectoriesViewModel) this.viewModel$delegate.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
|
|
public void onViewBound(View view) {
|
|
|
|
m.checkNotNullParameter(view, "view");
|
|
|
|
super.onViewBound(view);
|
|
|
|
RecyclerView recyclerView = getBinding().b;
|
|
|
|
recyclerView.setAdapter(this.adapter);
|
|
|
|
recyclerView.setLayoutManager(new LinearLayoutManager(recyclerView.getContext()));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
|
|
public void onViewBoundOrOnResume() {
|
|
|
|
super.onViewBoundOrOnResume();
|
2021-08-27 06:37:59 +00:00
|
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null), WidgetDirectoryCategory.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetDirectoryCategory$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
2021-08-20 05:39:29 +00:00
|
|
|
}
|
|
|
|
}
|