package com.ss.android.ugc.aweme.search.topfeed;

import X.1hK;
import X.9HM;
import X.BGU;
import X.C3466SZi;
import X.C3477SZt;
import X.C3488Sa4;
import X.C3493Sa9;
import X.C3706Sda;
import X.C3861Sg5;
import X.CAe;
import X.Cbz;
import X.DZp;
import X.DaP;
import X.LnI;
import X.M12;
import X.MKJ;
import X.OeM;
import X.Okm;
import X.Qeg;
import X.Qen;
import X.Qqv;
import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.powerlist.PowerCell;
import com.ss.android.ugc.aweme.discover.model.suggest.ClickSearchResponse;
import com.ss.android.ugc.aweme.discover.model.suggest.ClickSearchWord;
import java.util.ArrayList;
import java.util.List;
import kotlin.h.b.n;

public final class TopClickSearchHolder extends RecyclerView.ViewHolder {
    public static final Qqv LIZIZ = new Qqv((byte) 0);
    public DZp LIZ;

    static {
        Covode.recordClassIndex(104712);
    }

    public TopClickSearchHolder(View view) {
        super(view);
    }

    public static final class WordCell extends PowerCell<C3488Sa4> {
        public Qeg LIZ;

        static {
            Covode.recordClassIndex(104713);
        }

        public final View LIZ(ViewGroup viewGroup) {
            M12.LIZ(viewGroup);
            Context context = viewGroup.getContext();
            n.LIZIZ(context, "");
            Qeg qeg = new Qeg(context, (AttributeSet) null, 0, 6);
            CAe cAe = CAe.LIZ;
            Context context2 = qeg.getContext();
            n.LIZIZ(context2, "");
            int LIZ2 = Okm.LIZ(context2, 2130968605, 2131099669);
            Resources system = Resources.getSystem();
            n.LIZIZ(system, "");
            qeg.setBackground(cAe.LIZ(LIZ2, TypedValue.applyDimension(1, 2.0f, system.getDisplayMetrics())));
            qeg.setMaxLines(1);
            qeg.setEllipsize(TextUtils.TruncateAt.END);
            Resources system2 = Resources.getSystem();
            n.LIZIZ(system2, "");
            Integer valueOf = Integer.valueOf(LnI.LIZ(TypedValue.applyDimension(1, 8.0f, system2.getDisplayMetrics())));
            Resources system3 = Resources.getSystem();
            n.LIZIZ(system3, "");
            Integer valueOf2 = Integer.valueOf(LnI.LIZ(TypedValue.applyDimension(1, 9.0f, system3.getDisplayMetrics())));
            Resources system4 = Resources.getSystem();
            n.LIZIZ(system4, "");
            Integer valueOf3 = Integer.valueOf(LnI.LIZ(TypedValue.applyDimension(1, 8.0f, system4.getDisplayMetrics())));
            Resources system5 = Resources.getSystem();
            n.LIZIZ(system5, "");
            Qen.LIZ(qeg, valueOf, valueOf2, valueOf3, Integer.valueOf(LnI.LIZ(TypedValue.applyDimension(1, 9.0f, system5.getDisplayMetrics()))), false, 16);
            qeg.setTuxFont(41);
            qeg.setTextColorRes(2130968666);
            this.LIZ = qeg;
            return qeg;
        }

        public final /* synthetic */ void LIZ(DaP daP) {
            C3488Sa4 sa4 = (C3488Sa4) daP;
            M12.LIZ(sa4);
            TopClickSearchHolder.super.LIZ(sa4);
            C3861Sg5 sg5 = sa4.LIZIZ;
            ClickSearchWord clickSearchWord = sa4.LIZ;
            C3706Sda sda = sa4.LIZJ;
            Qeg qeg = this.LIZ;
            if (qeg == null) {
                n.LIZ("");
            }
            String str = clickSearchWord.word;
            StringBuilder sb = str;
            if (str == null) {
                sb = "";
            }
            M12.LIZ(qeg, sb);
            int length = sb.length();
            StringBuilder sb2 = sb;
            if (length > 36) {
                StringBuilder sb3 = new StringBuilder();
                sb3.append(BGU.LIZ(sb, 0, 33));
                sb2 = sb3;
                sb2.append("...");
            }
            qeg.setText(sb2);
            C3466SZi.LIZ(sa4.LIZ, sg5.LIZJ, sg5.LIZIZ, sda);
            Activity LJ = Cbz.LJ(this.itemView);
            if (!(LJ instanceof 1hK)) {
                LJ = null;
            }
            1hK r11 = (1hK) LJ;
            if (r11 != null) {
                Qeg qeg2 = this.LIZ;
                if (qeg2 == null) {
                    n.LIZ("");
                }
                qeg2.setOnClickListener(new C3477SZt(this, clickSearchWord, sg5, sda, sa4, r11));
                if (MKJ.LIZ.LIZ()) {
                    Qeg qeg3 = this.LIZ;
                    if (qeg3 == null) {
                        n.LIZ("");
                    }
                    qeg3.setOnLongClickListener(new C3493Sa9(r11, sa4));
                    return;
                }
                return;
            }
            throw new NullPointerException("Activity not found");
        }
    }

    public /* synthetic */ TopClickSearchHolder(View view, byte b) {
        this(view);
    }

    public final void LIZ(C3861Sg5 sg5, C3706Sda sda) {
        ClickSearchResponse clickSearchResponse;
        List<ClickSearchWord> list;
        M12.LIZ(sg5, sda);
        OeM<ClickSearchResponse> oeM = sg5.LIZLLL;
        if (oeM != null && (clickSearchResponse = (ClickSearchResponse) oeM.LIZIZ) != null && (list = clickSearchResponse.wordsList) != null) {
            ArrayList arrayList = new ArrayList(9HM.LIZ(list, 10));
            for (ClickSearchWord sa4 : list) {
                arrayList.add(new C3488Sa4(sa4, sg5, sda));
            }
            List list2 = arrayList;
            DZp dZp = this.LIZ;
            if (dZp == null) {
                n.LIZ("");
            }
            dZp.getState().LIZ();
            DZp dZp2 = this.LIZ;
            if (dZp2 == null) {
                n.LIZ("");
            }
            dZp2.getState().LIZ(list2);
            C3466SZi.LIZ("click_recom", list.size(), sg5.LIZJ, sg5.LIZIZ, sda);
        }
    }
}
