package com.discord.views; import android.content.Context; import android.content.res.TypedArray; import android.graphics.drawable.ColorDrawable; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import androidx.annotation.ColorInt; import c.a.i.m2; import com.discord.R; import com.discord.utilities.dimen.DimenUtils; import com.discord.utilities.icon.IconUtils; import com.discord.utilities.images.MGImages; import com.discord.views.CutoutView; import com.facebook.drawee.generic.GenericDraweeHierarchy; import com.facebook.drawee.view.SimpleDraweeView; import d0.d0.f; import d0.t.n; import d0.t.u; import d0.z.d.m; import java.util.Collection; /* compiled from: PileView.kt */ public final class PileView extends FrameLayout { public int i = 3; public boolean j = true; public boolean k = true; public int l = DimenUtils.dpToPixels(16); public int m; @ColorInt public int n; public int o; public int p = DimenUtils.dpToPixels(2); public final CutoutView.a q; /* compiled from: java-style lambda group */ public static final class a implements b { public static final a a = new a(0); public static final a b = new a(1); /* renamed from: c reason: collision with root package name */ public static final a f2141c = new a(2); public final /* synthetic */ int d; public a(int i) { this.d = i; } @Override // com.discord.views.PileView.b public final String getImageUri(int i) { int i2 = this.d; if (i2 == 0) { return "asset://asset/images/default_avatar_0.jpg"; } if (i2 == 1) { return "asset://asset/images/default_avatar_1.jpg"; } if (i2 == 2) { return "asset://asset/images/default_avatar_2.jpg"; } throw null; } } /* compiled from: PileView.kt */ public interface b { String getImageUri(int i); } /* JADX INFO: super call moved to the top of the method (can break code semantics) */ public PileView(Context context, AttributeSet attributeSet) { super(context, attributeSet); m.checkNotNullParameter(context, "context"); int[] iArr = R.a.PileView; m.checkNotNullExpressionValue(iArr, "R.styleable.PileView"); Context context2 = getContext(); m.checkNotNullExpressionValue(context2, "context"); TypedArray obtainStyledAttributes = context2.obtainStyledAttributes(attributeSet, iArr); m.checkNotNullExpressionValue(obtainStyledAttributes, "obtainStyledAttributes(attrs, styleable)"); this.i = obtainStyledAttributes.getInt(5, this.i); this.l = obtainStyledAttributes.getDimensionPixelSize(4, this.l); this.n = obtainStyledAttributes.getColor(0, this.n); this.o = obtainStyledAttributes.getDimensionPixelSize(3, this.o); this.m = obtainStyledAttributes.getDimensionPixelSize(2, this.m); this.p = obtainStyledAttributes.getDimensionPixelSize(1, this.p); this.j = obtainStyledAttributes.getBoolean(7, this.j); this.k = obtainStyledAttributes.getBoolean(6, this.k); obtainStyledAttributes.recycle(); int i = this.m; int i2 = this.p; this.q = new CutoutView.a.b((this.l / 2) + i2, i + i2); if (isInEditMode()) { setItems(n.listOf((Object[]) new b[]{a.a, a.b, a.f2141c})); } } public final void setItems(Collection collection) { m.checkNotNullParameter(collection, "items"); removeAllViews(); int coerceAtMost = f.coerceAtMost(collection.size(), this.i); int i = coerceAtMost - 1; int i2 = 0; for (Object obj : u.take(collection, coerceAtMost)) { int i3 = i2 + 1; if (i2 < 0) { n.throwIndexOverflow(); } b bVar = (b) obj; int i4 = this.l * i2; int i5 = this.m * i2; View inflate = LayoutInflater.from(getContext()).inflate(2131558786, (ViewGroup) this, false); int i6 = 2131364340; SimpleDraweeView simpleDraweeView = (SimpleDraweeView) inflate.findViewById(2131364340); if (simpleDraweeView != null) { i6 = 2131364341; SimpleDraweeView simpleDraweeView2 = (SimpleDraweeView) inflate.findViewById(2131364341); if (simpleDraweeView2 != null) { CutoutView cutoutView = (CutoutView) inflate; m.checkNotNullExpressionValue(new m2(cutoutView, simpleDraweeView, simpleDraweeView2), "ViewPileItemBinding.infl…om(context), this, false)"); cutoutView.setId(FrameLayout.generateViewId()); int i7 = this.l; FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(i7, i7); layoutParams.setMarginStart(i4 - i5); cutoutView.setLayoutParams(layoutParams); m.checkNotNullExpressionValue(cutoutView, "itemBinding.root"); addView(cutoutView, cutoutView.getLayoutParams()); if (this.o > 0) { m.checkNotNullExpressionValue(simpleDraweeView2, "itemBinding.pileItemImage"); int i8 = this.o; simpleDraweeView2.setPadding(i8, i8, i8, i8); if (!this.j) { m.checkNotNullExpressionValue(simpleDraweeView2, "itemBinding.pileItemImage"); GenericDraweeHierarchy hierarchy = simpleDraweeView2.getHierarchy(); m.checkNotNullExpressionValue(hierarchy, "itemBinding.pileItemImage.hierarchy"); hierarchy.r(null); } if (!this.k) { m.checkNotNullExpressionValue(simpleDraweeView, "itemBinding.pileItemBg"); GenericDraweeHierarchy hierarchy2 = simpleDraweeView.getHierarchy(); m.checkNotNullExpressionValue(hierarchy2, "itemBinding.pileItemBg.hierarchy"); hierarchy2.r(null); } if (this.n != 0) { m.checkNotNullExpressionValue(simpleDraweeView, "itemBinding.pileItemBg"); simpleDraweeView.getHierarchy().o(1, new ColorDrawable(this.n)); m.checkNotNullExpressionValue(simpleDraweeView, "itemBinding.pileItemBg"); simpleDraweeView.setVisibility(0); } } if (i2 != i) { cutoutView.setStyle(this.q); } String imageUri = bVar.getImageUri(IconUtils.getMediaProxySize(this.l)); m.checkNotNullExpressionValue(simpleDraweeView2, "itemBinding.pileItemImage"); MGImages.setImage$default(simpleDraweeView2, imageUri, 0, 0, true, null, null, 108, null); i2 = i3; } } throw new NullPointerException("Missing required view with ID: ".concat(inflate.getResources().getResourceName(i6))); } } }