forked from Juby210/discord-jadx
232 lines
12 KiB
Java
232 lines
12 KiB
Java
package com.discord.widgets.directories;
|
|
|
|
import android.annotation.SuppressLint;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.TextView;
|
|
import androidx.activity.result.ActivityResultLauncher;
|
|
import androidx.appcompat.widget.Toolbar;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
|
import androidx.viewpager2.widget.ViewPager2;
|
|
import c.a.d.e0;
|
|
import c.a.i.v4;
|
|
import c.a.k.b;
|
|
import c.a.o.b;
|
|
import c.d.b.a.a;
|
|
import c0.g;
|
|
import c0.t.o;
|
|
import c0.t.u;
|
|
import c0.z.d.a0;
|
|
import c0.z.d.m;
|
|
import com.discord.R;
|
|
import com.discord.api.directory.DirectoryEntry;
|
|
import com.discord.app.AppFragment;
|
|
import com.discord.databinding.WidgetDirectoryChannelBinding;
|
|
import com.discord.models.guild.Guild;
|
|
import com.discord.models.hubs.DirectoryEntryCategory;
|
|
import com.discord.stores.StoreStream;
|
|
import com.discord.utilities.dimen.DimenUtils;
|
|
import com.discord.utilities.hubs.HubUtilsKt;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$1;
|
|
import com.discord.utilities.rx.ObservableExtensionsKt$filterNull$2;
|
|
import com.discord.utilities.view.recycler.ViewPager2ExtensionsKt;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
import com.discord.views.directories.ServerDiscoveryHeader;
|
|
import com.discord.widgets.directories.WidgetDirectoriesViewModel;
|
|
import com.google.android.material.tabs.TabLayout;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Objects;
|
|
import kotlin.Lazy;
|
|
import kotlin.Pair;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.functions.Function1;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import kotlin.reflect.KProperty;
|
|
import rx.Observable;
|
|
/* compiled from: WidgetDirectoryChannel.kt */
|
|
public final class WidgetDirectoryChannel extends AppFragment {
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.Z(WidgetDirectoryChannel.class, "binding", "getBinding()Lcom/discord/databinding/WidgetDirectoryChannelBinding;", 0)};
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int TAB_LAYOUT_MARGINS = DimenUtils.dpToPixels(48);
|
|
private final ActivityResultLauncher<Intent> activityResult = HubUtilsKt.getAddServerActivityResultHandler(this);
|
|
private final Lazy adapter$delegate = g.lazy(new WidgetDirectoryChannel$adapter$2(this));
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding(this, WidgetDirectoryChannel$binding$2.INSTANCE, new WidgetDirectoryChannel$binding$3(this));
|
|
private final Lazy viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetDirectoriesViewModel.class), new WidgetDirectoryChannel$appActivityViewModels$$inlined$activityViewModels$1(this), new e0(WidgetDirectoryChannel$viewModel$2.INSTANCE));
|
|
|
|
/* compiled from: WidgetDirectoryChannel.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
|
|
public final int getTAB_LAYOUT_MARGINS() {
|
|
return WidgetDirectoryChannel.access$getTAB_LAYOUT_MARGINS$cp();
|
|
}
|
|
}
|
|
|
|
public WidgetDirectoryChannel() {
|
|
super(R.layout.widget_directory_channel);
|
|
}
|
|
|
|
public static final /* synthetic */ void access$configureUi(WidgetDirectoryChannel widgetDirectoryChannel, WidgetDirectoriesViewModel.ViewState viewState) {
|
|
widgetDirectoryChannel.configureUi(viewState);
|
|
}
|
|
|
|
public static final /* synthetic */ ActivityResultLauncher access$getActivityResult$p(WidgetDirectoryChannel widgetDirectoryChannel) {
|
|
return widgetDirectoryChannel.activityResult;
|
|
}
|
|
|
|
public static final /* synthetic */ int access$getTAB_LAYOUT_MARGINS$cp() {
|
|
return TAB_LAYOUT_MARGINS;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$onViewBindingDestroy(WidgetDirectoryChannel widgetDirectoryChannel, WidgetDirectoryChannelBinding widgetDirectoryChannelBinding) {
|
|
widgetDirectoryChannel.onViewBindingDestroy(widgetDirectoryChannelBinding);
|
|
}
|
|
|
|
public static /* synthetic */ void bindGestureObservers$default(WidgetDirectoryChannel widgetDirectoryChannel, boolean z2, WidgetDirectoryChannelBinding widgetDirectoryChannelBinding, int i, Object obj) {
|
|
if ((i & 2) != 0) {
|
|
widgetDirectoryChannelBinding = null;
|
|
}
|
|
widgetDirectoryChannel.bindGestureObservers(z2, widgetDirectoryChannelBinding);
|
|
}
|
|
|
|
private final void configureUi(WidgetDirectoriesViewModel.ViewState viewState) {
|
|
Guild guild = viewState.getGuild();
|
|
int i = 0;
|
|
if (guild != null) {
|
|
getBinding().f.d.setOnClickListener(new WidgetDirectoryChannel$configureUi$$inlined$let$lambda$1(guild, this));
|
|
TextView textView = getBinding().f.b;
|
|
m.checkNotNullExpressionValue(textView, "binding.widgetDirectoryC….itemDirectoryEmptyHeader");
|
|
textView.setText(b.k(this, R.string.hub_directory_channel_empty_title, new Object[]{guild.getName()}, null, 4));
|
|
}
|
|
ServerDiscoveryHeader serverDiscoveryHeader = getBinding().f2213c;
|
|
serverDiscoveryHeader.setButtonOnClickListener(new WidgetDirectoryChannel$configureUi$$inlined$apply$lambda$1(serverDiscoveryHeader, viewState));
|
|
List<DirectoryEntry> invoke = viewState.getDirectories().invoke();
|
|
boolean z2 = invoke != null && (invoke.isEmpty() ^ true);
|
|
ServerDiscoveryHeader serverDiscoveryHeader2 = getBinding().f2213c;
|
|
m.checkNotNullExpressionValue(serverDiscoveryHeader2, "binding.header");
|
|
serverDiscoveryHeader2.setVisibility(z2 ? 0 : 8);
|
|
v4 v4Var = getBinding().f;
|
|
m.checkNotNullExpressionValue(v4Var, "binding.widgetDirectoryChannelEmpty");
|
|
LinearLayout linearLayout = v4Var.a;
|
|
m.checkNotNullExpressionValue(linearLayout, "binding.widgetDirectoryChannelEmpty.root");
|
|
linearLayout.setVisibility(z2 ^ true ? 0 : 8);
|
|
Map<Integer, Integer> invoke2 = viewState.getTabs().invoke();
|
|
boolean z3 = !(invoke2 == null || invoke2.isEmpty());
|
|
toggleHeaderMargins(z3);
|
|
TabLayout tabLayout = getBinding().d;
|
|
m.checkNotNullExpressionValue(tabLayout, "binding.tabs");
|
|
if (!z3) {
|
|
i = 8;
|
|
}
|
|
tabLayout.setVisibility(i);
|
|
WidgetDirectoryChannelViewPagerAdapter adapter = getAdapter();
|
|
List<Pair<DirectoryEntryCategory, Integer>> mappedTabs = viewState.getMappedTabs();
|
|
ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(mappedTabs, 10));
|
|
Iterator<T> it = mappedTabs.iterator();
|
|
while (it.hasNext()) {
|
|
arrayList.add((DirectoryEntryCategory) ((Pair) it.next()).getFirst());
|
|
}
|
|
adapter.setTabs(u.toList(arrayList));
|
|
}
|
|
|
|
private final void onViewBindingDestroy(WidgetDirectoryChannelBinding widgetDirectoryChannelBinding) {
|
|
bindGestureObservers(false, widgetDirectoryChannelBinding);
|
|
}
|
|
|
|
private final void toggleHeaderMargins(boolean z2) {
|
|
int i = z2 ? TAB_LAYOUT_MARGINS : 0;
|
|
ServerDiscoveryHeader serverDiscoveryHeader = getBinding().f2213c;
|
|
m.checkNotNullExpressionValue(serverDiscoveryHeader, "binding.header");
|
|
ViewGroup.LayoutParams layoutParams = serverDiscoveryHeader.getLayoutParams();
|
|
Objects.requireNonNull(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
|
|
ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
|
|
marginLayoutParams.bottomMargin = i;
|
|
serverDiscoveryHeader.setLayoutParams(marginLayoutParams);
|
|
Toolbar toolbar = getBinding().b;
|
|
m.checkNotNullExpressionValue(toolbar, "binding.actionBarToolbar");
|
|
ViewGroup.LayoutParams layoutParams2 = toolbar.getLayoutParams();
|
|
Objects.requireNonNull(layoutParams2, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
|
|
ViewGroup.MarginLayoutParams marginLayoutParams2 = (ViewGroup.MarginLayoutParams) layoutParams2;
|
|
marginLayoutParams2.bottomMargin = i;
|
|
toolbar.setLayoutParams(marginLayoutParams2);
|
|
}
|
|
|
|
public final void bindGestureObservers(boolean z2, WidgetDirectoryChannelBinding widgetDirectoryChannelBinding) {
|
|
if (widgetDirectoryChannelBinding == null) {
|
|
widgetDirectoryChannelBinding = getBinding();
|
|
}
|
|
if (z2) {
|
|
c.a.o.b a = b.C0034b.a();
|
|
TabLayout tabLayout = widgetDirectoryChannelBinding.d;
|
|
m.checkNotNullExpressionValue(tabLayout, "nonNullBinding.tabs");
|
|
a.b(tabLayout);
|
|
c.a.o.b a2 = b.C0034b.a();
|
|
ViewPager2 viewPager2 = widgetDirectoryChannelBinding.e;
|
|
m.checkNotNullExpressionValue(viewPager2, "nonNullBinding.viewPager");
|
|
a2.b(viewPager2);
|
|
return;
|
|
}
|
|
c.a.o.b a3 = b.C0034b.a();
|
|
TabLayout tabLayout2 = widgetDirectoryChannelBinding.d;
|
|
m.checkNotNullExpressionValue(tabLayout2, "nonNullBinding.tabs");
|
|
a3.c(tabLayout2);
|
|
c.a.o.b a4 = b.C0034b.a();
|
|
ViewPager2 viewPager22 = widgetDirectoryChannelBinding.e;
|
|
m.checkNotNullExpressionValue(viewPager22, "nonNullBinding.viewPager");
|
|
a4.c(viewPager22);
|
|
}
|
|
|
|
public final WidgetDirectoryChannelViewPagerAdapter getAdapter() {
|
|
return (WidgetDirectoryChannelViewPagerAdapter) this.adapter$delegate.getValue();
|
|
}
|
|
|
|
public final WidgetDirectoryChannelBinding getBinding() {
|
|
return (WidgetDirectoryChannelBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
}
|
|
|
|
public final WidgetDirectoriesViewModel getViewModel() {
|
|
return (WidgetDirectoriesViewModel) this.viewModel$delegate.getValue();
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
@SuppressLint({"SetTextI18n"})
|
|
public void onViewBound(View view) {
|
|
m.checkNotNullParameter(view, "view");
|
|
super.onViewBound(view);
|
|
getBinding().f.f180c.setOnClickListener(new WidgetDirectoryChannel$onViewBound$1(this));
|
|
ServerDiscoveryHeader serverDiscoveryHeader = getBinding().f2213c;
|
|
serverDiscoveryHeader.setTitle(getString(R.string.hub_directory_search_title));
|
|
serverDiscoveryHeader.setDescription(getString(R.string.hub_directory_search_subtitle));
|
|
getBinding().e.setAdapter(getAdapter());
|
|
TabLayout tabLayout = getBinding().d;
|
|
ViewPager2 viewPager2 = getBinding().e;
|
|
m.checkNotNullExpressionValue(viewPager2, "binding.viewPager");
|
|
ViewPager2ExtensionsKt.setUpWithViewPager2(tabLayout, viewPager2, new WidgetDirectoryChannel$onViewBound$$inlined$apply$lambda$1(this));
|
|
bindGestureObservers$default(this, true, null, 2, null);
|
|
Observable<Long> q = StoreStream.Companion.getGuildSelected().observeSelectedGuildId().q();
|
|
m.checkNotNullExpressionValue(q, "StoreStream\n .get… .distinctUntilChanged()");
|
|
Observable<R> F = q.x(ObservableExtensionsKt$filterNull$1.INSTANCE).F(ObservableExtensionsKt$filterNull$2.INSTANCE);
|
|
m.checkNotNullExpressionValue(F, "filter { it != null }.map { it!! }");
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui(F), WidgetDirectoryChannel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetDirectoryChannel$onViewBound$5(this), 62, (Object) null);
|
|
}
|
|
|
|
@Override // com.discord.app.AppFragment
|
|
public void onViewBoundOrOnResume() {
|
|
super.onViewBoundOrOnResume();
|
|
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null), WidgetDirectoryChannel.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetDirectoryChannel$onViewBoundOrOnResume$1(this), 62, (Object) null);
|
|
}
|
|
}
|