discord-jadx/app/src/main/java/com/discord/views/ActiveSubscriptionView.java

407 lines
21 KiB
Java

package com.discord.views;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.annotation.AttrRes;
import androidx.annotation.DrawableRes;
import c.a.i.p1;
import c.a.k.b;
import com.discord.models.domain.ModelSubscription;
import com.discord.utilities.billing.GooglePlaySku;
import com.discord.utilities.billing.GooglePlaySkuKt;
import com.discord.utilities.drawable.DrawableCompat;
import com.discord.utilities.resources.StringResourceUtilsKt;
import com.google.android.material.button.MaterialButton;
import d0.z.d.m;
import kotlin.NoWhenBranchMatchedException;
import kotlin.Unit;
import kotlin.jvm.functions.Function0;
/* compiled from: ActiveSubscriptionView.kt */
public final class ActiveSubscriptionView extends FrameLayout {
public static final /* synthetic */ int i = 0;
public final p1 j;
/* compiled from: ActiveSubscriptionView.kt */
public enum ActiveSubscriptionType {
PREMIUM_CLASSIC(2130969522, 2131232238, 2131232241, 2131232239, 2131230932, 2131230938, 2131230937),
PREMIUM(2130969524, 2131232249, 2131232252, 2131232250, 2131230936, 2131230938, 2131230937),
PREMIUM_GUILD(2130969523, 2131232242, 2131232245, 2131232243, 2131230933, 2131230935, 2131230934),
PREMIUM_AND_PREMIUM_GUILD(2130969511, 2131232237, 2131232237, 2131232237, 2131230931, 2131230938, 2131230937);
private final int headerBackground;
private final int headerBackgroundError;
private final int headerBackgroundResub;
private final int headerImage;
private final int headerImageError;
private final int headerImageResub;
private final int headerLogo;
private ActiveSubscriptionType(@AttrRes int i, @DrawableRes int i2, @DrawableRes int i3, @DrawableRes int i4, @DrawableRes int i5, @DrawableRes int i6, @DrawableRes int i7) {
this.headerLogo = i;
this.headerImage = i2;
this.headerImageResub = i3;
this.headerImageError = i4;
this.headerBackground = i5;
this.headerBackgroundResub = i6;
this.headerBackgroundError = i7;
}
public final int getHeaderBackground() {
return this.headerBackground;
}
public final int getHeaderBackgroundError() {
return this.headerBackgroundError;
}
public final int getHeaderBackgroundResub() {
return this.headerBackgroundResub;
}
public final int getHeaderImage() {
return this.headerImage;
}
public final int getHeaderImageError() {
return this.headerImageError;
}
public final int getHeaderImageResub() {
return this.headerImageResub;
}
public final int getHeaderLogo() {
return this.headerLogo;
}
}
/* compiled from: java-style lambda group */
public static final class a implements View.OnClickListener {
public final /* synthetic */ int i;
public final /* synthetic */ Object j;
public a(int i, Object obj) {
this.i = i;
this.j = obj;
}
@Override // android.view.View.OnClickListener
public final void onClick(View view) {
int i = this.i;
if (i == 0) {
Function0 function0 = (Function0) this.j;
if (function0 != null) {
Unit unit = (Unit) function0.mo1invoke();
}
} else if (i == 1) {
Function0 function02 = (Function0) this.j;
if (function02 != null) {
Unit unit2 = (Unit) function02.mo1invoke();
}
} else if (i == 2) {
Function0 function03 = (Function0) this.j;
if (function03 != null) {
Unit unit3 = (Unit) function03.mo1invoke();
}
} else {
throw null;
}
}
}
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
public ActiveSubscriptionView(Context context, AttributeSet attributeSet) {
super(context, attributeSet, 0);
m.checkNotNullParameter(context, "context");
View inflate = LayoutInflater.from(context).inflate(2131558723, (ViewGroup) this, false);
addView(inflate);
int i2 = 2131361892;
TextView textView = (TextView) inflate.findViewById(2131361892);
if (textView != null) {
i2 = 2131361893;
ImageView imageView = (ImageView) inflate.findViewById(2131361893);
if (imageView != null) {
i2 = 2131361894;
ImageView imageView2 = (ImageView) inflate.findViewById(2131361894);
if (imageView2 != null) {
i2 = 2131361895;
ImageView imageView3 = (ImageView) inflate.findViewById(2131361895);
if (imageView3 != null) {
i2 = 2131361896;
TextView textView2 = (TextView) inflate.findViewById(2131361896);
if (textView2 != null) {
i2 = 2131361897;
MaterialButton materialButton = (MaterialButton) inflate.findViewById(2131361897);
if (materialButton != null) {
i2 = 2131361898;
ProgressBar progressBar = (ProgressBar) inflate.findViewById(2131361898);
if (progressBar != null) {
i2 = 2131361899;
MaterialButton materialButton2 = (MaterialButton) inflate.findViewById(2131361899);
if (materialButton2 != null) {
p1 p1Var = new p1((FrameLayout) inflate, textView, imageView, imageView2, imageView3, textView2, materialButton, progressBar, materialButton2);
m.checkNotNullExpressionValue(p1Var, "ViewActiveSubscriptionBi…rom(context), this, true)");
this.j = p1Var;
return;
}
}
}
}
}
}
}
}
throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i2)));
}
public static final ActiveSubscriptionType b(ModelSubscription modelSubscription) {
m.checkNotNullParameter(modelSubscription, "subscription");
if (modelSubscription.isGoogleSubscription()) {
String paymentGatewayPlanId = modelSubscription.getPaymentGatewayPlanId();
GooglePlaySku.Type type = null;
GooglePlaySku fromSkuName = paymentGatewayPlanId != null ? GooglePlaySku.Companion.fromSkuName(paymentGatewayPlanId) : null;
if (fromSkuName != null && GooglePlaySkuKt.isBundledSku(fromSkuName)) {
return ActiveSubscriptionType.PREMIUM_AND_PREMIUM_GUILD;
}
if (fromSkuName != null) {
type = fromSkuName.getType();
}
if (type == GooglePlaySku.Type.PREMIUM_GUILD) {
return ActiveSubscriptionType.PREMIUM_GUILD;
}
}
int ordinal = modelSubscription.getPlanType().ordinal();
if (!(ordinal == 2 || ordinal == 3)) {
switch (ordinal) {
case 6:
case 7:
break;
case 8:
case 9:
return ActiveSubscriptionType.PREMIUM_GUILD;
default:
return ActiveSubscriptionType.PREMIUM_CLASSIC;
}
}
return ActiveSubscriptionType.PREMIUM;
}
/* JADX WARNING: Removed duplicated region for block: B:16:0x0085 */
/* JADX WARNING: Removed duplicated region for block: B:23:0x009a */
/* JADX WARNING: Removed duplicated region for block: B:26:0x00b5 */
/* JADX WARNING: Removed duplicated region for block: B:51:0x0194 */
/* JADX WARNING: Removed duplicated region for block: B:59:0x01d2 */
/* JADX WARNING: Removed duplicated region for block: B:60:0x01d4 */
/* JADX WARNING: Removed duplicated region for block: B:63:0x01e4 A[ADDED_TO_REGION] */
/* JADX WARNING: Removed duplicated region for block: B:70:0x01f1 */
/* JADX WARNING: Removed duplicated region for block: B:71:0x01f3 */
/* JADX WARNING: Removed duplicated region for block: B:74:0x0203 */
/* JADX WARNING: Removed duplicated region for block: B:77:0x020d */
/* JADX WARNING: Removed duplicated region for block: B:80:0x0228 */
/* JADX WARNING: Removed duplicated region for block: B:81:0x022a */
/* JADX WARNING: Removed duplicated region for block: B:83:0x022d */
/* JADX WARNING: Removed duplicated region for block: B:84:0x022f */
/* JADX WARNING: Removed duplicated region for block: B:87:0x024b */
/* JADX WARNING: Removed duplicated region for block: B:88:0x024d */
/* JADX WARNING: Removed duplicated region for block: B:90:0x0250 */
/* JADX WARNING: Removed duplicated region for block: B:91:0x0252 */
/* JADX WARNING: Removed duplicated region for block: B:94:0x027b */
/* JADX WARNING: Removed duplicated region for block: B:9:0x004f */
public final void a(ActiveSubscriptionType activeSubscriptionType, ModelSubscription.Status status, boolean z2, CharSequence charSequence, boolean z3, int i2, Function0<Unit> function0, Function0<Unit> function02, Function0<Unit> function03, boolean z4) {
int i3;
int ordinal;
int i4;
int ordinal2;
int i5;
int ordinal3;
CharSequence charSequence2;
m.checkNotNullParameter(activeSubscriptionType, "activeSubscriptionType");
m.checkNotNullParameter(status, "status");
m.checkNotNullParameter(charSequence, "priceText");
ImageView imageView = this.j.f140c;
int ordinal4 = status.ordinal();
if (ordinal4 != 2) {
if (ordinal4 == 3) {
i3 = activeSubscriptionType.getHeaderBackgroundResub();
} else if (ordinal4 != 4) {
i3 = activeSubscriptionType.getHeaderBackground();
}
imageView.setImageResource(i3);
ImageView imageView2 = this.j.d;
ordinal = status.ordinal();
if (ordinal != 2) {
if (ordinal == 3) {
i4 = activeSubscriptionType.getHeaderImageResub();
} else if (ordinal != 4) {
i4 = activeSubscriptionType.getHeaderImage();
}
imageView2.setImageResource(i4);
int i6 = 0;
this.j.e.setImageResource(DrawableCompat.getThemedDrawableRes$default(this, activeSubscriptionType.getHeaderLogo(), 0, 2, (Object) null));
ImageView imageView3 = this.j.e;
m.checkNotNullExpressionValue(imageView3, "binding.activeSubscriptionHeaderLogo");
ordinal2 = activeSubscriptionType.ordinal();
if (ordinal2 != 0) {
if (ordinal2 != 1) {
if (ordinal2 == 2) {
i5 = 2131892300;
} else if (ordinal2 != 3) {
throw new NoWhenBranchMatchedException();
}
}
i5 = 2131892468;
} else {
i5 = 2131892466;
}
imageView3.setContentDescription(b.i(this, i5, new Object[0], null, 4));
TextView textView = this.j.f;
m.checkNotNullExpressionValue(textView, "binding.activeSubscriptionHeaderText");
ordinal3 = activeSubscriptionType.ordinal();
if (ordinal3 == 0) {
int ordinal5 = status.ordinal();
charSequence2 = ordinal5 != 3 ? ordinal5 != 4 ? b.i(this, 2131892429, new Object[]{charSequence}, null, 4) : b.i(this, 2131892430, new Object[]{charSequence}, null, 4) : b.i(this, 2131892433, new Object[]{charSequence}, null, 4);
} else if (ordinal3 == 1) {
int ordinal6 = status.ordinal();
charSequence2 = ordinal6 != 3 ? ordinal6 != 4 ? b.i(this, 2131892435, new Object[]{2, charSequence}, null, 4) : b.i(this, 2131892436, new Object[]{2, charSequence}, null, 4) : b.i(this, 2131892439, new Object[]{2, charSequence}, null, 4);
} else if (ordinal3 == 2) {
Context context = getContext();
m.checkNotNullExpressionValue(context, "context");
CharSequence i18nPluralString = StringResourceUtilsKt.getI18nPluralString(context, 2131755282, i2, Integer.valueOf(i2));
int ordinal7 = status.ordinal();
charSequence2 = ordinal7 != 3 ? ordinal7 != 4 ? b.i(this, 2131892308, new Object[]{String.valueOf(i2), i18nPluralString, charSequence}, null, 4) : b.i(this, 2131892306, new Object[]{Integer.valueOf(i2), i18nPluralString, charSequence}, null, 4) : b.i(this, 2131892311, new Object[]{Integer.valueOf(i2), i18nPluralString, charSequence}, null, 4);
} else if (ordinal3 == 3) {
int ordinal8 = status.ordinal();
charSequence2 = ordinal8 != 3 ? ordinal8 != 4 ? b.i(this, 2131892435, new Object[]{Integer.valueOf(i2), charSequence}, null, 4) : b.i(this, 2131892436, new Object[]{Integer.valueOf(i2), charSequence}, null, 4) : b.i(this, 2131892439, new Object[]{Integer.valueOf(i2), charSequence}, null, 4);
} else {
throw new NoWhenBranchMatchedException();
}
textView.setText(charSequence2);
MaterialButton materialButton = this.j.i;
m.checkNotNullExpressionValue(materialButton, "binding.activeSubscriptionTopButton");
materialButton.setVisibility(z3 ^ true ? 0 : 8);
TextView textView2 = this.j.b;
m.checkNotNullExpressionValue(textView2, "binding.activeSubscriptionCancelButton");
textView2.setVisibility(function03 == null && !z3 && status != ModelSubscription.Status.CANCELED && !z4 ? 0 : 8);
MaterialButton materialButton2 = this.j.i;
int ordinal9 = status.ordinal();
materialButton2.setText(ordinal9 != 3 ? ordinal9 != 4 ? 2131892461 : 2131886913 : 2131892826);
this.j.i.setOnClickListener(new a(0, function0));
MaterialButton materialButton3 = this.j.i;
m.checkNotNullExpressionValue(materialButton3, "binding.activeSubscriptionTopButton");
materialButton3.setVisibility(function0 != null ? 0 : 8);
MaterialButton materialButton4 = this.j.i;
m.checkNotNullExpressionValue(materialButton4, "binding.activeSubscriptionTopButton");
materialButton4.setEnabled(!z2);
MaterialButton materialButton5 = this.j.g;
m.checkNotNullExpressionValue(materialButton5, "binding.activeSubscriptionManagePremiumGuildButton");
materialButton5.setVisibility(function02 != null ? 0 : 8);
this.j.g.setOnClickListener(new a(1, function02));
this.j.b.setOnClickListener(new a(2, function03));
ProgressBar progressBar = this.j.h;
m.checkNotNullExpressionValue(progressBar, "binding.activeSubscriptionProgress");
if (!z3) {
i6 = 8;
}
progressBar.setVisibility(i6);
}
i4 = activeSubscriptionType.getHeaderImageError();
imageView2.setImageResource(i4);
int i6 = 0;
this.j.e.setImageResource(DrawableCompat.getThemedDrawableRes$default(this, activeSubscriptionType.getHeaderLogo(), 0, 2, (Object) null));
ImageView imageView3 = this.j.e;
m.checkNotNullExpressionValue(imageView3, "binding.activeSubscriptionHeaderLogo");
ordinal2 = activeSubscriptionType.ordinal();
if (ordinal2 != 0) {
}
imageView3.setContentDescription(b.i(this, i5, new Object[0], null, 4));
TextView textView = this.j.f;
m.checkNotNullExpressionValue(textView, "binding.activeSubscriptionHeaderText");
ordinal3 = activeSubscriptionType.ordinal();
if (ordinal3 == 0) {
}
textView.setText(charSequence2);
MaterialButton materialButton = this.j.i;
m.checkNotNullExpressionValue(materialButton, "binding.activeSubscriptionTopButton");
materialButton.setVisibility(z3 ^ true ? 0 : 8);
TextView textView2 = this.j.b;
m.checkNotNullExpressionValue(textView2, "binding.activeSubscriptionCancelButton");
textView2.setVisibility(function03 == null && !z3 && status != ModelSubscription.Status.CANCELED && !z4 ? 0 : 8);
MaterialButton materialButton2 = this.j.i;
int ordinal9 = status.ordinal();
materialButton2.setText(ordinal9 != 3 ? ordinal9 != 4 ? 2131892461 : 2131886913 : 2131892826);
this.j.i.setOnClickListener(new a(0, function0));
MaterialButton materialButton3 = this.j.i;
m.checkNotNullExpressionValue(materialButton3, "binding.activeSubscriptionTopButton");
materialButton3.setVisibility(function0 != null ? 0 : 8);
MaterialButton materialButton4 = this.j.i;
m.checkNotNullExpressionValue(materialButton4, "binding.activeSubscriptionTopButton");
materialButton4.setEnabled(!z2);
MaterialButton materialButton5 = this.j.g;
m.checkNotNullExpressionValue(materialButton5, "binding.activeSubscriptionManagePremiumGuildButton");
materialButton5.setVisibility(function02 != null ? 0 : 8);
this.j.g.setOnClickListener(new a(1, function02));
this.j.b.setOnClickListener(new a(2, function03));
ProgressBar progressBar = this.j.h;
m.checkNotNullExpressionValue(progressBar, "binding.activeSubscriptionProgress");
if (!z3) {
}
progressBar.setVisibility(i6);
}
i3 = activeSubscriptionType.getHeaderBackgroundError();
imageView.setImageResource(i3);
ImageView imageView2 = this.j.d;
ordinal = status.ordinal();
if (ordinal != 2) {
}
i4 = activeSubscriptionType.getHeaderImageError();
imageView2.setImageResource(i4);
int i6 = 0;
this.j.e.setImageResource(DrawableCompat.getThemedDrawableRes$default(this, activeSubscriptionType.getHeaderLogo(), 0, 2, (Object) null));
ImageView imageView3 = this.j.e;
m.checkNotNullExpressionValue(imageView3, "binding.activeSubscriptionHeaderLogo");
ordinal2 = activeSubscriptionType.ordinal();
if (ordinal2 != 0) {
}
imageView3.setContentDescription(b.i(this, i5, new Object[0], null, 4));
TextView textView = this.j.f;
m.checkNotNullExpressionValue(textView, "binding.activeSubscriptionHeaderText");
ordinal3 = activeSubscriptionType.ordinal();
if (ordinal3 == 0) {
}
textView.setText(charSequence2);
MaterialButton materialButton = this.j.i;
m.checkNotNullExpressionValue(materialButton, "binding.activeSubscriptionTopButton");
materialButton.setVisibility(z3 ^ true ? 0 : 8);
TextView textView2 = this.j.b;
m.checkNotNullExpressionValue(textView2, "binding.activeSubscriptionCancelButton");
textView2.setVisibility(function03 == null && !z3 && status != ModelSubscription.Status.CANCELED && !z4 ? 0 : 8);
MaterialButton materialButton2 = this.j.i;
int ordinal9 = status.ordinal();
materialButton2.setText(ordinal9 != 3 ? ordinal9 != 4 ? 2131892461 : 2131886913 : 2131892826);
this.j.i.setOnClickListener(new a(0, function0));
MaterialButton materialButton3 = this.j.i;
m.checkNotNullExpressionValue(materialButton3, "binding.activeSubscriptionTopButton");
materialButton3.setVisibility(function0 != null ? 0 : 8);
MaterialButton materialButton4 = this.j.i;
m.checkNotNullExpressionValue(materialButton4, "binding.activeSubscriptionTopButton");
materialButton4.setEnabled(!z2);
MaterialButton materialButton5 = this.j.g;
m.checkNotNullExpressionValue(materialButton5, "binding.activeSubscriptionManagePremiumGuildButton");
materialButton5.setVisibility(function02 != null ? 0 : 8);
this.j.g.setOnClickListener(new a(1, function02));
this.j.b.setOnClickListener(new a(2, function03));
ProgressBar progressBar = this.j.h;
m.checkNotNullExpressionValue(progressBar, "binding.activeSubscriptionProgress");
if (!z3) {
}
progressBar.setVisibility(i6);
}
}