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

import X.0HH;
import X.C0635AAl;
import X.C0636AAm;
import X.C0637AAn;
import X.C0638AAo;
import X.C0639AAp;
import X.C0640AAq;
import X.C0641AAr;
import X.C0642AAs;
import X.C0643AAt;
import X.C0644AAu;
import X.C0645AAv;
import X.C0646AAw;
import X.C0964ANc;
import X.C0965ANd;
import X.C0966ANe;
import X.C1783Ahn;
import X.C2712Awm;
import X.C4003BcV;
import X.Csa;
import X.Csw;
import X.Csy;
import X.Ct1;
import X.D1G;
import X.DaP;
import X.KEM;
import X.LnI;
import X.M12;
import X.Qeg;
import android.content.Context;
import android.content.res.Resources;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.bytedance.covode.number.Covode;
import com.bytedance.ies.powerlist.PowerCell;
import com.bytedance.ug.sdk.poi.model.PoiItem;
import com.ss.android.ugc.aweme.discover.model.Position;
import com.ss.android.ugc.aweme.search.SearchServiceImpl;
import java.util.List;
import kotlin.h.b.n;

public final class PoiSearchCell extends PowerCell<C1783Ahn> {
    public Qeg LIZ;
    public Qeg LIZIZ;
    public final Csa LJIIIZ;
    public final int LJIIJ;
    public final int LJIIJJI;
    public final int LJIIL;

    static {
        Covode.recordClassIndex(97460);
    }

    public final PoiSearchVM LIZ() {
        return (PoiSearchVM) this.LJIIIZ.getValue();
    }

    public PoiSearchCell() {
        Csa csa;
        Csy csy = Csy.LIZ;
        D1G LIZ2 = KEM.LIZ.LIZ(PoiSearchVM.class);
        C0642AAs aAs = new C0642AAs(LIZ2);
        C0643AAt aAt = C0643AAt.INSTANCE;
        if (n.LIZ(csy, Csw.LIZ)) {
            csa = new Csa(LIZ2, aAs, C0965ANd.INSTANCE, new C0636AAm(this), new C0635AAl(this), C0646AAw.INSTANCE, aAt);
        } else if (n.LIZ(csy, Csy.LIZ)) {
            csa = new Csa(LIZ2, aAs, C0966ANe.INSTANCE, new C0638AAo(this), new C0637AAn(this), C0645AAv.INSTANCE, aAt);
        } else if (csy != null && !n.LIZ(csy, Ct1.LIZ)) {
            throw new IllegalArgumentException("Don't support this VMScope: " + csy + " there");
        } else {
            csa = new Csa(LIZ2, aAs, C0964ANc.INSTANCE, new C0641AAr(this), new C0639AAp(this), new C0640AAq(this), aAt);
        }
        this.LJIIIZ = csa;
        Resources system = Resources.getSystem();
        n.LIZIZ(system, "");
        this.LJIIJ = LnI.LIZ(TypedValue.applyDimension(1, 16.0f, system.getDisplayMetrics()));
        Resources system2 = Resources.getSystem();
        n.LIZIZ(system2, "");
        this.LJIIJJI = LnI.LIZ(TypedValue.applyDimension(1, 12.0f, system2.getDisplayMetrics()));
        Resources system3 = Resources.getSystem();
        n.LIZIZ(system3, "");
        this.LJIIL = LnI.LIZ(TypedValue.applyDimension(1, 20.0f, system3.getDisplayMetrics()));
    }

    public final View LIZ(ViewGroup viewGroup) {
        int i;
        M12.LIZ(viewGroup);
        LayoutInflater from = LayoutInflater.from(viewGroup.getContext());
        if (C0644AAu.LIZ.LIZ() == 0) {
            i = 2131560718;
        } else {
            i = 2131560719;
        }
        View LIZ2 = 0HH.LIZ(from, i, viewGroup, false);
        Qeg findViewById = LIZ2.findViewById(2131372216);
        n.LIZIZ(findViewById, "");
        this.LIZ = findViewById;
        Qeg findViewById2 = LIZ2.findViewById(2131372215);
        n.LIZIZ(findViewById2, "");
        this.LIZIZ = findViewById2;
        LIZ2.setOnClickListener(new C2712Awm(LIZ2, this));
        n.LIZIZ(LIZ2, "");
        return LIZ2;
    }

    public final /* synthetic */ void LIZ(DaP daP) {
        String str;
        String str2;
        Integer num;
        boolean z;
        C1783Ahn ahn = (C1783Ahn) daP;
        M12.LIZ(ahn);
        PoiSearchCell.super.LIZ(ahn);
        PoiItem poiItem = ahn.LIZ;
        if (poiItem == null || (str2 = poiItem.LIZIZ) == null) {
            Qeg qeg = this.LIZ;
            if (qeg == null) {
                n.LIZ("");
            }
            qeg.setVisibility(4);
        } else {
            List<C1783Ahn> listItemState = LIZ().getState().getListItemState();
            if (listItemState != null) {
                num = Integer.valueOf(listItemState.indexOf(ahn));
            } else {
                num = null;
            }
            List<Position> list = ahn.LIZIZ;
            if (list == null || list.isEmpty()) {
                z = true;
            } else {
                z = false;
            }
            if (z) {
                if (C0644AAu.LIZ.LIZ() == 1) {
                    String str3 = LIZ().getState().LIZJ;
                    if (str3 == null || str3.length() == 0) {
                        Qeg qeg2 = this.LIZ;
                        if (qeg2 == null) {
                            n.LIZ("");
                        }
                        qeg2.setTuxFont(42);
                    } else {
                        Qeg qeg3 = this.LIZ;
                        if (qeg3 == null) {
                            n.LIZ("");
                        }
                        qeg3.setTuxFont(41);
                    }
                }
                Qeg qeg4 = this.LIZ;
                if (qeg4 == null) {
                    n.LIZ("");
                }
                qeg4.setText(str2);
            } else {
                if (C0644AAu.LIZ.LIZ() == 1) {
                    Qeg qeg5 = this.LIZ;
                    if (qeg5 == null) {
                        n.LIZ("");
                    }
                    qeg5.setTuxFont(41);
                }
                Qeg qeg6 = this.LIZ;
                if (qeg6 == null) {
                    n.LIZ("");
                }
                C4003BcV LJI = SearchServiceImpl.LJJIIZ().LJI();
                Qeg qeg7 = this.LIZ;
                if (qeg7 == null) {
                    n.LIZ("");
                }
                Context context = qeg7.getContext();
                n.LIZIZ(context, "");
                qeg6.setText(LJI.LIZ(context, str2, (List<? extends Position>) ahn.LIZIZ));
            }
            if (C0644AAu.LIZ.LIZ() == 1) {
                if (num != null && num.intValue() == 0) {
                    View view = this.itemView;
                    int i = this.LJIIJ;
                    view.setPadding(i, this.LJIIL, i, this.LJIIJJI);
                } else {
                    View view2 = this.itemView;
                    int i2 = this.LJIIJ;
                    int i3 = this.LJIIJJI;
                    view2.setPadding(i2, i3, i2, i3);
                }
            }
            Qeg qeg8 = this.LIZ;
            if (qeg8 == null) {
                n.LIZ("");
            }
            qeg8.setVisibility(0);
        }
        PoiItem poiItem2 = ahn.LIZ;
        if (poiItem2 == null || (str = poiItem2.LJFF) == null) {
            Qeg qeg9 = this.LIZIZ;
            if (qeg9 == null) {
                n.LIZ("");
            }
            qeg9.setVisibility(8);
        } else if (n.LIZ(str, ahn.LIZ.LIZIZ) || str.length() == 0) {
            Qeg qeg10 = this.LIZIZ;
            if (qeg10 == null) {
                n.LIZ("");
            }
            qeg10.setVisibility(8);
        } else {
            Qeg qeg11 = this.LIZIZ;
            if (qeg11 == null) {
                n.LIZ("");
            }
            qeg11.setText(str);
            Qeg qeg12 = this.LIZIZ;
            if (qeg12 == null) {
                n.LIZ("");
            }
            qeg12.setVisibility(0);
        }
    }
}
