412 lines
18 KiB
Java
412 lines
18 KiB
Java
package com.discord.widgets.settings.premium;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.drawable.Drawable;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.TextView;
|
|
import androidx.annotation.StringRes;
|
|
import androidx.recyclerview.widget.RecyclerView;
|
|
import c.a.l.b;
|
|
import c.d.b.a.a;
|
|
import com.android.billingclient.api.SkuDetails;
|
|
import com.discord.databinding.WidgetChoosePlanAdapterHeaderItemBinding;
|
|
import com.discord.databinding.WidgetChoosePlanAdapterPlanItemBinding;
|
|
import com.discord.utilities.billing.GooglePlaySku;
|
|
import com.discord.utilities.drawable.DrawableCompat;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerAdapterSimple;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerDataPayload;
|
|
import com.discord.utilities.mg_recycler.MGRecyclerViewHolder;
|
|
import com.discord.utilities.premium.PremiumUtils;
|
|
import com.google.android.material.card.MaterialCardView;
|
|
import d0.z.d.m;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function3;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: WidgetChoosePlanAdapter.kt */
|
|
public final class WidgetChoosePlanAdapter extends MGRecyclerAdapterSimple<Item> {
|
|
private Function3<? super GooglePlaySku, ? super String, ? super SkuDetails, Unit> onClickPlan = WidgetChoosePlanAdapter$onClickPlan$1.INSTANCE;
|
|
|
|
/* compiled from: WidgetChoosePlanAdapter.kt */
|
|
public static final class DividerViewHolder extends MGRecyclerViewHolder<WidgetChoosePlanAdapter, Item> {
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public DividerViewHolder(WidgetChoosePlanAdapter widgetChoosePlanAdapter) {
|
|
super(2131558975, widgetChoosePlanAdapter);
|
|
m.checkNotNullParameter(widgetChoosePlanAdapter, "adapter");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChoosePlanAdapter.kt */
|
|
public static final class HeaderViewHolder extends MGRecyclerViewHolder<WidgetChoosePlanAdapter, Item> {
|
|
private final WidgetChoosePlanAdapterHeaderItemBinding binding;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public HeaderViewHolder(WidgetChoosePlanAdapter widgetChoosePlanAdapter) {
|
|
super(2131558976, widgetChoosePlanAdapter);
|
|
m.checkNotNullParameter(widgetChoosePlanAdapter, "adapter");
|
|
View view = this.itemView;
|
|
TextView textView = (TextView) view.findViewById(2131364616);
|
|
if (textView != null) {
|
|
WidgetChoosePlanAdapterHeaderItemBinding widgetChoosePlanAdapterHeaderItemBinding = new WidgetChoosePlanAdapterHeaderItemBinding((FrameLayout) view, textView);
|
|
m.checkNotNullExpressionValue(widgetChoosePlanAdapterHeaderItemBinding, "WidgetChoosePlanAdapterH…temBinding.bind(itemView)");
|
|
this.binding = widgetChoosePlanAdapterHeaderItemBinding;
|
|
return;
|
|
}
|
|
throw new NullPointerException("Missing required view with ID: ".concat(view.getResources().getResourceName(2131364616)));
|
|
}
|
|
|
|
public void onConfigure(int i, Item item) {
|
|
m.checkNotNullParameter(item, "data");
|
|
super.onConfigure(i, (int) item);
|
|
TextView textView = this.binding.b;
|
|
m.checkNotNullExpressionValue(textView, "binding.selectSubscriptionHeaderText");
|
|
b.m(textView, ((Item.Header) item).getTitleStringResId(), new Object[0], null, 4);
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChoosePlanAdapter.kt */
|
|
public static abstract class Item implements MGRecyclerDataPayload {
|
|
public static final Companion Companion = new Companion(null);
|
|
public static final int TYPE_DIVIDER = 2;
|
|
public static final int TYPE_HEADER = 0;
|
|
public static final int TYPE_PLAN = 1;
|
|
private final int type;
|
|
|
|
/* compiled from: WidgetChoosePlanAdapter.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChoosePlanAdapter.kt */
|
|
public static final class Divider extends Item {
|
|
private final String key = String.valueOf(getType());
|
|
|
|
public Divider() {
|
|
super(2, null);
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
|
|
public String getKey() {
|
|
return this.key;
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChoosePlanAdapter.kt */
|
|
public static final class Header extends Item {
|
|
private final String key = String.valueOf(getType());
|
|
private final int titleStringResId;
|
|
|
|
public Header(@StringRes int i) {
|
|
super(0, null);
|
|
this.titleStringResId = i;
|
|
}
|
|
|
|
public static /* synthetic */ Header copy$default(Header header, int i, int i2, Object obj) {
|
|
if ((i2 & 1) != 0) {
|
|
i = header.titleStringResId;
|
|
}
|
|
return header.copy(i);
|
|
}
|
|
|
|
public final int component1() {
|
|
return this.titleStringResId;
|
|
}
|
|
|
|
public final Header copy(@StringRes int i) {
|
|
return new Header(i);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this != obj) {
|
|
return (obj instanceof Header) && this.titleStringResId == ((Header) obj).titleStringResId;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
|
|
public String getKey() {
|
|
return this.key;
|
|
}
|
|
|
|
public final int getTitleStringResId() {
|
|
return this.titleStringResId;
|
|
}
|
|
|
|
public int hashCode() {
|
|
return this.titleStringResId;
|
|
}
|
|
|
|
public String toString() {
|
|
return a.z(a.L("Header(titleStringResId="), this.titleStringResId, ")");
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChoosePlanAdapter.kt */
|
|
public static final class Plan extends Item {
|
|
private final GooglePlaySku displaySku;
|
|
private final boolean isCurrentPlan;
|
|
private final String key;
|
|
private final String oldSkuName;
|
|
private final GooglePlaySku purchaseSku;
|
|
private final SkuDetails skuDetails;
|
|
private final SkuDetails upgradeSkuDetails;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Plan(GooglePlaySku googlePlaySku, SkuDetails skuDetails, GooglePlaySku googlePlaySku2, String str, SkuDetails skuDetails2, boolean z2) {
|
|
super(1, null);
|
|
m.checkNotNullParameter(googlePlaySku, "displaySku");
|
|
m.checkNotNullParameter(skuDetails, "skuDetails");
|
|
this.displaySku = googlePlaySku;
|
|
this.skuDetails = skuDetails;
|
|
this.purchaseSku = googlePlaySku2;
|
|
this.oldSkuName = str;
|
|
this.upgradeSkuDetails = skuDetails2;
|
|
this.isCurrentPlan = z2;
|
|
this.key = getType() + googlePlaySku.getSkuName();
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ Plan(GooglePlaySku googlePlaySku, SkuDetails skuDetails, GooglePlaySku googlePlaySku2, String str, SkuDetails skuDetails2, boolean z2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(googlePlaySku, skuDetails, googlePlaySku2, (i & 8) != 0 ? null : str, (i & 16) != 0 ? null : skuDetails2, (i & 32) != 0 ? false : z2);
|
|
}
|
|
|
|
public static /* synthetic */ Plan copy$default(Plan plan, GooglePlaySku googlePlaySku, SkuDetails skuDetails, GooglePlaySku googlePlaySku2, String str, SkuDetails skuDetails2, boolean z2, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
googlePlaySku = plan.displaySku;
|
|
}
|
|
if ((i & 2) != 0) {
|
|
skuDetails = plan.skuDetails;
|
|
}
|
|
if ((i & 4) != 0) {
|
|
googlePlaySku2 = plan.purchaseSku;
|
|
}
|
|
if ((i & 8) != 0) {
|
|
str = plan.oldSkuName;
|
|
}
|
|
if ((i & 16) != 0) {
|
|
skuDetails2 = plan.upgradeSkuDetails;
|
|
}
|
|
if ((i & 32) != 0) {
|
|
z2 = plan.isCurrentPlan;
|
|
}
|
|
return plan.copy(googlePlaySku, skuDetails, googlePlaySku2, str, skuDetails2, z2);
|
|
}
|
|
|
|
public final GooglePlaySku component1() {
|
|
return this.displaySku;
|
|
}
|
|
|
|
public final SkuDetails component2() {
|
|
return this.skuDetails;
|
|
}
|
|
|
|
public final GooglePlaySku component3() {
|
|
return this.purchaseSku;
|
|
}
|
|
|
|
public final String component4() {
|
|
return this.oldSkuName;
|
|
}
|
|
|
|
public final SkuDetails component5() {
|
|
return this.upgradeSkuDetails;
|
|
}
|
|
|
|
public final boolean component6() {
|
|
return this.isCurrentPlan;
|
|
}
|
|
|
|
public final Plan copy(GooglePlaySku googlePlaySku, SkuDetails skuDetails, GooglePlaySku googlePlaySku2, String str, SkuDetails skuDetails2, boolean z2) {
|
|
m.checkNotNullParameter(googlePlaySku, "displaySku");
|
|
m.checkNotNullParameter(skuDetails, "skuDetails");
|
|
return new Plan(googlePlaySku, skuDetails, googlePlaySku2, str, skuDetails2, z2);
|
|
}
|
|
|
|
public boolean equals(Object obj) {
|
|
if (this == obj) {
|
|
return true;
|
|
}
|
|
if (!(obj instanceof Plan)) {
|
|
return false;
|
|
}
|
|
Plan plan = (Plan) obj;
|
|
return m.areEqual(this.displaySku, plan.displaySku) && m.areEqual(this.skuDetails, plan.skuDetails) && m.areEqual(this.purchaseSku, plan.purchaseSku) && m.areEqual(this.oldSkuName, plan.oldSkuName) && m.areEqual(this.upgradeSkuDetails, plan.upgradeSkuDetails) && this.isCurrentPlan == plan.isCurrentPlan;
|
|
}
|
|
|
|
public final GooglePlaySku getDisplaySku() {
|
|
return this.displaySku;
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload, com.discord.utilities.recycler.DiffKeyProvider
|
|
public String getKey() {
|
|
return this.key;
|
|
}
|
|
|
|
public final String getOldSkuName() {
|
|
return this.oldSkuName;
|
|
}
|
|
|
|
public final GooglePlaySku getPurchaseSku() {
|
|
return this.purchaseSku;
|
|
}
|
|
|
|
public final SkuDetails getSkuDetails() {
|
|
return this.skuDetails;
|
|
}
|
|
|
|
public final SkuDetails getUpgradeSkuDetails() {
|
|
return this.upgradeSkuDetails;
|
|
}
|
|
|
|
public int hashCode() {
|
|
GooglePlaySku googlePlaySku = this.displaySku;
|
|
int i = 0;
|
|
int hashCode = (googlePlaySku != null ? googlePlaySku.hashCode() : 0) * 31;
|
|
SkuDetails skuDetails = this.skuDetails;
|
|
int hashCode2 = (hashCode + (skuDetails != null ? skuDetails.hashCode() : 0)) * 31;
|
|
GooglePlaySku googlePlaySku2 = this.purchaseSku;
|
|
int hashCode3 = (hashCode2 + (googlePlaySku2 != null ? googlePlaySku2.hashCode() : 0)) * 31;
|
|
String str = this.oldSkuName;
|
|
int hashCode4 = (hashCode3 + (str != null ? str.hashCode() : 0)) * 31;
|
|
SkuDetails skuDetails2 = this.upgradeSkuDetails;
|
|
if (skuDetails2 != null) {
|
|
i = skuDetails2.hashCode();
|
|
}
|
|
int i2 = (hashCode4 + i) * 31;
|
|
boolean z2 = this.isCurrentPlan;
|
|
if (z2) {
|
|
z2 = true;
|
|
}
|
|
int i3 = z2 ? 1 : 0;
|
|
int i4 = z2 ? 1 : 0;
|
|
int i5 = z2 ? 1 : 0;
|
|
return i2 + i3;
|
|
}
|
|
|
|
public final boolean isCurrentPlan() {
|
|
return this.isCurrentPlan;
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder L = a.L("Plan(displaySku=");
|
|
L.append(this.displaySku);
|
|
L.append(", skuDetails=");
|
|
L.append(this.skuDetails);
|
|
L.append(", purchaseSku=");
|
|
L.append(this.purchaseSku);
|
|
L.append(", oldSkuName=");
|
|
L.append(this.oldSkuName);
|
|
L.append(", upgradeSkuDetails=");
|
|
L.append(this.upgradeSkuDetails);
|
|
L.append(", isCurrentPlan=");
|
|
return a.G(L, this.isCurrentPlan, ")");
|
|
}
|
|
}
|
|
|
|
private Item(int i) {
|
|
this.type = i;
|
|
}
|
|
|
|
public /* synthetic */ Item(int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(i);
|
|
}
|
|
|
|
@Override // com.discord.utilities.mg_recycler.MGRecyclerDataPayload
|
|
public int getType() {
|
|
return this.type;
|
|
}
|
|
}
|
|
|
|
/* compiled from: WidgetChoosePlanAdapter.kt */
|
|
public static final class PlanViewHeader extends MGRecyclerViewHolder<WidgetChoosePlanAdapter, Item> {
|
|
private final WidgetChoosePlanAdapterPlanItemBinding binding;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public PlanViewHeader(WidgetChoosePlanAdapter widgetChoosePlanAdapter) {
|
|
super(2131558977, widgetChoosePlanAdapter);
|
|
m.checkNotNullParameter(widgetChoosePlanAdapter, "adapter");
|
|
WidgetChoosePlanAdapterPlanItemBinding a = WidgetChoosePlanAdapterPlanItemBinding.a(this.itemView);
|
|
m.checkNotNullExpressionValue(a, "WidgetChoosePlanAdapterP…temBinding.bind(itemView)");
|
|
this.binding = a;
|
|
}
|
|
|
|
public static final /* synthetic */ WidgetChoosePlanAdapter access$getAdapter$p(PlanViewHeader planViewHeader) {
|
|
return (WidgetChoosePlanAdapter) planViewHeader.adapter;
|
|
}
|
|
|
|
public void onConfigure(int i, Item item) {
|
|
m.checkNotNullParameter(item, "data");
|
|
super.onConfigure(i, (int) item);
|
|
Item.Plan plan = (Item.Plan) item;
|
|
TextView textView = this.binding.f;
|
|
m.checkNotNullExpressionValue(textView, "binding.planItemName");
|
|
textView.setText(plan.getSkuDetails().a());
|
|
TextView textView2 = this.binding.g;
|
|
m.checkNotNullExpressionValue(textView2, "binding.planItemPrice");
|
|
PremiumUtils premiumUtils = PremiumUtils.INSTANCE;
|
|
MaterialCardView materialCardView = this.binding.f1753c;
|
|
m.checkNotNullExpressionValue(materialCardView, "binding.planItemContainer");
|
|
Context context = materialCardView.getContext();
|
|
m.checkNotNullExpressionValue(context, "binding.planItemContainer.context");
|
|
textView2.setText(premiumUtils.getPlanPriceText(context, plan.getSkuDetails()));
|
|
this.binding.e.setImageResource(plan.getDisplaySku().getIconDrawableResId());
|
|
TextView textView3 = this.binding.d;
|
|
m.checkNotNullExpressionValue(textView3, "binding.planItemCurrentPlan");
|
|
textView3.setVisibility(plan.isCurrentPlan() ? 0 : 8);
|
|
this.binding.b.setImageResource(plan.isCurrentPlan() ? GooglePlaySku.Companion.getBorderResource(plan.getDisplaySku().getType()) : 0);
|
|
if (plan.getPurchaseSku() == null) {
|
|
TextView textView4 = this.binding.g;
|
|
m.checkNotNullExpressionValue(textView4, "binding.planItemPrice");
|
|
DrawableCompat.setCompoundDrawablesCompat$default(textView4, (Drawable) null, (Drawable) null, (Drawable) null, (Drawable) null, 11, (Object) null);
|
|
return;
|
|
}
|
|
View view = this.itemView;
|
|
m.checkNotNullExpressionValue(view, "itemView");
|
|
int themedDrawableRes$default = DrawableCompat.getThemedDrawableRes$default(view, 2130969427, 0, 2, (Object) null);
|
|
TextView textView5 = this.binding.g;
|
|
m.checkNotNullExpressionValue(textView5, "binding.planItemPrice");
|
|
DrawableCompat.setCompoundDrawablesCompat$default(textView5, 0, 0, themedDrawableRes$default, 0, 11, (Object) null);
|
|
this.binding.f1753c.setOnClickListener(new WidgetChoosePlanAdapter$PlanViewHeader$onConfigure$1(this, item));
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public WidgetChoosePlanAdapter(RecyclerView recyclerView) {
|
|
super(recyclerView, false, 2, null);
|
|
m.checkNotNullParameter(recyclerView, "recycler");
|
|
}
|
|
|
|
public static final /* synthetic */ Function3 access$getOnClickPlan$p(WidgetChoosePlanAdapter widgetChoosePlanAdapter) {
|
|
return widgetChoosePlanAdapter.onClickPlan;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setOnClickPlan$p(WidgetChoosePlanAdapter widgetChoosePlanAdapter, Function3 function3) {
|
|
widgetChoosePlanAdapter.onClickPlan = function3;
|
|
}
|
|
|
|
@Override // androidx.recyclerview.widget.RecyclerView.Adapter
|
|
public MGRecyclerViewHolder<WidgetChoosePlanAdapter, Item> onCreateViewHolder(ViewGroup viewGroup, int i) {
|
|
m.checkNotNullParameter(viewGroup, "parent");
|
|
if (i == 0) {
|
|
return new HeaderViewHolder(this);
|
|
}
|
|
if (i == 1) {
|
|
return new PlanViewHeader(this);
|
|
}
|
|
if (i == 2) {
|
|
return new DividerViewHolder(this);
|
|
}
|
|
throw invalidViewTypeException(i);
|
|
}
|
|
|
|
public final void setOnClickPlan(Function3<? super GooglePlaySku, ? super String, ? super SkuDetails, Unit> function3) {
|
|
m.checkNotNullParameter(function3, "onClickPlan");
|
|
this.onClickPlan = function3;
|
|
}
|
|
}
|