189 lines
10 KiB
Java
189 lines
10 KiB
Java
package com.discord.widgets.guild_role_subscriptions;
|
|
|
|
import android.content.Context;
|
|
import android.content.res.TypedArray;
|
|
import android.util.AttributeSet;
|
|
import android.view.LayoutInflater;
|
|
import android.widget.ImageView;
|
|
import android.widget.TextView;
|
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
|
import c.f.g.e.r;
|
|
import c.f.g.e.v;
|
|
import c.f.g.f.c;
|
|
import com.discord.R;
|
|
import com.discord.databinding.ViewGuildRoleSubscriptionImageUploadBinding;
|
|
import com.discord.utilities.color.ColorCompat;
|
|
import com.discord.utilities.drawable.DrawableCompat;
|
|
import com.discord.utilities.icon.IconUtils;
|
|
import com.discord.widgets.guild_role_subscriptions.tier.model.GuildRoleSubscriptionTier;
|
|
import com.facebook.drawee.drawable.ScalingUtils$ScaleType;
|
|
import com.facebook.drawee.generic.GenericDraweeHierarchy;
|
|
import com.facebook.drawee.view.SimpleDraweeView;
|
|
import d0.g0.t;
|
|
import d0.z.d.m;
|
|
import kotlin.Unit;
|
|
import kotlin.jvm.functions.Function0;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
/* compiled from: GuildSubscriptionRoleImageUploadView.kt */
|
|
public final class GuildSubscriptionRoleImageUploadView extends ConstraintLayout {
|
|
private static final int CIRCLE_IMAGE_STYLE = 0;
|
|
public static final Companion Companion = new Companion(null);
|
|
private static final int ROUNDED_IMAGE_STYLE = 1;
|
|
private int avatarSize;
|
|
private final ViewGuildRoleSubscriptionImageUploadBinding binding;
|
|
private Function0<Unit> onImageChooserClickListener;
|
|
private Function0<Unit> onImageRemovedListener;
|
|
|
|
/* compiled from: GuildSubscriptionRoleImageUploadView.kt */
|
|
public static final class Companion {
|
|
private Companion() {
|
|
}
|
|
|
|
public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public GuildSubscriptionRoleImageUploadView(Context context) {
|
|
super(context);
|
|
m.checkNotNullParameter(context, "context");
|
|
ViewGuildRoleSubscriptionImageUploadBinding a = ViewGuildRoleSubscriptionImageUploadBinding.a(LayoutInflater.from(getContext()), this);
|
|
m.checkNotNullExpressionValue(a, "ViewGuildRoleSubscriptio…ater.from(context), this)");
|
|
this.binding = a;
|
|
this.avatarSize = getResources().getDimensionPixelSize(R.dimen.avatar_size_huge);
|
|
initialize$default(this, null, 1, null);
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public GuildSubscriptionRoleImageUploadView(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
m.checkNotNullParameter(context, "context");
|
|
ViewGuildRoleSubscriptionImageUploadBinding a = ViewGuildRoleSubscriptionImageUploadBinding.a(LayoutInflater.from(getContext()), this);
|
|
m.checkNotNullExpressionValue(a, "ViewGuildRoleSubscriptio…ater.from(context), this)");
|
|
this.binding = a;
|
|
this.avatarSize = getResources().getDimensionPixelSize(R.dimen.avatar_size_huge);
|
|
initialize(attributeSet);
|
|
}
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public GuildSubscriptionRoleImageUploadView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
m.checkNotNullParameter(context, "context");
|
|
ViewGuildRoleSubscriptionImageUploadBinding a = ViewGuildRoleSubscriptionImageUploadBinding.a(LayoutInflater.from(getContext()), this);
|
|
m.checkNotNullExpressionValue(a, "ViewGuildRoleSubscriptio…ater.from(context), this)");
|
|
this.binding = a;
|
|
this.avatarSize = getResources().getDimensionPixelSize(R.dimen.avatar_size_huge);
|
|
initialize(attributeSet);
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ GuildSubscriptionRoleImageUploadView(Context context, AttributeSet attributeSet, int i, int i2, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(context, (i2 & 2) != 0 ? null : attributeSet, (i2 & 4) != 0 ? 0 : i);
|
|
}
|
|
|
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
|
public /* synthetic */ GuildSubscriptionRoleImageUploadView(Context context, AttributeSet attributeSet, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
|
this(context, (i & 2) != 0 ? null : attributeSet);
|
|
}
|
|
|
|
public static final /* synthetic */ Function0 access$getOnImageChooserClickListener$p(GuildSubscriptionRoleImageUploadView guildSubscriptionRoleImageUploadView) {
|
|
return guildSubscriptionRoleImageUploadView.onImageChooserClickListener;
|
|
}
|
|
|
|
public static final /* synthetic */ void access$setOnImageChooserClickListener$p(GuildSubscriptionRoleImageUploadView guildSubscriptionRoleImageUploadView, Function0 function0) {
|
|
guildSubscriptionRoleImageUploadView.onImageChooserClickListener = function0;
|
|
}
|
|
|
|
private final void initialize(AttributeSet attributeSet) {
|
|
ScalingUtils$ScaleType scalingUtils$ScaleType;
|
|
Context context = getContext();
|
|
m.checkNotNullExpressionValue(context, "context");
|
|
int[] iArr = R.a.GuildSubscriptionRoleImageUploadView;
|
|
m.checkNotNullExpressionValue(iArr, "R.styleable.GuildSubscriptionRoleImageUploadView");
|
|
TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, iArr);
|
|
m.checkNotNullExpressionValue(obtainStyledAttributes, "obtainStyledAttributes(attrs, styleable)");
|
|
if (obtainStyledAttributes.getBoolean(3, false)) {
|
|
ScalingUtils$ScaleType scalingUtils$ScaleType2 = ScalingUtils$ScaleType.a;
|
|
scalingUtils$ScaleType = r.l;
|
|
} else {
|
|
ScalingUtils$ScaleType scalingUtils$ScaleType3 = ScalingUtils$ScaleType.a;
|
|
scalingUtils$ScaleType = v.l;
|
|
}
|
|
SimpleDraweeView simpleDraweeView = this.binding.f1685c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.guildSubscriptionImage");
|
|
GenericDraweeHierarchy hierarchy = simpleDraweeView.getHierarchy();
|
|
m.checkNotNullExpressionValue(hierarchy, "binding.guildSubscriptionImage.hierarchy");
|
|
hierarchy.n(scalingUtils$ScaleType);
|
|
int i = obtainStyledAttributes.getInt(2, 0);
|
|
if (i == 0) {
|
|
this.binding.f1685c.setBackgroundResource(DrawableCompat.getThemedDrawableRes(this, (int) R.attr.primary_700_circle, 0));
|
|
} else if (i == 1) {
|
|
SimpleDraweeView simpleDraweeView2 = this.binding.f1685c;
|
|
simpleDraweeView2.setBackgroundResource(R.drawable.drawable_rect_rounded_bg_tertiary);
|
|
GenericDraweeHierarchy hierarchy2 = simpleDraweeView2.getHierarchy();
|
|
m.checkNotNullExpressionValue(hierarchy2, "hierarchy");
|
|
c cVar = new c();
|
|
cVar.b = false;
|
|
hierarchy2.s(cVar);
|
|
m.checkNotNullExpressionValue(simpleDraweeView2, "binding.guildSubscriptio… }\n }");
|
|
}
|
|
String string = obtainStyledAttributes.getString(0);
|
|
if (string == null) {
|
|
string = getContext().getString(R.string.guild_role_subscription_tier_detail_custom_image_description);
|
|
}
|
|
m.checkNotNullExpressionValue(string, "it.getString(R.styleable…image_description\n )");
|
|
TextView textView = this.binding.e;
|
|
m.checkNotNullExpressionValue(textView, "binding.guildSubscriptionUploadImageLabel");
|
|
textView.setText(string);
|
|
this.avatarSize = obtainStyledAttributes.getDimensionPixelSize(1, getResources().getDimensionPixelSize(R.dimen.avatar_size_huge));
|
|
obtainStyledAttributes.recycle();
|
|
setBackgroundColor(ColorCompat.getThemedColor(this, (int) R.attr.colorBackgroundSecondary));
|
|
this.binding.d.setOnClickListener(new GuildSubscriptionRoleImageUploadView$initialize$2(this));
|
|
this.binding.f1685c.setOnClickListener(new GuildSubscriptionRoleImageUploadView$initialize$3(this));
|
|
this.binding.b.setOnClickListener(new GuildSubscriptionRoleImageUploadView$initialize$4(this));
|
|
}
|
|
|
|
public static /* synthetic */ void initialize$default(GuildSubscriptionRoleImageUploadView guildSubscriptionRoleImageUploadView, AttributeSet attributeSet, int i, Object obj) {
|
|
if ((i & 1) != 0) {
|
|
attributeSet = null;
|
|
}
|
|
guildSubscriptionRoleImageUploadView.initialize(attributeSet);
|
|
}
|
|
|
|
private final void updateImage(Long l, long j) {
|
|
updateImage(IconUtils.INSTANCE.getAssetImage(l, String.valueOf(j), this.avatarSize));
|
|
}
|
|
|
|
private final void updateImage(String str) {
|
|
SimpleDraweeView simpleDraweeView = this.binding.f1685c;
|
|
m.checkNotNullExpressionValue(simpleDraweeView, "binding.guildSubscriptionImage");
|
|
int i = this.avatarSize;
|
|
IconUtils.setIcon$default(simpleDraweeView, str, i, i, false, null, null, 112, null);
|
|
ImageView imageView = this.binding.b;
|
|
m.checkNotNullExpressionValue(imageView, "binding.guildSubscriptionEditImage");
|
|
int i2 = 0;
|
|
if (!(!(str == null || t.isBlank(str)))) {
|
|
i2 = 8;
|
|
}
|
|
imageView.setVisibility(i2);
|
|
}
|
|
|
|
public final void configureUI(Function0<Unit> function0, Function0<Unit> function02) {
|
|
m.checkNotNullParameter(function0, "onImageRemoved");
|
|
m.checkNotNullParameter(function02, "onImageChooserClicked");
|
|
this.onImageRemovedListener = function0;
|
|
this.onImageChooserClickListener = function02;
|
|
}
|
|
|
|
public final void updateImage(GuildRoleSubscriptionTier guildRoleSubscriptionTier) {
|
|
m.checkNotNullParameter(guildRoleSubscriptionTier, "guildSubscriptionTier");
|
|
String image = guildRoleSubscriptionTier.getImage();
|
|
if (!(image == null || t.isBlank(image)) || guildRoleSubscriptionTier.getImageAssetId() == null) {
|
|
updateImage(guildRoleSubscriptionTier.getImage());
|
|
} else {
|
|
updateImage(guildRoleSubscriptionTier.getApplicationId(), guildRoleSubscriptionTier.getImageAssetId().longValue());
|
|
}
|
|
}
|
|
}
|