discord-jadx/app/src/main/java/com/discord/widgets/announcements/WidgetChannelFollowSheet.java

280 lines
14 KiB
Java

package com.discord.widgets.announcements;
import a0.a.a.b;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentViewModelLazyKt;
import c.a.d.h0;
import c.a.d.j0;
import c.d.b.a.a;
import com.airbnb.lottie.parser.AnimatableValueParser;
import com.discord.api.channel.Channel;
import com.discord.app.AppBottomSheet;
import com.discord.app.AppViewFlipper;
import com.discord.databinding.WidgetChannelFollowSheetBinding;
import com.discord.models.guild.Guild;
import com.discord.utilities.color.ColorCompat;
import com.discord.utilities.icon.IconUtils;
import com.discord.utilities.images.MGImages;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
import com.discord.widgets.announcements.WidgetChannelFollowSheetViewModel;
import com.discord.widgets.channels.WidgetChannelSelector;
import com.discord.widgets.guilds.WidgetGuildSelector;
import com.facebook.drawee.view.SimpleDraweeView;
import com.google.android.material.button.MaterialButton;
import d0.z.d.a0;
import d0.z.d.m;
import java.util.Set;
import kotlin.Lazy;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
import rx.Observable;
/* compiled from: WidgetChannelFollowSheet.kt */
public final class WidgetChannelFollowSheet extends AppBottomSheet {
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetChannelFollowSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChannelFollowSheetBinding;", 0)};
public static final Companion Companion = new Companion(null);
private static final String REQUEST_KEY_CHANNEL_FOLLOW = "REQUEST_KEY_CHANNEL_FOLLOW_CHANNEL";
private static final int VIEW_INDEX_FOLLOW = 0;
private static final int VIEW_INDEX_NO_AVAILABLE_GUILDS = 1;
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetChannelFollowSheet$binding$2.INSTANCE, null, 2, null);
private final Lazy viewModel$delegate;
/* compiled from: WidgetChannelFollowSheet.kt */
public static final class ChannelFollowChannelFilterFunction implements WidgetChannelSelector.FilterFunction {
private final Set<Long> channelIds;
private final long selectedGuildId;
public ChannelFollowChannelFilterFunction(long j, Set<Long> set) {
m.checkNotNullParameter(set, "channelIds");
this.selectedGuildId = j;
this.channelIds = set;
}
private final long component1() {
return this.selectedGuildId;
}
private final Set<Long> component2() {
return this.channelIds;
}
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.widgets.announcements.WidgetChannelFollowSheet$ChannelFollowChannelFilterFunction */
/* JADX WARN: Multi-variable type inference failed */
public static /* synthetic */ ChannelFollowChannelFilterFunction copy$default(ChannelFollowChannelFilterFunction channelFollowChannelFilterFunction, long j, Set set, int i, Object obj) {
if ((i & 1) != 0) {
j = channelFollowChannelFilterFunction.selectedGuildId;
}
if ((i & 2) != 0) {
set = channelFollowChannelFilterFunction.channelIds;
}
return channelFollowChannelFilterFunction.copy(j, set);
}
public final ChannelFollowChannelFilterFunction copy(long j, Set<Long> set) {
m.checkNotNullParameter(set, "channelIds");
return new ChannelFollowChannelFilterFunction(j, set);
}
@Override // java.lang.Object
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof ChannelFollowChannelFilterFunction)) {
return false;
}
ChannelFollowChannelFilterFunction channelFollowChannelFilterFunction = (ChannelFollowChannelFilterFunction) obj;
return this.selectedGuildId == channelFollowChannelFilterFunction.selectedGuildId && m.areEqual(this.channelIds, channelFollowChannelFilterFunction.channelIds);
}
@Override // java.lang.Object
public int hashCode() {
int a = b.a(this.selectedGuildId) * 31;
Set<Long> set = this.channelIds;
return a + (set != null ? set.hashCode() : 0);
}
@Override // com.discord.widgets.channels.WidgetChannelSelector.FilterFunction
public boolean includeChannel(Channel channel) {
m.checkNotNullParameter(channel, "channel");
return this.channelIds.contains(Long.valueOf(channel.h())) && channel.f() == this.selectedGuildId;
}
@Override // java.lang.Object
public String toString() {
StringBuilder L = a.L("ChannelFollowChannelFilterFunction(selectedGuildId=");
L.append(this.selectedGuildId);
L.append(", channelIds=");
L.append(this.channelIds);
L.append(")");
return L.toString();
}
}
/* compiled from: WidgetChannelFollowSheet.kt */
public static final class Companion {
private Companion() {
}
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
this();
}
public final void show(FragmentManager fragmentManager, long j, long j2) {
m.checkNotNullParameter(fragmentManager, "fragmentManager");
WidgetChannelFollowSheet widgetChannelFollowSheet = new WidgetChannelFollowSheet();
Bundle bundle = new Bundle();
bundle.putLong("com.discord.intent.extra.EXTRA_CHANNEL_ID", j);
bundle.putLong("com.discord.intent.extra.EXTRA_GUILD_ID", j2);
widgetChannelFollowSheet.setArguments(bundle);
widgetChannelFollowSheet.show(fragmentManager, WidgetChannelFollowSheet.class.getName());
}
}
public WidgetChannelFollowSheet() {
super(false, 1, null);
WidgetChannelFollowSheet$viewModel$2 widgetChannelFollowSheet$viewModel$2 = new WidgetChannelFollowSheet$viewModel$2(this);
h0 h0Var = new h0(this);
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(WidgetChannelFollowSheetViewModel.class), new WidgetChannelFollowSheet$appViewModels$$inlined$viewModels$1(h0Var), new j0(widgetChannelFollowSheet$viewModel$2));
}
public static final /* synthetic */ void access$configureUI(WidgetChannelFollowSheet widgetChannelFollowSheet, WidgetChannelFollowSheetViewModel.ViewState.Loaded loaded) {
widgetChannelFollowSheet.configureUI(loaded);
}
public static final /* synthetic */ Bundle access$getArgumentsOrDefault$p(WidgetChannelFollowSheet widgetChannelFollowSheet) {
return widgetChannelFollowSheet.getArgumentsOrDefault();
}
public static final /* synthetic */ WidgetChannelFollowSheetViewModel access$getViewModel$p(WidgetChannelFollowSheet widgetChannelFollowSheet) {
return widgetChannelFollowSheet.getViewModel();
}
private final void configureChannelSelector(WidgetChannelFollowSheetViewModel.ViewState.Loaded loaded) {
int i;
Guild selectedGuild = loaded.getSelectedGuild();
Channel selectedChannel = loaded.getSelectedChannel();
if (selectedGuild != null) {
getBinding().e.setOnClickListener(new WidgetChannelFollowSheet$configureChannelSelector$1(this, selectedGuild, loaded));
}
if (selectedChannel != null) {
i = 2130968946;
TextView textView = getBinding().g;
m.checkNotNullExpressionValue(textView, "binding.channelFollowSelectedChannelName");
Context requireContext = requireContext();
m.checkNotNullExpressionValue(requireContext, "requireContext()");
textView.setText(AnimatableValueParser.A0(selectedChannel, requireContext, false, 2));
MaterialButton materialButton = getBinding().i;
m.checkNotNullExpressionValue(materialButton, "binding.createChannelFollowerButton");
materialButton.setEnabled(true);
getBinding().i.setOnClickListener(new WidgetChannelFollowSheet$configureChannelSelector$2(this, selectedChannel));
} else {
i = 2130968949;
TextView textView2 = getBinding().g;
m.checkNotNullExpressionValue(textView2, "binding.channelFollowSelectedChannelName");
textView2.setText(getString(2131893215));
MaterialButton materialButton2 = getBinding().i;
m.checkNotNullExpressionValue(materialButton2, "binding.createChannelFollowerButton");
materialButton2.setEnabled(false);
}
TextView textView3 = getBinding().g;
TextView textView4 = getBinding().h;
m.checkNotNullExpressionValue(textView4, "binding.channelFollowSelectedGuildName");
textView3.setTextColor(ColorCompat.getThemedColor(textView4, i));
}
private final void configureGuildSelector(WidgetChannelFollowSheetViewModel.ViewState.Loaded loaded) {
String str;
getBinding().f.setOnClickListener(new WidgetChannelFollowSheet$configureGuildSelector$1(this, loaded));
Guild selectedGuild = loaded.getSelectedGuild();
TextView textView = getBinding().h;
m.checkNotNullExpressionValue(textView, "binding.channelFollowSelectedGuildName");
if (selectedGuild == null || (str = selectedGuild.getName()) == null) {
str = getString(2131893215);
}
textView.setText(str);
int i = selectedGuild != null ? 2130968946 : 2130968949;
TextView textView2 = getBinding().h;
TextView textView3 = getBinding().h;
m.checkNotNullExpressionValue(textView3, "binding.channelFollowSelectedGuildName");
textView2.setTextColor(ColorCompat.getThemedColor(textView3, i));
}
private final void configureUI(WidgetChannelFollowSheetViewModel.ViewState.Loaded loaded) {
SimpleDraweeView simpleDraweeView = getBinding().d;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.channelFollowGuildIcon");
MGImages.setImage$default(simpleDraweeView, IconUtils.getForGuild$default(loaded.getSourceGuild(), null, false, null, 14, null), 0, 0, false, null, null, 124, null);
Channel sourceChannel = loaded.getSourceChannel();
if (sourceChannel != null) {
TextView textView = getBinding().b;
m.checkNotNullExpressionValue(textView, "binding.channelFollowChannelName");
Context requireContext = requireContext();
m.checkNotNullExpressionValue(requireContext, "requireContext()");
textView.setText(AnimatableValueParser.z0(sourceChannel, requireContext, false));
}
if (loaded.getAvailableGuilds().isEmpty()) {
AppViewFlipper appViewFlipper = getBinding().j;
m.checkNotNullExpressionValue(appViewFlipper, "binding.followSheetViewFlipper");
appViewFlipper.setDisplayedChild(1);
} else {
AppViewFlipper appViewFlipper2 = getBinding().j;
m.checkNotNullExpressionValue(appViewFlipper2, "binding.followSheetViewFlipper");
appViewFlipper2.setDisplayedChild(0);
configureGuildSelector(loaded);
configureChannelSelector(loaded);
}
if (loaded.getErrorTextRes() != null) {
getBinding().f1686c.setText(loaded.getErrorTextRes().intValue());
TextView textView2 = getBinding().f1686c;
m.checkNotNullExpressionValue(textView2, "binding.channelFollowErrorText");
textView2.setVisibility(0);
return;
}
TextView textView3 = getBinding().f1686c;
m.checkNotNullExpressionValue(textView3, "binding.channelFollowErrorText");
textView3.setVisibility(8);
}
private final WidgetChannelFollowSheetBinding getBinding() {
return (WidgetChannelFollowSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
}
private final WidgetChannelFollowSheetViewModel getViewModel() {
return (WidgetChannelFollowSheetViewModel) this.viewModel$delegate.getValue();
}
public static final void show(FragmentManager fragmentManager, long j, long j2) {
Companion.show(fragmentManager, j, j2);
}
@Override // com.discord.app.AppBottomSheet
public int getContentViewResId() {
return 2131558865;
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.DialogFragment, androidx.fragment.app.Fragment
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
WidgetChannelSelector.Companion.registerForResult(this, "REQUEST_KEY_CHANNEL_FOLLOW_CHANNEL", true, new WidgetChannelFollowSheet$onCreate$1(this));
WidgetGuildSelector.Companion.registerForResult$default(WidgetGuildSelector.Companion, this, null, true, new WidgetChannelFollowSheet$onCreate$2(this), 2, null);
}
@Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment
public void onResume() {
super.onResume();
Observable<WidgetChannelFollowSheetViewModel.ViewState> r = getViewModel().observeViewState().r();
m.checkNotNullExpressionValue(r, "viewModel\n .obser… .distinctUntilChanged()");
Observable<R> F = r.x(WidgetChannelFollowSheet$onResume$$inlined$filterIs$1.INSTANCE).F(WidgetChannelFollowSheet$onResume$$inlined$filterIs$2.INSTANCE);
m.checkNotNullExpressionValue(F, "filter { it is T }.map { it as T }");
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(F, this), WidgetChannelFollowSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelFollowSheet$onResume$1(this), 62, (Object) null);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeEvents(), this), WidgetChannelFollowSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelFollowSheet$onResume$2(this), 62, (Object) null);
}
}