package com.bytedance.android.livesdk.guide;

import X.0HH;
import X.0Ul;
import X.0b0;
import X.0bc;
import X.1jk;
import X.C3028Glh;
import X.C3491GtA;
import X.C3899Gzk;
import X.C4100H7d;
import X.C4201HBa;
import X.C4208HBh;
import X.C4209HBi;
import X.C4210HBj;
import X.C4212HBl;
import X.C4213HBm;
import X.C4215HBo;
import X.CZn;
import X.HBZ;
import X.M12;
import X.Mjy;
import X.Mk2;
import X.Mk3;
import X.PgU;
import X.PhE;
import X.PlI;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.text.SpannableStringBuilder;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.fragment.app.Fragment;
import com.bytedance.android.live.base.model.ImageModel;
import com.bytedance.android.live.base.model.user.User;
import com.bytedance.android.livesdk.livesetting.gift.LiveGuideDialogDurationSetting;
import com.bytedance.android.livesdk.model.Gift;
import com.bytedance.android.livesdk.model.message.common.Text;
import com.bytedance.android.livesdk.service.assets.GiftManager;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.sdk.datachannel.DataChannel;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import kotlin.h.b.n;
import kotlin.o.z;

public final class LiveGiftGuideDialog extends Fragment {
    public long LIZ;
    public Text LIZIZ;
    public DataChannel LIZJ;
    public C4213HBm LIZLLL;
    public View LJ;
    public View LJFF;
    public ImageView LJI;
    public 1jk LJII;
    public 1jk LJIIIIZZ;
    public final Mjy LJIIIZ = new Mjy();
    public String LJIIJ = "";
    public String LJIIJJI = "";
    public HashMap LJIIL;

    static {
        Covode.recordClassIndex(16547);
    }

    private View LIZ(int i) {
        if (this.LJIIL == null) {
            this.LJIIL = new HashMap();
        }
        View view = (View) this.LJIIL.get(Integer.valueOf(i));
        if (view != null) {
            return view;
        }
        View view2 = getView();
        if (view2 == null) {
            return null;
        }
        View findViewById = view2.findViewById(i);
        this.LJIIL.put(Integer.valueOf(i), findViewById);
        return findViewById;
    }

    public final /* synthetic */ void onDestroyView() {
        LiveGiftGuideDialog.super.onDestroyView();
        HashMap hashMap = this.LJIIL;
        if (hashMap != null) {
            hashMap.clear();
        }
    }

    public final void onDetach() {
        LiveGiftGuideDialog.super.onDetach();
        this.LJIIIZ.LIZ();
    }

    public final void onViewCreated(View view, Bundle bundle) {
        ImageModel imageModel;
        User user;
        Resources resources;
        Drawable drawable;
        M12.LIZ(view);
        LiveGiftGuideDialog.super.onViewCreated(view, bundle);
        view.findViewById(2131364125).setOnClickListener(new C4210HBj(this));
        view.findViewById(2131373115).setOnClickListener(C4201HBa.LIZ);
        View findViewById = view.findViewById(2131363848);
        this.LJ = findViewById;
        if (findViewById != null) {
            findViewById.setOnClickListener(new C4212HBl(this));
        }
        this.LJFF = view.findViewById(2131370090);
        ((LinearLayout) LIZ(2131370091)).setOnClickListener(new C4208HBh(this));
        this.LJI = (ImageView) view.findViewById(2131365318);
        this.LJII = view.findViewById(2131372671);
        this.LJIIIIZZ = view.findViewById(2131364035);
        Gift findGiftById = GiftManager.inst().findGiftById(this.LIZ);
        ImageView imageView = this.LJI;
        CZn cZn = null;
        if (findGiftById != null) {
            imageModel = findGiftById.LIZIZ;
        } else {
            imageModel = null;
        }
        0bc.LIZIZ(imageView, imageModel);
        C3028Glh LIZIZ2 = C4100H7d.LIZ().LIZIZ();
        if (LIZIZ2 != null) {
            user = LIZIZ2.LIZIZ();
        } else {
            user = null;
        }
        String LIZ2 = 0b0.LIZ(2131828914, new Object[]{0Ul.LIZ(user)});
        1jk r0 = this.LJII;
        if (r0 != null) {
            r0.setText(LIZ2);
        }
        CharSequence LIZ3 = C3899Gzk.LIZ.LIZ(this.LIZIZ);
        1jk r1 = this.LJIIIIZZ;
        if (r1 != null) {
            r1.setText(LIZ3.toString());
        }
        this.LJIIIZ.LIZ(PgU.LIZIZ((long) LiveGuideDialogDurationSetting.INSTANCE.getValue(), TimeUnit.SECONDS).LIZIZ(PhE.LIZIZ(PlI.LIZJ)).LIZ(Mk2.LIZ(Mk3.LIZ)).LIZ(new C4209HBi(this), HBZ.LIZ));
        if (findGiftById != null) {
            SpannableStringBuilder spannableStringBuilder = new SpannableStringBuilder();
            Context context = getContext();
            if (!(context == null || (resources = context.getResources()) == null || (drawable = resources.getDrawable(2131234914)) == null)) {
                drawable.setBounds(0, 0, 0b0.LIZ(11.0f), 0b0.LIZ(11.0f));
                cZn = new CZn(drawable);
            }
            if (0b0.LJI()) {
                spannableStringBuilder.append("(");
                spannableStringBuilder.append(String.valueOf(findGiftById.LJFF));
                spannableStringBuilder.append(".");
                spannableStringBuilder.append(")");
            } else {
                spannableStringBuilder.append("(");
                spannableStringBuilder.append(".");
                spannableStringBuilder.append(String.valueOf(findGiftById.LJFF));
                spannableStringBuilder.append(")");
            }
            int LIZ4 = z.LIZ(spannableStringBuilder, ".", 0, false, 6);
            spannableStringBuilder.setSpan(cZn, LIZ4, LIZ4 + 1, 33);
            1jk LIZ5 = LIZ(2131370092);
            n.LIZIZ(LIZ5, "");
            LIZ5.setText(spannableStringBuilder);
        }
        long j = this.LIZ;
        C3491GtA LIZ6 = C3491GtA.LJFF.LIZ("gift_guide_popup_show");
        LIZ6.LIZ();
        LIZ6.LIZ("gift_id", j);
        LIZ6.LIZ("notification_type", C4215HBo.LIZJ);
        LIZ6.LIZ("notification_request_id", C4215HBo.LIZIZ);
        LIZ6.LIZLLL();
    }

    public final View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        M12.LIZ(layoutInflater);
        return 0HH.LIZ(layoutInflater, 2131561594, viewGroup, false);
    }
}
