package com.discord.widgets.channels.list; import android.content.Context; import android.os.Bundle; import android.view.View; import android.widget.ImageView; import android.widget.TextView; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import c.a.k.b; 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.databinding.WidgetChannelsListItemActionsBinding; import com.discord.models.guild.Guild; import com.discord.models.user.User; import com.discord.stores.StoreStream; import com.discord.utilities.drawable.DrawableCompat; import com.discord.utilities.icon.IconUtils; import com.discord.utilities.images.MGImages; import com.discord.utilities.permissions.PermissionUtils; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.threads.ThreadUtils; import com.discord.utilities.viewbinding.FragmentViewBindingDelegate; import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt; import com.facebook.drawee.view.SimpleDraweeView; import d0.z.d.m; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.reflect.KProperty; import rx.Observable; import rx.subscriptions.CompositeSubscription; /* compiled from: WidgetChannelsListItemChannelActions.kt */ public final class WidgetChannelsListItemChannelActions extends AppBottomSheet { public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.V(WidgetChannelsListItemChannelActions.class, "binding", "getBinding()Lcom/discord/databinding/WidgetChannelsListItemActionsBinding;", 0)}; public static final Companion Companion = new Companion(null); private static final String INTENT_EXTRA_CHANNEL_ID = "INTENT_EXTRA_CHANNEL_ID"; private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetChannelsListItemChannelActions$binding$2.INSTANCE, null, 2, null); /* compiled from: WidgetChannelsListItemChannelActions.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final void show(FragmentManager fragmentManager, long j) { m.checkNotNullParameter(fragmentManager, "fragmentManager"); WidgetChannelsListItemChannelActions widgetChannelsListItemChannelActions = new WidgetChannelsListItemChannelActions(); Bundle bundle = new Bundle(); bundle.putLong("INTENT_EXTRA_CHANNEL_ID", j); widgetChannelsListItemChannelActions.setArguments(bundle); widgetChannelsListItemChannelActions.show(fragmentManager, WidgetChannelsListItemChannelActions.class.getName()); } } /* compiled from: WidgetChannelsListItemChannelActions.kt */ public static final class Model { public static final Companion Companion = new Companion(null); private final boolean canCreateInstantInvite; private final boolean canManageChannel; private final Channel channel; private final Guild guild; private final boolean isDeveloper = StoreStream.Companion.getUserSettings().getIsDeveloperMode(); private final boolean isMuted; private final Long permissions; private final boolean showStageNotificationSurfaces; /* compiled from: WidgetChannelsListItemChannelActions.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final Observable get(long j) { Observable Y = StoreStream.Companion.getChannels().observeChannel(j).Y(new WidgetChannelsListItemChannelActions$Model$Companion$get$1(j)); m.checkNotNullExpressionValue(Y, "StoreStream.getChannels(… }\n }"); Observable r = ObservableExtensionsKt.computationLatest(Y).r(); m.checkNotNullExpressionValue(r, "StoreStream.getChannels(… .distinctUntilChanged()"); return r; } } public Model(Channel channel, Guild guild, Long l, boolean z2, boolean z3) { m.checkNotNullParameter(channel, "channel"); this.channel = channel; this.guild = guild; this.permissions = l; this.isMuted = z2; this.showStageNotificationSurfaces = z3; this.canManageChannel = PermissionUtils.can(16, l) || AnimatableValueParser.r1(channel); this.canCreateInstantInvite = PermissionUtils.can(1, l); } public static /* synthetic */ Model copy$default(Model model, Channel channel, Guild guild, Long l, boolean z2, boolean z3, int i, Object obj) { if ((i & 1) != 0) { channel = model.channel; } if ((i & 2) != 0) { guild = model.guild; } if ((i & 4) != 0) { l = model.permissions; } if ((i & 8) != 0) { z2 = model.isMuted; } if ((i & 16) != 0) { z3 = model.showStageNotificationSurfaces; } return model.copy(channel, guild, l, z2, z3); } public final Channel component1() { return this.channel; } public final Guild component2() { return this.guild; } public final Long component3() { return this.permissions; } public final boolean component4() { return this.isMuted; } public final boolean component5() { return this.showStageNotificationSurfaces; } public final Model copy(Channel channel, Guild guild, Long l, boolean z2, boolean z3) { m.checkNotNullParameter(channel, "channel"); return new Model(channel, guild, l, z2, z3); } public boolean equals(Object obj) { if (this == obj) { return true; } if (!(obj instanceof Model)) { return false; } Model model = (Model) obj; return m.areEqual(this.channel, model.channel) && m.areEqual(this.guild, model.guild) && m.areEqual(this.permissions, model.permissions) && this.isMuted == model.isMuted && this.showStageNotificationSurfaces == model.showStageNotificationSurfaces; } public final boolean getCanCreateInstantInvite() { return this.canCreateInstantInvite; } public final boolean getCanManageChannel() { return this.canManageChannel; } public final Channel getChannel() { return this.channel; } public final Guild getGuild() { return this.guild; } public final CharSequence getMuteChannelText(Context context) { m.checkNotNullParameter(context, "context"); return this.isMuted ? b.g(context, 2131894292, new Object[0], null, 4) : b.g(context, 2131891453, new Object[]{AnimatableValueParser.A0(this.channel, context, false, 2)}, null, 4); } public final int getMuteIconResId(Context context) { m.checkNotNullParameter(context, "context"); return DrawableCompat.getThemedDrawableRes$default(context, this.isMuted ? 2130969390 : 2130969389, 0, 2, (Object) null); } public final Long getPermissions() { return this.permissions; } public final boolean getShowStageNotificationSurfaces() { return this.showStageNotificationSurfaces; } public int hashCode() { Channel channel = this.channel; int i = 0; int hashCode = (channel != null ? channel.hashCode() : 0) * 31; Guild guild = this.guild; int hashCode2 = (hashCode + (guild != null ? guild.hashCode() : 0)) * 31; Long l = this.permissions; if (l != null) { i = l.hashCode(); } int i2 = (hashCode2 + i) * 31; boolean z2 = this.isMuted; int i3 = 1; if (z2) { z2 = true; } int i4 = z2 ? 1 : 0; int i5 = z2 ? 1 : 0; int i6 = z2 ? 1 : 0; int i7 = (i2 + i4) * 31; boolean z3 = this.showStageNotificationSurfaces; if (!z3) { i3 = z3 ? 1 : 0; } return i7 + i3; } public final boolean isDeveloper() { return this.isDeveloper; } public final boolean isMuted() { return this.isMuted; } public String toString() { StringBuilder K = a.K("Model(channel="); K.append(this.channel); K.append(", guild="); K.append(this.guild); K.append(", permissions="); K.append(this.permissions); K.append(", isMuted="); K.append(this.isMuted); K.append(", showStageNotificationSurfaces="); return a.F(K, this.showStageNotificationSurfaces, ")"); } } public WidgetChannelsListItemChannelActions() { super(false, 1, null); } public static final /* synthetic */ void access$configureUI(WidgetChannelsListItemChannelActions widgetChannelsListItemChannelActions, Model model) { widgetChannelsListItemChannelActions.configureUI(model); } private final void configureUI(Model model) { if (model == null) { dismiss(); return; } if (model.getGuild() != null) { SimpleDraweeView simpleDraweeView = getBinding().f; m.checkNotNullExpressionValue(simpleDraweeView, "binding.channelsListItemTextActionsIcon"); IconUtils.setIcon$default((ImageView) simpleDraweeView, model.getGuild(), 0, (MGImages.ChangeDetector) null, false, 28, (Object) null); } else { SimpleDraweeView simpleDraweeView2 = getBinding().f; m.checkNotNullExpressionValue(simpleDraweeView2, "binding.channelsListItemTextActionsIcon"); IconUtils.setIcon$default(simpleDraweeView2, model.getChannel(), 0, null, 12, null); } TextView textView = getBinding().g; m.checkNotNullExpressionValue(textView, "binding.channelsListItemTextActionsTitle"); Channel channel = model.getChannel(); Context requireContext = requireContext(); m.checkNotNullExpressionValue(requireContext, "requireContext()"); int i = 0; textView.setText(AnimatableValueParser.A0(channel, requireContext, false, 2)); User v0 = AnimatableValueParser.v0(model.getChannel()); TextView textView2 = getBinding().i; boolean z2 = true; textView2.setVisibility(v0 != null ? 0 : 8); textView2.setOnClickListener(new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$1(this, v0)); TextView textView3 = getBinding().e; textView3.setVisibility(model.getCanCreateInstantInvite() ? 0 : 8); setOnClickAndDismissListener(textView3, new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$2(textView3, this, model)); TextView textView4 = getBinding().k; textView4.setVisibility(AnimatableValueParser.z1(model.getChannel()) || AnimatableValueParser.f1(model.getChannel()) ? 0 : 8); setOnClickAndDismissListener(textView4, new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$3(textView4, this, model)); Context context = textView4.getContext(); m.checkNotNullExpressionValue(context, "context"); textView4.setCompoundDrawablesWithIntrinsicBounds(model.getMuteIconResId(context), 0, 0, 0); Context context2 = textView4.getContext(); m.checkNotNullExpressionValue(context2, "context"); textView4.setText(model.getMuteChannelText(context2)); TextView textView5 = getBinding().l; textView5.setVisibility(ThreadUtils.INSTANCE.isThreadsEnabled(model.getChannel().f()) && AnimatableValueParser.B1(model.getChannel()) ? 0 : 8); setOnClickAndDismissListener(textView5, new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$4(textView5, this, model)); TextView textView6 = getBinding().f1712c; textView6.setVisibility(model.getCanManageChannel() ? 0 : 8); setOnClickAndDismissListener(textView6, new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$5(this, model)); textView6.setText(getSettingsText(model.getChannel(), model.getCanManageChannel())); TextView textView7 = getBinding().b; textView7.setVisibility(AnimatableValueParser.l1(model.getChannel()) || AnimatableValueParser.f1(model.getChannel()) || (AnimatableValueParser.w1(model.getChannel()) && model.getShowStageNotificationSurfaces()) ? 0 : 8); textView7.setOnClickListener(new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$6(model)); View view = getBinding().j; if (!AnimatableValueParser.z1(model.getChannel()) && !AnimatableValueParser.f1(model.getChannel())) { z2 = false; } view.setVisibility(z2 ? 0 : 8); setOnClickAndDismissListener(view, new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$7(this, model)); View view2 = getBinding().h; m.checkNotNullExpressionValue(view2, "binding.developerDivider"); view2.setVisibility(model.isDeveloper() ? 0 : 8); View view3 = getBinding().d; if (!model.isDeveloper()) { i = 8; } view3.setVisibility(i); setOnClickAndDismissListener(view3, new WidgetChannelsListItemChannelActions$configureUI$$inlined$apply$lambda$8(this, model)); } private final WidgetChannelsListItemActionsBinding getBinding() { return (WidgetChannelsListItemActionsBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]); } private final String getSettingsText(Channel channel, boolean z2) { String string = getString(AnimatableValueParser.f1(channel) ? 2131888205 : z2 ? 2131888206 : !z2 ? 2131887329 : 2131893114); m.checkNotNullExpressionValue(string, "getString(\n when {\n…_empty_string\n }\n )"); return string; } public static final void show(FragmentManager fragmentManager, long j) { Companion.show(fragmentManager, j); } @Override // com.discord.app.AppBottomSheet public void bindSubscriptions(CompositeSubscription compositeSubscription) { m.checkNotNullParameter(compositeSubscription, "compositeSubscription"); super.bindSubscriptions(compositeSubscription); ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(Model.Companion.get(getArgumentsOrDefault().getLong("INTENT_EXTRA_CHANNEL_ID", -1)), this, null, 2, null), WidgetChannelsListItemChannelActions.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetChannelsListItemChannelActions$bindSubscriptions$1(this), 62, (Object) null); } @Override // com.discord.app.AppBottomSheet public int getContentViewResId() { return 2131558903; } @Override // com.discord.app.AppBottomSheet, androidx.fragment.app.Fragment public void onPause() { super.onPause(); dismiss(); } }