package com.discord.widgets.stickers; import android.content.Context; import android.content.res.ColorStateList; import android.os.Bundle; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentManager; import androidx.fragment.app.FragmentViewModelLazyKt; import c.a.d.f0; import c.a.d.h0; import c.a.k.b; import c.d.b.a.a; import com.discord.R; import com.discord.api.guild.GuildFeature; import com.discord.api.sticker.Sticker; import com.discord.api.sticker.StickerType; import com.discord.app.AppBottomSheet; import com.discord.app.AppViewFlipper; import com.discord.databinding.WidgetGuildStickerSheetBinding; import com.discord.models.guild.Guild; import com.discord.utilities.color.ColorCompat; import com.discord.utilities.drawable.DrawableCompat; import com.discord.utilities.icon.IconUtils; import com.discord.utilities.images.MGImages; import com.discord.utilities.locale.LocaleManager; import com.discord.utilities.rx.ObservableExtensionsKt; import com.discord.utilities.viewbinding.FragmentViewBindingDelegate; import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt; import com.discord.widgets.stickers.GuildStickerSheetViewModel; 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.text.NumberFormat; 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; import rx.subscriptions.CompositeSubscription; /* compiled from: WidgetGuildStickerSheet.kt */ public final class WidgetGuildStickerSheet extends AppBottomSheet { public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.W(WidgetGuildStickerSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetGuildStickerSheetBinding;", 0)}; public static final Companion Companion = new Companion(null); private static final int VIEW_CONTENT = 0; private static final int VIEW_LOADING = 1; private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetGuildStickerSheet$binding$2.INSTANCE, null, 2, null); private final Lazy viewModel$delegate; /* compiled from: WidgetGuildStickerSheet.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final void show(FragmentManager fragmentManager, Sticker sticker) { m.checkNotNullParameter(fragmentManager, "fragmentManager"); m.checkNotNullParameter(sticker, "sticker"); if (sticker.k() == StickerType.GUILD) { WidgetGuildStickerSheet widgetGuildStickerSheet = new WidgetGuildStickerSheet(); Bundle bundle = new Bundle(); bundle.putSerializable("com.discord.intent.extra.EXTRA_STICKER", sticker); widgetGuildStickerSheet.setArguments(bundle); widgetGuildStickerSheet.show(fragmentManager, WidgetGuildStickerSheet.class.getName()); } } } public WidgetGuildStickerSheet() { super(false, 1, null); WidgetGuildStickerSheet$viewModel$2 widgetGuildStickerSheet$viewModel$2 = new WidgetGuildStickerSheet$viewModel$2(this); f0 f0Var = new f0(this); this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(GuildStickerSheetViewModel.class), new WidgetGuildStickerSheet$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetGuildStickerSheet$viewModel$2)); } public static final /* synthetic */ void access$configureUI(WidgetGuildStickerSheet widgetGuildStickerSheet, GuildStickerSheetViewModel.ViewState.Loaded loaded) { widgetGuildStickerSheet.configureUI(loaded); } public static final /* synthetic */ Bundle access$getArgumentsOrDefault$p(WidgetGuildStickerSheet widgetGuildStickerSheet) { return widgetGuildStickerSheet.getArgumentsOrDefault(); } public static final /* synthetic */ GuildStickerSheetViewModel access$getViewModel$p(WidgetGuildStickerSheet widgetGuildStickerSheet) { return widgetGuildStickerSheet.getViewModel(); } public static final /* synthetic */ void access$showLoading(WidgetGuildStickerSheet widgetGuildStickerSheet) { widgetGuildStickerSheet.showLoading(); } private final void configureButtons(boolean z2, boolean z3, Guild guild) { WidgetGuildStickerSheetBinding binding = getBinding(); if (guild == null) { FrameLayout frameLayout = binding.b; m.checkNotNullExpressionValue(frameLayout, "guildStickerSheetButtonContainer"); frameLayout.setVisibility(8); } else if (!z2) { FrameLayout frameLayout2 = binding.b; m.checkNotNullExpressionValue(frameLayout2, "guildStickerSheetButtonContainer"); frameLayout2.setVisibility(0); MaterialButton materialButton = binding.l; m.checkNotNullExpressionValue(materialButton, "guildStickerSheetPremiumBtn"); materialButton.setVisibility(0); MaterialButton materialButton2 = binding.k; m.checkNotNullExpressionValue(materialButton2, "guildStickerSheetJoinBtn"); materialButton2.setVisibility(8); binding.l.setOnClickListener(new WidgetGuildStickerSheet$configureButtons$$inlined$with$lambda$1(this, guild, z2, z3)); } else if (!z3) { FrameLayout frameLayout3 = binding.b; m.checkNotNullExpressionValue(frameLayout3, "guildStickerSheetButtonContainer"); frameLayout3.setVisibility(0); MaterialButton materialButton3 = binding.l; m.checkNotNullExpressionValue(materialButton3, "guildStickerSheetPremiumBtn"); materialButton3.setVisibility(8); MaterialButton materialButton4 = binding.k; m.checkNotNullExpressionValue(materialButton4, "guildStickerSheetJoinBtn"); materialButton4.setVisibility(0); binding.k.setOnClickListener(new WidgetGuildStickerSheet$configureButtons$$inlined$with$lambda$2(this, guild, z2, z3)); } else { FrameLayout frameLayout4 = binding.b; m.checkNotNullExpressionValue(frameLayout4, "guildStickerSheetButtonContainer"); frameLayout4.setVisibility(8); } } private final void configureGuildSection(Guild guild, boolean z2, boolean z3, Integer num) { WidgetGuildStickerSheetBinding binding = getBinding(); if (guild == null || z2) { LinearLayout linearLayout = binding.e; m.checkNotNullExpressionValue(linearLayout, "guildStickerSheetGuildContainer"); linearLayout.setVisibility(8); return; } LinearLayout linearLayout2 = binding.e; m.checkNotNullExpressionValue(linearLayout2, "guildStickerSheetGuildContainer"); linearLayout2.setVisibility(0); if (guild.hasIcon()) { SimpleDraweeView simpleDraweeView = binding.f; m.checkNotNullExpressionValue(simpleDraweeView, "guildStickerSheetGuildIcon"); IconUtils.setIcon$default((ImageView) simpleDraweeView, guild, 0, (MGImages.ChangeDetector) null, true, 12, (Object) null); } else { binding.h.setBackgroundResource(R.drawable.drawable_circle_black); int themedColor = ColorCompat.getThemedColor(requireContext(), (int) R.attr.colorBackgroundSecondary); FrameLayout frameLayout = binding.h; m.checkNotNullExpressionValue(frameLayout, "guildStickerSheetGuildIconWrapper"); frameLayout.setBackgroundTintList(ColorStateList.valueOf(themedColor)); TextView textView = binding.g; m.checkNotNullExpressionValue(textView, "guildStickerSheetGuildIconText"); textView.setText(guild.getShortName()); } int i = guild.getFeatures().contains(GuildFeature.PARTNERED) ? R.drawable.ic_partnered_badge_banner : guild.getFeatures().contains(GuildFeature.VERIFIED) ? R.drawable.ic_verified_badge_banner : 0; TextView textView2 = binding.j; m.checkNotNullExpressionValue(textView2, "guildStickerSheetGuildName"); DrawableCompat.setCompoundDrawablesCompat(textView2, i, 0, 0, 0); TextView textView3 = binding.j; m.checkNotNullExpressionValue(textView3, "guildStickerSheetGuildName"); textView3.setText(guild.getName()); int i2 = z3 ? R.string.sticker_popout_public_server : R.string.sticker_popout_private_server; String str = null; CharSequence k = b.k(this, i2, new Object[0], null, 4); if (num != null) { String format = NumberFormat.getNumberInstance(new LocaleManager().getPrimaryLocale(requireContext())).format(Integer.valueOf(num.intValue())); str = b.k(this, R.string.instant_invite_guild_members_online, new Object[]{format}, null, 4).toString() + " • "; } if (str == null) { str = ""; } TextView textView4 = binding.i; m.checkNotNullExpressionValue(textView4, "guildStickerSheetGuildInfo"); textView4.setText(str + k); } private final void configureUI(GuildStickerSheetViewModel.ViewState.Loaded loaded) { Sticker component1 = loaded.component1(); boolean component2 = loaded.component2(); boolean component3 = loaded.component3(); boolean isPublic = loaded.getGuildStickerGuildInfo().isPublic(); boolean isUserInGuild = loaded.getGuildStickerGuildInfo().isUserInGuild(); GuildStickerSheetViewModel.Companion.GuildStickerGuildInfo guildStickerGuildInfo = loaded.getGuildStickerGuildInfo(); Integer num = null; if (!(guildStickerGuildInfo instanceof GuildStickerSheetViewModel.Companion.GuildStickerGuildInfo.Known)) { guildStickerGuildInfo = null; } GuildStickerSheetViewModel.Companion.GuildStickerGuildInfo.Known known = (GuildStickerSheetViewModel.Companion.GuildStickerGuildInfo.Known) guildStickerGuildInfo; getBinding().m.d(component1, 0); TextView textView = getBinding().n; m.checkNotNullExpressionValue(textView, "binding.guildStickerSheetStickerName"); textView.setText(component1.h()); TextView textView2 = getBinding().f1847c; m.checkNotNullExpressionValue(textView2, "binding.guildStickerSheetDescription"); textView2.setText(getString(getCustomStickerInfoText(component3, isUserInGuild, isPublic, component2))); configureButtons(component2, isUserInGuild, known != null ? known.getGuild() : null); Guild guild = known != null ? known.getGuild() : null; if (known != null) { num = known.getApproximateOnline(); } configureGuildSection(guild, component3, isPublic, num); AppViewFlipper appViewFlipper = getBinding().d; m.checkNotNullExpressionValue(appViewFlipper, "binding.guildStickerSheetFlipper"); appViewFlipper.setDisplayedChild(0); } private final WidgetGuildStickerSheetBinding getBinding() { return (WidgetGuildStickerSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]); } private final int getCustomStickerInfoText(boolean z2, boolean z3, boolean z4, boolean z5) { return (!z2 || z5) ? (!z2 || !z5) ? (!z3 || z5) ? (!z3 || !z5) ? (!z4 || z5) ? (!z4 || !z5) ? R.string.sticker_popout_premium_unjoined_private_guild_description : R.string.sticker_popout_premium_unjoined_discoverable_guild_description : R.string.sticker_popout_unjoined_discoverable_guild_description : R.string.sticker_popout_premium_joined_guild_description : R.string.sticker_popout_joined_guild_description : R.string.sticker_popout_premium_current_guild_description : R.string.sticker_popout_current_guild_description; } private final GuildStickerSheetViewModel getViewModel() { return (GuildStickerSheetViewModel) this.viewModel$delegate.getValue(); } public static final void show(FragmentManager fragmentManager, Sticker sticker) { Companion.show(fragmentManager, sticker); } private final void showLoading() { AppViewFlipper appViewFlipper = getBinding().d; m.checkNotNullExpressionValue(appViewFlipper, "binding.guildStickerSheetFlipper"); appViewFlipper.setDisplayedChild(1); } @Override // com.discord.app.AppBottomSheet public void bindSubscriptions(CompositeSubscription compositeSubscription) { m.checkNotNullParameter(compositeSubscription, "compositeSubscription"); Observable r = ObservableExtensionsKt.bindToComponentLifecycle(getViewModel().observeViewState(), this).r(); m.checkNotNullExpressionValue(r, "viewModel\n .obser… .distinctUntilChanged()"); ObservableExtensionsKt.appSubscribe$default(r, WidgetGuildStickerSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetGuildStickerSheet$bindSubscriptions$1(this), 62, (Object) null); } @Override // com.discord.app.AppBottomSheet public int getContentViewResId() { return R.layout.widget_guild_sticker_sheet; } }