得物.apk(点击下载) / QixiLotteryLayout.java


package com.shizhuang.duapp.modules.live.common.widget;

import a.f;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.OvershootInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.Group;
import androidx.core.util.Consumer;
import cd.h;
import com.meituan.robust.ChangeQuickRedirect;
import com.meituan.robust.PatchProxy;
import com.meituan.robust.PatchProxyResult;
import com.shizhuang.duapp.R;
import com.shizhuang.duapp.common.extension.ViewExtensionKt;
import com.shizhuang.duapp.common.widget.font.FontText;
import com.shizhuang.duapp.common.widget.shapeview.ShapeTextView;
import com.shizhuang.duapp.libs.duimageloaderview.options.DuRequestOptions;
import com.shizhuang.duapp.modules.live.anchor.detail.widget.qixi.QixiReporter;
import com.shizhuang.duapp.modules.live.anchor.detail.widget.qixi.QixiReporter$reportDialogExposure$1;
import com.shizhuang.duapp.modules.live.common.base.BaseFrameLayout;
import com.shizhuang.duapp.modules.live.common.model.live.message.QixiLotteryResult;
import com.shizhuang.duapp.modules.live.common.pkmic.qixi.AdaptiveSizeGroup;
import cq.g;
import fi.b;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import jp0.t;
import kotlin.Metadata;
import kotlin.collections.CollectionsKt__CollectionsKt;
import kotlin.jvm.JvmOverloads;
import kotlin.jvm.internal.Ref;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@Metadata(bv = {}, d1 = {"\u00008\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\t\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001B'\b\u0007\u0012\u0006\u0010\u001b\u001a\u00020\u001a\u0012\n\b\u0002\u0010\u001d\u001a\u0004\u0018\u00010\u001c\u0012\b\b\u0002\u0010\u001e\u001a\u00020\u0003¢\u0006\u0004\b\u001f\u0010 J\b\u0010\u0004\u001a\u00020\u0003H\u0014J\u0010\u0010\u0007\u001a\u00020\u00062\b\u0010\u0005\u001a\u0004\u0018\u00010\u0002J\u000e\u0010\n\u001a\u00020\u00062\u0006\u0010\t\u001a\u00020\bR\"\u0010\u0011\u001a\u00020\u00038\u0006@\u0006X†\u000e¢\u0006\u0012\n\u0004\b\u000b\u0010\f\u001a\u0004\b\r\u0010\u000e\"\u0004\b\u000f\u0010\u0010R,\u0010\u0019\u001a\f\u0012\u0006\u0012\u0004\u0018\u00010\u0002\u0018\u00010\u00128\u0006@\u0006X†\u000e¢\u0006\u0012\n\u0004\b\u0013\u0010\u0014\u001a\u0004\b\u0015\u0010\u0016\"\u0004\b\u0017\u0010\u0018¨\u0006!"}, d2 = {"Lcom/shizhuang/duapp/modules/live/common/widget/QixiLotteryLayout;", "Lcom/shizhuang/duapp/modules/live/common/base/BaseFrameLayout;", "Lcom/shizhuang/duapp/modules/live/common/model/live/message/QixiLotteryResult;", "", "getLayoutId", "result", "", "setGiftInfo", "Landroid/view/View$OnClickListener;", "onClickListener", "setOnCloseClickListener", "f", "I", "getLightUpType", "()I", "setLightUpType", "(I)V", "lightUpType", "Landroidx/core/util/Consumer;", "g", "Landroidx/core/util/Consumer;", "getOnDismissListener", "()Landroidx/core/util/Consumer;", "setOnDismissListener", "(Landroidx/core/util/Consumer;)V", "onDismissListener", "Landroid/content/Context;", "context", "Landroid/util/AttributeSet;", "attrs", "defStyleAttr", "<init>", "(Landroid/content/Context;Landroid/util/AttributeSet;I)V", "du_live_release"}, k = 1, mv = {1, 4, 2})
/* compiled from: QixiLotteryLayout.kt */
public final class QixiLotteryLayout extends BaseFrameLayout<QixiLotteryResult> {
    public static ChangeQuickRedirect changeQuickRedirect;
    public QixiLotteryResult e;
    public int f;
    @Nullable

    /* renamed from: g  reason: collision with root package name */
    public Consumer<QixiLotteryResult> f18689g;

    /* renamed from: h  reason: collision with root package name */
    public HashMap f18690h;

    /* compiled from: QixiLotteryLayout.kt */
    public static final class a implements Runnable {
        public static ChangeQuickRedirect changeQuickRedirect;
        public final /* synthetic */ QixiLotteryLayout b;

        /* renamed from: c  reason: collision with root package name */
        public final /* synthetic */ boolean f18691c;

        public a(QixiLotteryLayout qixiLotteryLayout, boolean z) {
            this.b = qixiLotteryLayout;
            this.f18691c = z;
        }

        public final void run() {
            if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 202170, new Class[0], Void.TYPE).isSupported) {
                if (!this.f18691c) {
                    Consumer<QixiLotteryResult> onDismissListener = this.b.getOnDismissListener();
                    if (onDismissListener != null) {
                        onDismissListener.accept(this.b.e);
                        return;
                    }
                    return;
                }
                QixiLotteryLayout qixiLotteryLayout = this.b;
                ChangeQuickRedirect changeQuickRedirect2 = QixiLotteryLayout.changeQuickRedirect;
                Object[] objArr = {qixiLotteryLayout, new Float(0.2f), new Float(0.2f), new Float(1.0f), new Float(1.0f)};
                ChangeQuickRedirect changeQuickRedirect3 = QixiLotteryLayout.changeQuickRedirect;
                Class cls = Float.TYPE;
                if (!PatchProxy.proxy(objArr, qixiLotteryLayout, changeQuickRedirect3, false, 202150, new Class[]{View.class, cls, cls, cls, cls}, Void.TYPE).isSupported) {
                    qixiLotteryLayout.setScaleX(0.2f);
                    qixiLotteryLayout.setScaleY(0.2f);
                    float f = (float) 2;
                    qixiLotteryLayout.setPivotX(((float) g.b(qixiLotteryLayout.getContext())[0]) / f);
                    qixiLotteryLayout.setPivotY(((float) g.b(qixiLotteryLayout.getContext())[1]) / f);
                    qixiLotteryLayout.animate().scaleX(1.0f).scaleY(1.0f).setInterpolator(new OvershootInterpolator()).setListener(new t(qixiLotteryLayout)).setDuration(400).start();
                }
            }
        }
    }

    @JvmOverloads
    public QixiLotteryLayout(@NotNull Context context) {
        this(context, null, 0);
    }

    @Override // com.shizhuang.duapp.modules.live.common.base.BaseFrameLayout
    public void d(@Nullable View view) {
        if (!PatchProxy.proxy(new Object[]{view}, this, changeQuickRedirect, false, 202146, new Class[]{View.class}, Void.TYPE).isSupported) {
            super.d(view);
            GradientDrawable gradientDrawable = new GradientDrawable();
            gradientDrawable.setCornerRadius((float) b.b((float) 5));
            gradientDrawable.setColor(getContext().getResources().getColor(R.color.white));
            ((ConstraintLayout) e(R.id.giftContent)).setBackground(gradientDrawable);
            setOnCloseClickListener(new QixiLotteryLayout$initView$1(this));
            setOnClickListener(QixiLotteryLayout$initView$2.b);
        }
    }

    public View e(int i) {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{new Integer(i)}, this, changeQuickRedirect, false, 202157, new Class[]{Integer.TYPE}, View.class);
        if (proxy.isSupported) {
            return (View) proxy.result;
        }
        if (this.f18690h == null) {
            this.f18690h = new HashMap();
        }
        View view = (View) this.f18690h.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View findViewById = findViewById(i);
        this.f18690h.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public void f(@Nullable QixiLotteryResult qixiLotteryResult) {
        if (!PatchProxy.proxy(new Object[]{qixiLotteryResult}, this, changeQuickRedirect, false, 202148, new Class[]{QixiLotteryResult.class}, Void.TYPE).isSupported) {
            this.e = qixiLotteryResult;
            setGiftInfo(qixiLotteryResult);
            h(true);
        }
    }

    public final String g(QixiLotteryResult qixiLotteryResult) {
        boolean z = true;
        int i = 0;
        PatchProxyResult proxy = PatchProxy.proxy(new Object[]{qixiLotteryResult}, this, changeQuickRedirect, false, 202152, new Class[]{QixiLotteryResult.class}, String.class);
        if (proxy.isSupported) {
            return (String) proxy.result;
        }
        List<QixiLotteryResult.GiftInfo> giftAward = qixiLotteryResult.getGiftAward();
        if (giftAward != null && !giftAward.isEmpty()) {
            z = false;
        }
        String str = "";
        if (z) {
            return str;
        }
        for (T t : giftAward) {
            int i3 = i + 1;
            if (i < 0) {
                CollectionsKt__CollectionsKt.throwIndexOverflow();
            }
            StringBuilder i12 = f.i(str, 12300);
            i12.append(t.getName());
            i12.append((char) 12301);
            str = i12.toString();
            i = i3;
        }
        return str;
    }

    @Override // com.shizhuang.duapp.modules.live.common.base.BaseFrameLayout
    public int getLayoutId() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 202143, new Class[0], Integer.TYPE);
        return proxy.isSupported ? ((Integer) proxy.result).intValue() : R.layout.qixi_gift_result_view;
    }

    public final int getLightUpType() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 202144, new Class[0], Integer.TYPE);
        return proxy.isSupported ? ((Integer) proxy.result).intValue() : this.f;
    }

    @Nullable
    public final Consumer<QixiLotteryResult> getOnDismissListener() {
        PatchProxyResult proxy = PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 202155, new Class[0], Consumer.class);
        return proxy.isSupported ? (Consumer) proxy.result : this.f18689g;
    }

    public final void h(boolean z) {
        if (!PatchProxy.proxy(new Object[]{new Byte(z ? (byte) 1 : 0)}, this, changeQuickRedirect, false, 202149, new Class[]{Boolean.TYPE}, Void.TYPE).isSupported) {
            post(new a(this, z));
        }
    }

    @Override // com.shizhuang.duapp.modules.live.common.base.BaseFrameLayout
    public void onAttachedToWindow() {
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 202147, new Class[0], Void.TYPE).isSupported) {
            super.onAttachedToWindow();
            ((DuRequestOptions) mn.a.f35714a.g("https://apk.poizon.com/duApp/Android_Config/live/img/qixi_lottery_bg.png").G(h.f(this)).u(new QixiLotteryLayout$onAttachedToWindow$1(this))).y();
        }
    }

    public final void release() {
        if (!PatchProxy.proxy(new Object[0], this, changeQuickRedirect, false, 202154, new Class[0], Void.TYPE).isSupported) {
            setVisibility(8);
            AdaptiveSizeGroup adaptiveSizeGroup = (AdaptiveSizeGroup) e(R.id.giftIcon);
            if (!PatchProxy.proxy(new Object[0], adaptiveSizeGroup, AdaptiveSizeGroup.changeQuickRedirect, false, 199471, new Class[0], Void.TYPE).isSupported) {
                adaptiveSizeGroup.removeAllViews();
                adaptiveSizeGroup.setVisibility(8);
            }
        }
    }

    /* JADX WARNING: Code restructure failed: missing block: B:11:0x0054, code lost:
        if ((r11.isEmpty()) != false) goto L_0x0056;
     */
    /* JADX WARNING: Removed duplicated region for block: B:31:0x0209  */
    /* JADX WARNING: Removed duplicated region for block: B:33:? A[RETURN, SYNTHETIC] */
    public final void setGiftInfo(@Nullable QixiLotteryResult qixiLotteryResult) {
        QixiReporter qixiReporter;
        int i;
        T t;
        String str;
        if (!PatchProxy.proxy(new Object[]{qixiLotteryResult}, this, changeQuickRedirect, false, 202151, new Class[]{QixiLotteryResult.class}, Void.TYPE).isSupported) {
            Ref.ObjectRef objectRef = new Ref.ObjectRef();
            objectRef.element = "";
            ((ImageView) e(R.id.qixiLotteryBg)).setVisibility(0);
            if (!(qixiLotteryResult == null || (r11 = qixiLotteryResult.getGiftAward()) == null)) {
            }
            if ((qixiLotteryResult != null ? qixiLotteryResult.getGmvAward() : null) == null || qixiLotteryResult.getGmvAward().getAmount() <= 0) {
                ((Group) e(R.id.giftSuccess)).setVisibility(8);
                ((ImageView) e(R.id.giftResultClose)).setVisibility(8);
                ((Group) e(R.id.giftFail)).setVisibility(0);
                ViewExtensionKt.i((TextView) e(R.id.iKnowGiftNone), 1000, new QixiLotteryLayout$setGiftInfo$1(this));
                ((ImageView) e(R.id.qixiLotteryBg)).setVisibility(8);
                ViewExtensionKt.i((ShapeTextView) e(R.id.acceptGift), 1000, new QixiLotteryLayout$setGiftInfo$2(this, objectRef));
                ViewExtensionKt.i((ImageView) e(R.id.giftResultClose), 1000, new QixiLotteryLayout$setGiftInfo$3(this));
                qixiReporter = QixiReporter.f17393a;
                i = this.f;
                t = objectRef.element;
                if (!PatchProxy.proxy(new Object[]{new Integer(i), t}, qixiReporter, QixiReporter.changeQuickRedirect, false, 178449, new Class[]{Integer.TYPE, String.class}, Void.TYPE).isSupported) {
                    mq0.b.b("community_live_activity_exposure", "9", "2913", new QixiReporter$reportDialogExposure$1(i, t));
                    return;
                }
                return;
            }
            if (qixiLotteryResult.getGmvAward() == null || qixiLotteryResult.getGmvAward().getAmount() <= 0) {
                ((Group) e(R.id.giftSuccess)).setVisibility(0);
                ((Group) e(R.id.giftFail)).setVisibility(8);
                ((ImageView) e(R.id.giftResultClose)).setVisibility(0);
                ((TextView) e(R.id.giftDesc)).setText(String.format(getResources().getString(R.string.live_accept_gift), Arrays.copyOf(new Object[]{g(qixiLotteryResult)}, 1)));
                ((TextView) e(R.id.giftDescTips)).setText("可在礼物「背包」里查看");
                ((AdaptiveSizeGroup) e(R.id.giftIcon)).setGiftInfo(qixiLotteryResult.getGiftAward());
                ((AdaptiveSizeGroup) e(R.id.giftIcon)).setVisibility(0);
                ((FrameLayout) e(R.id.fmContainerAllowance)).setVisibility(8);
                objectRef.element = (T) g(qixiLotteryResult);
                ViewExtensionKt.i((ShapeTextView) e(R.id.acceptGift), 1000, new QixiLotteryLayout$setGiftInfo$2(this, objectRef));
                ViewExtensionKt.i((ImageView) e(R.id.giftResultClose), 1000, new QixiLotteryLayout$setGiftInfo$3(this));
                qixiReporter = QixiReporter.f17393a;
                i = this.f;
                t = objectRef.element;
                if (!PatchProxy.proxy(new Object[]{new Integer(i), t}, qixiReporter, QixiReporter.changeQuickRedirect, false, 178449, new Class[]{Integer.TYPE, String.class}, Void.TYPE).isSupported) {
                }
            } else {
                ((Group) e(R.id.giftSuccess)).setVisibility(0);
                ((Group) e(R.id.giftFail)).setVisibility(8);
                ((ImageView) e(R.id.giftResultClose)).setVisibility(0);
                ((TextView) e(R.id.giftDesc)).setText("恭喜你!获得了津贴礼物");
                ((TextView) e(R.id.giftDescTips)).setText("可在 我 - 钱包 - 津贴 里查看");
                ((AdaptiveSizeGroup) e(R.id.giftIcon)).setVisibility(8);
                ((FrameLayout) e(R.id.fmContainerAllowance)).setVisibility(0);
                float amount = ((float) qixiLotteryResult.getGmvAward().getAmount()) / 100.0f;
                if (qixiLotteryResult.getGmvAward().getAmount() % 100 == 0) {
                    str = String.valueOf((int) amount);
                } else {
                    str = new DecimalFormat("#.##").format(Float.valueOf(amount));
                }
                ((FontText) e(R.id.tvAllowanceCouponPrice)).setText(str);
                objectRef.element = (T) ((FontText) e(R.id.tvAllowanceCouponPrice)).getText().toString();
                ViewExtensionKt.i((ShapeTextView) e(R.id.acceptGift), 1000, new QixiLotteryLayout$setGiftInfo$2(this, objectRef));
                ViewExtensionKt.i((ImageView) e(R.id.giftResultClose), 1000, new QixiLotteryLayout$setGiftInfo$3(this));
                qixiReporter = QixiReporter.f17393a;
                i = this.f;
                t = objectRef.element;
                if (!PatchProxy.proxy(new Object[]{new Integer(i), t}, qixiReporter, QixiReporter.changeQuickRedirect, false, 178449, new Class[]{Integer.TYPE, String.class}, Void.TYPE).isSupported) {
                }
            }
        }
    }

    public final void setLightUpType(int i) {
        if (!PatchProxy.proxy(new Object[]{new Integer(i)}, this, changeQuickRedirect, false, 202145, new Class[]{Integer.TYPE}, Void.TYPE).isSupported) {
            this.f = i;
        }
    }

    public final void setOnCloseClickListener(@NotNull View.OnClickListener onClickListener) {
        if (!PatchProxy.proxy(new Object[]{onClickListener}, this, changeQuickRedirect, false, 202153, new Class[]{View.OnClickListener.class}, Void.TYPE).isSupported) {
            ViewExtensionKt.i((ImageView) e(R.id.giftResultClose), 1000, new QixiLotteryLayout$setOnCloseClickListener$1(this, onClickListener));
        }
    }

    public final void setOnDismissListener(@Nullable Consumer<QixiLotteryResult> consumer) {
        if (!PatchProxy.proxy(new Object[]{consumer}, this, changeQuickRedirect, false, 202156, new Class[]{Consumer.class}, Void.TYPE).isSupported) {
            this.f18689g = consumer;
        }
    }

    @JvmOverloads
    public QixiLotteryLayout(@NotNull Context context, @Nullable AttributeSet attributeSet) {
        this(context, attributeSet, 0);
    }

    @JvmOverloads
    public QixiLotteryLayout(@NotNull Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }
}