discord-jadx/app/src/main/java/c/a/a/y/c.java

441 lines
24 KiB
Java

package c.a.a.y;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import c.a.d.f;
import c.a.i.x3;
import com.discord.api.application.Application;
import com.discord.api.premium.SubscriptionPlan;
import com.discord.app.AppDialog;
import com.discord.app.AppViewFlipper;
import com.discord.models.domain.ModelGift;
import com.discord.models.domain.ModelSku;
import com.discord.models.domain.ModelStoreListing;
import com.discord.stores.StoreGifting;
import com.discord.stores.StoreNotices;
import com.discord.stores.StoreStream;
import com.discord.utilities.error.Error;
import com.discord.utilities.icon.IconUtils;
import com.discord.utilities.images.MGImages;
import com.discord.utilities.premium.PremiumUtils;
import com.discord.utilities.resources.StringResourceUtilsKt;
import com.discord.utilities.rx.ObservableExtensionsKt;
import com.discord.utilities.view.text.LinkifiedTextView;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegate;
import com.discord.utilities.viewbinding.FragmentViewBindingDelegateKt;
import com.discord.widgets.home.WidgetHome;
import com.discord.widgets.settings.premium.WidgetSettingsGifting;
import com.facebook.drawee.view.SimpleDraweeView;
import com.google.android.material.button.MaterialButton;
import d0.t.n;
import d0.z.d.a0;
import d0.z.d.k;
import d0.z.d.m;
import d0.z.d.o;
import java.util.Objects;
import kotlin.NoWhenBranchMatchedException;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.reflect.KProperty;
/* compiled from: WidgetGiftAcceptDialog.kt */
public final class c extends AppDialog {
public static final /* synthetic */ KProperty[] i = {c.d.b.a.a.W(c.class, "binding", "getBinding()Lcom/discord/databinding/WidgetAcceptGiftDialogBinding;", 0)};
public static final a j = new a(null);
public final FragmentViewBindingDelegate k = FragmentViewBindingDelegateKt.viewBinding$default(this, b.i, null, 2, null);
/* compiled from: WidgetGiftAcceptDialog.kt */
public static final class a {
/* compiled from: WidgetGiftAcceptDialog.kt */
/* renamed from: c.a.a.y.c$a$a reason: collision with other inner class name */
public static final class C0020a extends o implements Function1<FragmentActivity, Boolean> {
public final /* synthetic */ long $channelId;
public final /* synthetic */ String $giftCode;
public final /* synthetic */ String $source;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public C0020a(String str, String str2, long j) {
super(1);
this.$giftCode = str;
this.$source = str2;
this.$channelId = j;
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public Boolean invoke(FragmentActivity fragmentActivity) {
FragmentActivity fragmentActivity2 = fragmentActivity;
m.checkNotNullParameter(fragmentActivity2, "appActivity");
StoreStream.Companion.getAnalytics().trackOpenGiftAcceptModal(this.$giftCode, this.$source, this.$channelId);
c cVar = new c();
Bundle bundle = new Bundle();
bundle.putString("ARG_GIFT_CODE", this.$giftCode);
cVar.setArguments(bundle);
FragmentManager supportFragmentManager = fragmentActivity2.getSupportFragmentManager();
m.checkNotNullExpressionValue(supportFragmentManager, "appActivity.supportFragmentManager");
cVar.show(supportFragmentManager, a0.getOrCreateKotlinClass(c.class).toString());
return Boolean.TRUE;
}
}
public a(DefaultConstructorMarker defaultConstructorMarker) {
}
public final void a(String str, String str2, long j) {
m.checkNotNullParameter(str, "giftCode");
m.checkNotNullParameter(str2, "source");
m.checkNotNullParameter(str, "giftCode");
StoreStream.Companion.getNotices().requestToShow(new StoreNotices.Notice("gift:" + str, null, 0, 0, false, n.listOf((Object[]) new d0.e0.c[]{a0.getOrCreateKotlinClass(WidgetSettingsGifting.class), a0.getOrCreateKotlinClass(WidgetHome.class)}), 0, 0, new C0020a(str, str2, j), 22, null));
}
}
/* compiled from: WidgetGiftAcceptDialog.kt */
public static final /* synthetic */ class b extends k implements Function1<View, x3> {
public static final b i = new b();
public b() {
super(1, x3.class, "bind", "bind(Landroid/view/View;)Lcom/discord/databinding/WidgetAcceptGiftDialogBinding;", 0);
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public x3 invoke(View view) {
View view2 = view;
m.checkNotNullParameter(view2, "p1");
int i2 = 2131361813;
LinearLayout linearLayout = (LinearLayout) view2.findViewById(2131361813);
if (linearLayout != null) {
i2 = 2131361814;
SimpleDraweeView simpleDraweeView = (SimpleDraweeView) view2.findViewById(2131361814);
if (simpleDraweeView != null) {
i2 = 2131361815;
TextView textView = (TextView) view2.findViewById(2131361815);
if (textView != null) {
i2 = 2131361816;
MaterialButton materialButton = (MaterialButton) view2.findViewById(2131361816);
if (materialButton != null) {
i2 = 2131361817;
LinearLayout linearLayout2 = (LinearLayout) view2.findViewById(2131361817);
if (linearLayout2 != null) {
i2 = 2131361818;
LinkifiedTextView linkifiedTextView = (LinkifiedTextView) view2.findViewById(2131361818);
if (linkifiedTextView != null) {
i2 = 2131361819;
AppViewFlipper appViewFlipper = (AppViewFlipper) view2.findViewById(2131361819);
if (appViewFlipper != null) {
i2 = 2131361820;
TextView textView2 = (TextView) view2.findViewById(2131361820);
if (textView2 != null) {
i2 = 2131361821;
ProgressBar progressBar = (ProgressBar) view2.findViewById(2131361821);
if (progressBar != null) {
return new x3((LinearLayout) view2, linearLayout, simpleDraweeView, textView, materialButton, linearLayout2, linkifiedTextView, appViewFlipper, textView2, progressBar);
}
}
}
}
}
}
}
}
}
throw new NullPointerException("Missing required view with ID: ".concat(view2.getResources().getResourceName(i2)));
}
}
/* compiled from: WidgetGiftAcceptDialog.kt */
/* renamed from: c.a.a.y.c$c reason: collision with other inner class name */
public static final class C0021c extends o implements Function1<Error, Unit> {
public final /* synthetic */ c this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public C0021c(c cVar) {
super(1);
this.this$0 = cVar;
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public Unit invoke(Error error) {
m.checkNotNullParameter(error, "it");
this.this$0.dismiss();
return Unit.a;
}
}
/* compiled from: WidgetGiftAcceptDialog.kt */
public static final class d extends o implements Function1<StoreGifting.GiftState, Unit> {
public final /* synthetic */ c this$0;
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public d(c cVar) {
super(1);
this.this$0 = cVar;
}
/* Return type fixed from 'java.lang.Object' to match base method */
/* JADX DEBUG: Method arguments types fixed to match base method, original types: [java.lang.Object] */
@Override // kotlin.jvm.functions.Function1
public Unit invoke(StoreGifting.GiftState giftState) {
ModelSku sku;
ModelSku sku2;
String str;
ModelSku sku3;
StoreGifting.GiftState giftState2 = giftState;
m.checkNotNullParameter(giftState2, "giftState");
int i = 0;
if (giftState2 instanceof StoreGifting.GiftState.Loading) {
c cVar = this.this$0;
KProperty[] kPropertyArr = c.i;
AppViewFlipper appViewFlipper = cVar.h().g;
m.checkNotNullExpressionValue(appViewFlipper, "binding.acceptGiftFlipper");
appViewFlipper.setDisplayedChild(0);
} else {
CharSequence charSequence = null;
if (giftState2 instanceof StoreGifting.GiftState.Resolved) {
StoreGifting.GiftState.Resolved resolved = (StoreGifting.GiftState.Resolved) giftState2;
if (resolved.getGift().getRedeemed()) {
c cVar2 = this.this$0;
ModelGift gift = resolved.getGift();
KProperty[] kPropertyArr2 = c.i;
cVar2.g(gift);
ModelStoreListing storeListing = gift.getStoreListing();
if (storeListing == null || (sku3 = storeListing.getSku()) == null || (str = sku3.getName()) == null) {
str = "";
}
CharSequence i2 = cVar2.i(gift);
LinearLayout linearLayout = c.d.b.a.a.o0(c.d.b.a.a.o0(cVar2.h().h, "binding.acceptGiftHeader", gift.isAnyNitroGift() ? c.a.l.b.j(cVar2, 2131889031, new Object[]{str}, null, 4) : c.a.l.b.j(cVar2, 2131889030, new Object[0], null, 4), cVar2).f177c, "binding.acceptGiftBodyText", gift.isNitroClassicGift() ? c.a.l.b.j(cVar2, 2131889012, new Object[]{i2}, null, 4) : gift.isNitroGift() ? c.a.l.b.j(cVar2, 2131889013, new Object[]{i2}, null, 4) : c.a.l.b.j(cVar2, 2131889011, new Object[]{str}, null, 4), cVar2).e;
m.checkNotNullExpressionValue(linearLayout, "binding.acceptGiftDisclaimerContainer");
linearLayout.setVisibility(8);
MaterialButton materialButton = cVar2.h().d;
m.checkNotNullExpressionValue(materialButton, "binding.acceptGiftConfirm");
Context context = cVar2.getContext();
if (context != null) {
charSequence = context.getText(2131889026);
}
materialButton.setText(charSequence);
cVar2.h().d.setOnClickListener(new d(cVar2));
} else if (resolved.getGift().getMaxUses() == resolved.getGift().getUses()) {
c cVar3 = this.this$0;
ModelGift gift2 = resolved.getGift();
KProperty[] kPropertyArr3 = c.i;
cVar3.g(gift2);
TextView textView = cVar3.h().h;
m.checkNotNullExpressionValue(textView, "binding.acceptGiftHeader");
c.a.l.b.n(textView, 2131889029, new Object[0], null, 4);
TextView textView2 = cVar3.h().f177c;
m.checkNotNullExpressionValue(textView2, "binding.acceptGiftBodyText");
c.a.l.b.n(textView2, 2131888996, new Object[0], null, 4);
LinearLayout linearLayout2 = cVar3.h().e;
m.checkNotNullExpressionValue(linearLayout2, "binding.acceptGiftDisclaimerContainer");
linearLayout2.setVisibility(8);
MaterialButton materialButton2 = cVar3.h().d;
m.checkNotNullExpressionValue(materialButton2, "binding.acceptGiftConfirm");
c.a.l.b.n(materialButton2, 2131889022, new Object[0], null, 4);
cVar3.h().d.setOnClickListener(new e(cVar3));
} else {
c cVar4 = this.this$0;
ModelGift gift3 = resolved.getGift();
KProperty[] kPropertyArr4 = c.i;
cVar4.g(gift3);
ModelStoreListing storeListing2 = gift3.getStoreListing();
String name = (storeListing2 == null || (sku2 = storeListing2.getSku()) == null) ? null : sku2.getName();
LinearLayout linearLayout3 = c.d.b.a.a.o0(c.d.b.a.a.o0(cVar4.h().h, "binding.acceptGiftHeader", gift3.isAnyNitroGift() ? c.a.l.b.j(cVar4, 2131889028, new Object[]{name}, null, 4) : c.a.l.b.j(cVar4, 2131889027, new Object[0], null, 4), cVar4).f177c, "binding.acceptGiftBodyText", gift3.isAnyNitroGift() ? c.a.l.b.j(cVar4, 2131888998, new Object[]{name, cVar4.i(gift3)}, null, 4) : c.a.l.b.j(cVar4, 2131888997, new Object[]{name}, null, 4), cVar4).e;
m.checkNotNullExpressionValue(linearLayout3, "binding.acceptGiftDisclaimerContainer");
if (!gift3.isAnyNitroGift()) {
i = 8;
}
linearLayout3.setVisibility(i);
MaterialButton materialButton3 = cVar4.h().d;
m.checkNotNullExpressionValue(materialButton3, "binding.acceptGiftConfirm");
Context context2 = cVar4.getContext();
if (context2 != null) {
charSequence = context2.getText(2131889020);
}
materialButton3.setText(charSequence);
cVar4.h().d.setOnClickListener(new f(gift3));
}
} else if (giftState2 instanceof StoreGifting.GiftState.Redeeming) {
c cVar5 = this.this$0;
ModelGift gift4 = ((StoreGifting.GiftState.Redeeming) giftState2).getGift();
KProperty[] kPropertyArr5 = c.i;
cVar5.g(gift4);
ModelStoreListing storeListing3 = gift4.getStoreListing();
String name2 = (storeListing3 == null || (sku = storeListing3.getSku()) == null) ? null : sku.getName();
MaterialButton materialButton4 = cVar5.h().d;
m.checkNotNullExpressionValue(materialButton4, "binding.acceptGiftConfirm");
materialButton4.setVisibility(8);
ProgressBar progressBar = cVar5.h().i;
m.checkNotNullExpressionValue(progressBar, "binding.acceptGiftProgress");
progressBar.setVisibility(0);
LinearLayout linearLayout4 = c.d.b.a.a.o0(c.d.b.a.a.o0(cVar5.h().h, "binding.acceptGiftHeader", gift4.isAnyNitroGift() ? c.a.l.b.j(cVar5, 2131889028, new Object[]{name2}, null, 4) : c.a.l.b.j(cVar5, 2131889027, new Object[0], null, 4), cVar5).f177c, "binding.acceptGiftBodyText", gift4.isAnyNitroGift() ? c.a.l.b.j(cVar5, 2131888998, new Object[]{name2, cVar5.i(gift4)}, null, 4) : c.a.l.b.j(cVar5, 2131888997, new Object[]{name2}, null, 4), cVar5).e;
m.checkNotNullExpressionValue(linearLayout4, "binding.acceptGiftDisclaimerContainer");
if (!gift4.isAnyNitroGift()) {
i = 8;
}
linearLayout4.setVisibility(i);
} else if (giftState2 instanceof StoreGifting.GiftState.RedeemedFailed) {
c cVar6 = this.this$0;
StoreGifting.GiftState.RedeemedFailed redeemedFailed = (StoreGifting.GiftState.RedeemedFailed) giftState2;
KProperty[] kPropertyArr6 = c.i;
Objects.requireNonNull(cVar6);
cVar6.g(redeemedFailed.getGift());
TextView textView3 = cVar6.h().h;
m.checkNotNullExpressionValue(textView3, "binding.acceptGiftHeader");
textView3.setText(c.a.l.b.j(cVar6, 2131889029, new Object[0], null, 4));
TextView textView4 = cVar6.h().f177c;
m.checkNotNullExpressionValue(textView4, "binding.acceptGiftBodyText");
c.a.l.b.n(textView4, 2131889018, new Object[0], null, 4);
if (redeemedFailed.getCanRetry()) {
TextView textView5 = cVar6.h().f177c;
m.checkNotNullExpressionValue(textView5, "binding.acceptGiftBodyText");
c.a.l.b.n(textView5, 2131889018, new Object[0], null, 4);
MaterialButton materialButton5 = cVar6.h().d;
m.checkNotNullExpressionValue(materialButton5, "binding.acceptGiftConfirm");
Context context3 = cVar6.getContext();
if (context3 != null) {
charSequence = context3.getText(2131892653);
}
materialButton5.setText(charSequence);
cVar6.h().d.setOnClickListener(new f(0, redeemedFailed));
} else {
Integer errorCode = redeemedFailed.getErrorCode();
if (errorCode != null && errorCode.intValue() == 50054) {
cVar6.h().f177c.setText(2131889005);
} else if (errorCode != null && errorCode.intValue() == 100024) {
cVar6.h().f177c.setText(2131889001);
} else if (errorCode != null && errorCode.intValue() == 100022) {
cVar6.h().f177c.setText(2131889002);
} else if (errorCode != null && errorCode.intValue() == 100025) {
cVar6.h().f177c.setText(2131889000);
}
MaterialButton materialButton6 = cVar6.h().d;
m.checkNotNullExpressionValue(materialButton6, "binding.acceptGiftConfirm");
Context context4 = cVar6.getContext();
if (context4 != null) {
charSequence = context4.getText(2131889022);
}
materialButton6.setText(charSequence);
cVar6.h().d.setOnClickListener(new f(1, cVar6));
}
} else if ((giftState2 instanceof StoreGifting.GiftState.Invalid) || (giftState2 instanceof StoreGifting.GiftState.LoadFailed) || (giftState2 instanceof StoreGifting.GiftState.Revoking)) {
this.this$0.dismiss();
}
}
return Unit.a;
}
}
public c() {
super(2131558835);
}
public final void g(ModelGift modelGift) {
String str;
ModelSku sku;
Application application;
String e;
ModelSku sku2;
AppViewFlipper appViewFlipper = h().g;
m.checkNotNullExpressionValue(appViewFlipper, "binding.acceptGiftFlipper");
appViewFlipper.setDisplayedChild(1);
if (modelGift.isAnyNitroGift()) {
MGImages mGImages = MGImages.INSTANCE;
SimpleDraweeView simpleDraweeView = h().b;
m.checkNotNullExpressionValue(simpleDraweeView, "binding.acceptGiftBodyImage");
MGImages.setImage$default(mGImages, simpleDraweeView, PremiumUtils.INSTANCE.getNitroGiftIcon(modelGift), (MGImages.ChangeDetector) null, 4, (Object) null);
} else {
ModelStoreListing storeListing = modelGift.getStoreListing();
if (storeListing == null || (sku = storeListing.getSku()) == null || (application = sku.getApplication()) == null || (e = application.e()) == null) {
str = null;
} else {
ModelStoreListing storeListing2 = modelGift.getStoreListing();
str = IconUtils.getApplicationIcon$default((storeListing2 == null || (sku2 = storeListing2.getSku()) == null) ? 0 : sku2.getApplicationId(), e, 0, 4, null);
}
h().b.setImageURI(str);
}
MaterialButton materialButton = h().d;
m.checkNotNullExpressionValue(materialButton, "binding.acceptGiftConfirm");
materialButton.setVisibility(0);
ProgressBar progressBar = h().i;
m.checkNotNullExpressionValue(progressBar, "binding.acceptGiftProgress");
progressBar.setVisibility(8);
}
public final x3 h() {
return (x3) this.k.getValue((Fragment) this, i[0]);
}
public final CharSequence i(ModelGift modelGift) {
int i2;
SubscriptionPlan subscriptionPlan = modelGift.getSubscriptionPlan();
if (subscriptionPlan == null) {
return "";
}
int ordinal = subscriptionPlan.b().ordinal();
if (ordinal == 0) {
i2 = 2131755118;
} else if (ordinal == 1) {
i2 = 2131755119;
} else {
throw new NoWhenBranchMatchedException();
}
Context requireContext = requireContext();
m.checkNotNullExpressionValue(requireContext, "requireContext()");
CharSequence i18nPluralString = StringResourceUtilsKt.getI18nPluralString(requireContext, i2, subscriptionPlan.c(), Integer.valueOf(subscriptionPlan.c()));
int ordinal2 = subscriptionPlan.b().ordinal();
if (ordinal2 == 0) {
return c.a.l.b.j(this, 2131889032, new Object[]{i18nPluralString}, null, 4);
}
if (ordinal2 == 1) {
return c.a.l.b.j(this, 2131889033, new Object[]{i18nPluralString}, null, 4);
}
throw new NoWhenBranchMatchedException();
}
@Override // androidx.fragment.app.Fragment
public void onDestroy() {
String string;
Bundle arguments = getArguments();
if (!(arguments == null || (string = arguments.getString("ARG_GIFT_CODE")) == null)) {
a aVar = j;
m.checkNotNullExpressionValue(string, "it");
Objects.requireNonNull(aVar);
m.checkNotNullParameter(string, "giftCode");
String str = "gift:" + string;
if (str != null) {
StoreStream.Companion.getNotices().markDialogSeen(str);
}
}
super.onDestroy();
}
@Override // com.discord.app.AppDialog
public void onViewBound(View view) {
m.checkNotNullParameter(view, "view");
super.onViewBound(view);
Bundle arguments = getArguments();
String string = arguments != null ? arguments.getString("ARG_GIFT_CODE") : null;
if (string == null) {
dismiss();
return;
}
LinkifiedTextView linkifiedTextView = h().f;
m.checkNotNullExpressionValue(linkifiedTextView, "binding.acceptGiftDisclaimerText");
c.a.l.b.n(linkifiedTextView, 2131888999, new Object[]{f.a.a(360055386693L, null)}, null, 4);
ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.ui$default(StoreStream.Companion.getGifting().requestGift(string), this, null, 2, null), c.class, (Context) null, (Function1) null, new C0021c(this), (Function0) null, (Function0) null, new d(this), 54, (Object) null);
}
}