2021-08-03 07:33:18 +00:00
|
|
|
package com.discord.widgets.stickers;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import android.os.Bundle;
|
|
|
|
import android.widget.RelativeLayout;
|
|
|
|
import android.widget.TextView;
|
|
|
|
import androidx.fragment.app.Fragment;
|
|
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
import androidx.fragment.app.FragmentViewModelLazyKt;
|
2021-12-17 21:59:34 +00:00
|
|
|
import b.a.d.f0;
|
|
|
|
import b.a.d.h0;
|
|
|
|
import b.a.k.b;
|
|
|
|
import b.d.b.a.a;
|
2021-08-09 22:51:56 +00:00
|
|
|
import com.discord.R;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.api.channel.Channel;
|
|
|
|
import com.discord.api.premium.PremiumTier;
|
|
|
|
import com.discord.api.sticker.Sticker;
|
|
|
|
import com.discord.api.sticker.StickerType;
|
|
|
|
import com.discord.app.AppBottomSheet;
|
|
|
|
import com.discord.databinding.WidgetStickerSheetBinding;
|
|
|
|
import com.discord.models.sticker.dto.ModelStickerPack;
|
|
|
|
import com.discord.stores.StoreStream;
|
2021-08-09 22:51:56 +00:00
|
|
|
import com.discord.utilities.analytics.Traits;
|
2021-08-03 07:33:18 +00:00
|
|
|
import com.discord.utilities.rx.ObservableExtensionsKt;
|
|
|
|
import com.discord.utilities.stickers.StickerUtils;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
|
|
|
|
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
|
|
|
|
import com.discord.views.LoadingButton;
|
|
|
|
import com.discord.widgets.stickers.StickerSheetViewModel;
|
|
|
|
import com.google.android.material.button.MaterialButton;
|
|
|
|
import com.google.android.material.chip.Chip;
|
2021-11-02 06:38:17 +00:00
|
|
|
import d0.z.d.a0;
|
|
|
|
import d0.z.d.m;
|
2021-08-03 07:33:18 +00:00
|
|
|
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: WidgetStickerSheet.kt */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes2.dex */
|
2021-08-03 07:33:18 +00:00
|
|
|
public final class WidgetStickerSheet extends AppBottomSheet {
|
|
|
|
private static final String ANALYTICS_LOCATION = "widget_sticker_sheet_analytics_location";
|
|
|
|
private final FragmentViewBindingDelegate binding$delegate = FragmentViewBindingDelegateKt.viewBinding$default(this, WidgetStickerSheet$binding$2.INSTANCE, null, 2, null);
|
|
|
|
private final Lazy viewModel$delegate;
|
2022-03-21 18:52:30 +00:00
|
|
|
public static final /* synthetic */ KProperty[] $$delegatedProperties = {a.b0(WidgetStickerSheet.class, "binding", "getBinding()Lcom/discord/databinding/WidgetStickerSheetBinding;", 0)};
|
2022-03-07 09:34:54 +00:00
|
|
|
public static final Companion Companion = new Companion(null);
|
2021-08-03 07:33:18 +00:00
|
|
|
|
|
|
|
/* compiled from: WidgetStickerSheet.kt */
|
2022-03-07 09:34:54 +00:00
|
|
|
/* loaded from: classes2.dex */
|
2021-08-03 07:33:18 +00:00
|
|
|
public static final class Companion {
|
|
|
|
private Companion() {
|
|
|
|
}
|
|
|
|
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
|
|
this();
|
|
|
|
}
|
|
|
|
|
|
|
|
public final void show(FragmentManager fragmentManager, Sticker sticker, long j) {
|
2021-11-16 23:14:13 +00:00
|
|
|
Channel findChannelById;
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullParameter(fragmentManager, "fragmentManager");
|
|
|
|
m.checkNotNullParameter(sticker, "sticker");
|
2021-11-16 23:14:13 +00:00
|
|
|
if (sticker.k() == StickerType.STANDARD && (findChannelById = StoreStream.Companion.getChannels().findChannelById(j)) != null) {
|
2022-03-21 18:52:30 +00:00
|
|
|
String str = findChannelById.h() == 0 ? "DM Channel" : Traits.Location.Page.GUILD_CHANNEL;
|
2021-08-03 07:33:18 +00:00
|
|
|
WidgetStickerSheet widgetStickerSheet = new WidgetStickerSheet();
|
|
|
|
Bundle bundle = new Bundle();
|
|
|
|
bundle.putSerializable("com.discord.intent.extra.EXTRA_STICKER", sticker);
|
2021-08-09 22:51:56 +00:00
|
|
|
bundle.putString(WidgetStickerSheet.ANALYTICS_LOCATION, str);
|
2021-08-03 07:33:18 +00:00
|
|
|
widgetStickerSheet.setArguments(bundle);
|
|
|
|
widgetStickerSheet.show(fragmentManager, WidgetStickerSheet.class.getName());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public WidgetStickerSheet() {
|
|
|
|
super(false, 1, null);
|
|
|
|
WidgetStickerSheet$viewModel$2 widgetStickerSheet$viewModel$2 = new WidgetStickerSheet$viewModel$2(this);
|
2021-08-13 06:23:11 +00:00
|
|
|
f0 f0Var = new f0(this);
|
|
|
|
this.viewModel$delegate = FragmentViewModelLazyKt.createViewModelLazy(this, a0.getOrCreateKotlinClass(StickerSheetViewModel.class), new WidgetStickerSheet$appViewModels$$inlined$viewModels$1(f0Var), new h0(widgetStickerSheet$viewModel$2));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ void access$configureUI(WidgetStickerSheet widgetStickerSheet, StickerSheetViewModel.ViewState viewState) {
|
|
|
|
widgetStickerSheet.configureUI(viewState);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final /* synthetic */ Bundle access$getArgumentsOrDefault$p(WidgetStickerSheet widgetStickerSheet) {
|
|
|
|
return widgetStickerSheet.getArgumentsOrDefault();
|
|
|
|
}
|
|
|
|
|
|
|
|
private final void configureUI(StickerSheetViewModel.ViewState viewState) {
|
|
|
|
ModelStickerPack component1 = viewState.component1();
|
|
|
|
Sticker component2 = viewState.component2();
|
|
|
|
PremiumTier component3 = viewState.component3();
|
|
|
|
boolean component4 = viewState.component4();
|
|
|
|
TextView textView = getBinding().d;
|
|
|
|
m.checkNotNullExpressionValue(textView, "binding.stickerSheetStickerName");
|
|
|
|
textView.setText(component2.h());
|
|
|
|
if (!viewState.isUserPremiumTier2()) {
|
2021-12-17 21:59:34 +00:00
|
|
|
getBinding().c.setOnClickListener(new WidgetStickerSheet$configureUI$1(this));
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
2021-12-17 21:59:34 +00:00
|
|
|
TextView textView2 = getBinding().c;
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullExpressionValue(textView2, "binding.stickerSheetStickerInfo");
|
|
|
|
boolean z2 = true;
|
|
|
|
int i = 0;
|
2021-08-09 22:51:56 +00:00
|
|
|
textView2.setText((component4 || viewState.isUserPremiumTier2() || component1.isPremiumPack()) ? b.k(this, R.string.sticker_popout_pack_info_premium, new Object[]{component1.getName()}, null, 4) : !component1.canBePurchased() ? b.k(this, R.string.sticker_popout_pack_info_unavailable, new Object[]{component1.getName()}, null, 4) : b.e(this, R.string.sticker_popout_pack_info, new Object[]{component1.getName(), String.valueOf(StickerUtils.INSTANCE.calculatePremiumStickerPackDiscount())}, WidgetStickerSheet$configureUI$2.INSTANCE));
|
2021-08-03 07:33:18 +00:00
|
|
|
try {
|
|
|
|
getBinding().h.d(component1.getStickers().get(0), 0);
|
|
|
|
getBinding().i.d(component1.getStickers().get(1), 0);
|
|
|
|
getBinding().j.d(component1.getStickers().get(2), 0);
|
|
|
|
getBinding().k.d(component1.getStickers().get(3), 0);
|
|
|
|
} catch (IndexOutOfBoundsException unused) {
|
|
|
|
}
|
|
|
|
Bundle arguments = getArguments();
|
2021-08-09 22:51:56 +00:00
|
|
|
String string = arguments != null ? arguments.getString(ANALYTICS_LOCATION) : null;
|
2021-08-03 07:33:18 +00:00
|
|
|
StickerUtils stickerUtils = StickerUtils.INSTANCE;
|
|
|
|
Context requireContext = requireContext();
|
|
|
|
m.checkNotNullExpressionValue(requireContext, "requireContext()");
|
2022-03-21 18:52:30 +00:00
|
|
|
getBinding().f2645b.setText(stickerUtils.getStickerPackPremiumPriceLabel(requireContext, component1, component3, component4));
|
|
|
|
getBinding().f2645b.setIsLoading(false);
|
|
|
|
getBinding().f2645b.setOnClickListener(new WidgetStickerSheet$configureUI$3(this, component4, component3));
|
|
|
|
LoadingButton loadingButton = getBinding().f2645b;
|
2021-08-03 07:33:18 +00:00
|
|
|
m.checkNotNullExpressionValue(loadingButton, "binding.stickerSheetBuyButton");
|
|
|
|
if (!component4 || component3 == PremiumTier.TIER_2) {
|
|
|
|
z2 = false;
|
|
|
|
}
|
|
|
|
loadingButton.setVisibility(z2 ? 0 : 8);
|
|
|
|
MaterialButton materialButton = getBinding().e;
|
|
|
|
m.checkNotNullExpressionValue(materialButton, "binding.stickerSheetViewButton");
|
|
|
|
materialButton.setVisibility(component4 ? 0 : 8);
|
|
|
|
getBinding().e.setOnClickListener(new WidgetStickerSheet$configureUI$4(this, component4, component3, component2, string, component1));
|
|
|
|
RelativeLayout relativeLayout = getBinding().g;
|
|
|
|
m.checkNotNullExpressionValue(relativeLayout, "binding.stickerSheetViewLimitedContainer");
|
|
|
|
if (!component1.isLimitedPack()) {
|
|
|
|
i = 8;
|
|
|
|
}
|
|
|
|
relativeLayout.setVisibility(i);
|
|
|
|
Chip chip = getBinding().f;
|
|
|
|
m.checkNotNullExpressionValue(chip, "binding.stickerSheetViewLimitedChip");
|
|
|
|
Context requireContext2 = requireContext();
|
|
|
|
m.checkNotNullExpressionValue(requireContext2, "requireContext()");
|
|
|
|
chip.setText(stickerUtils.getLimitedTimeLeftString(requireContext2, component1.getStoreListing()));
|
|
|
|
}
|
|
|
|
|
|
|
|
private final WidgetStickerSheetBinding getBinding() {
|
|
|
|
return (WidgetStickerSheetBinding) this.binding$delegate.getValue((Fragment) this, $$delegatedProperties[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
private final StickerSheetViewModel getViewModel() {
|
|
|
|
return (StickerSheetViewModel) this.viewModel$delegate.getValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final void show(FragmentManager fragmentManager, Sticker sticker, long j) {
|
|
|
|
Companion.show(fragmentManager, sticker, j);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppBottomSheet
|
|
|
|
public void bindSubscriptions(CompositeSubscription compositeSubscription) {
|
|
|
|
m.checkNotNullParameter(compositeSubscription, "compositeSubscription");
|
2022-03-21 18:52:30 +00:00
|
|
|
Observable r = ObservableExtensionsKt.bindToComponentLifecycle$default(getViewModel().observeViewState(), this, null, 2, null).r();
|
|
|
|
m.checkNotNullExpressionValue(r, "viewModel\n .obser… .distinctUntilChanged()");
|
|
|
|
ObservableExtensionsKt.appSubscribe$default(r, WidgetStickerSheet.class, (Context) null, (Function1) null, (Function1) null, (Function0) null, (Function0) null, new WidgetStickerSheet$bindSubscriptions$1(this), 62, (Object) null);
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override // com.discord.app.AppBottomSheet
|
|
|
|
public int getContentViewResId() {
|
2021-08-09 22:51:56 +00:00
|
|
|
return R.layout.widget_sticker_sheet;
|
2021-08-03 07:33:18 +00:00
|
|
|
}
|
|
|
|
}
|