package com.tencent.mm.plugin.sns.ui;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.TextView.BufferType;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.plugin.messenger.foundation.a.j;
import com.tencent.mm.plugin.sns.model.ap;
import com.tencent.mm.plugin.sns.storage.h;
import com.tencent.mm.plugin.sns.storage.n;
import com.tencent.mm.plugin.sns.ui.widget.SnsAvatarImageView;
import com.tencent.mm.plugin.sns.ui.widget.d;
import com.tencent.mm.pluginsdk.ui.a.b;
import com.tencent.mm.pluginsdk.ui.e.k;
import com.tencent.mm.pluginsdk.ui.e.o;
import com.tencent.mm.protocal.protobuf.cat;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.storage.ad;
import com.tencent.mm.ui.v;
import java.util.LinkedList;

class SnsCommentDetailUI$b extends BaseAdapter {
    Activity activity;
    String cwT;
    final /* synthetic */ SnsCommentDetailUI rqN;
    public LinkedList<cat> rrj;
    LinkedList<cat> rrk;

    public SnsCommentDetailUI$b(SnsCommentDetailUI snsCommentDetailUI, LinkedList<cat> linkedList, LinkedList<cat> linkedList2, Activity activity, String str) {
        this.rqN = snsCommentDetailUI;
        this.rrj = linkedList;
        this.rrk = linkedList2;
        this.activity = activity;
        this.cwT = str;
    }

    public final int getCount() {
        int i = 0;
        AppMethodBeat.i(38831);
        if (this.rrk.size() > 0) {
            if (this.rrj != null) {
                i = this.rrj.size();
            }
            i++;
            AppMethodBeat.o(38831);
            return i;
        } else if (this.rrj == null) {
            AppMethodBeat.o(38831);
            return 0;
        } else {
            i = this.rrj.size();
            AppMethodBeat.o(38831);
            return i;
        }
    }

    public final Object getItem(int i) {
        return null;
    }

    public final long getItemId(int i) {
        return 0;
    }

    public final View getView(int i, View view, ViewGroup viewGroup) {
        a aVar;
        CharSequence Oj;
        AppMethodBeat.i(38832);
        if (this.rrk.size() > 0) {
            if (i == 0) {
                LinearLayout H = SnsCommentDetailUI.H(this.rqN);
                AppMethodBeat.o(38832);
                return H;
            }
            i--;
        }
        cat cat = (cat) this.rrj.get(i);
        if (view == null || !(view.getTag() instanceof a)) {
            view = v.hu(this.activity).inflate(2130970754, null);
            view.setOnTouchListener(SnsCommentDetailUI.I(this.rqN));
            a aVar2 = new a(this);
            aVar2.ejo = (ImageView) view.findViewById(2131827731);
            aVar2.ejo.setOnClickListener(SnsCommentDetailUI.J(this.rqN));
            aVar2.pnE = (TextView) view.findViewById(2131827733);
            aVar2.pnE.setOnTouchListener(new aa());
            aVar2.pnE.setOnClickListener(new 2(this));
            aVar2.timeTv = (TextView) view.findViewById(2131827732);
            aVar2.gKl = (TextView) view.findViewById(2131827734);
            aVar2.gKl.setOnTouchListener(new aa());
            aVar2.rrm = (SnsTranslateResultView) view.findViewById(2131827715);
            aVar2.rrm.setVisibility(8);
            if (SnsCommentDetailUI.C(this.rqN) == 10) {
                view.findViewById(2131827728).setBackgroundResource(2130838855);
                aVar = aVar2;
            } else {
                aVar = aVar2;
            }
        } else {
            aVar = (a) view.getTag();
        }
        aVar.rrn = cat;
        aVar.userName = cat.vHl;
        ((SnsAvatarImageView) aVar.ejo).dk(cat.vHl, 3);
        ((SnsAvatarImageView) aVar.ejo).setWeakContext(this.activity);
        int i2 = SnsCommentDetailUI.C(this.rqN) == 10 ? 3 : 2;
        SnsCommentDetailUI.C(this.rqN);
        g.RQ();
        ad aoM = ((j) g.K(j.class)).XM().aoM(aVar.userName);
        if (i == 0 && this.rrk.isEmpty()) {
            if (SnsCommentDetailUI.C(this.rqN) == 10) {
                view.setBackgroundResource(2130838856);
            } else {
                view.setBackgroundResource(2130840260);
            }
        } else if (SnsCommentDetailUI.C(this.rqN) == 10) {
            view.setBackgroundResource(2130840265);
        } else {
            view.setBackgroundResource(2130840264);
        }
        if (i == 0) {
            view.findViewById(2131827730).setVisibility(0);
            view.findViewById(2131827729).setVisibility(8);
            if (SnsCommentDetailUI.C(this.rqN) == 10) {
                ((ImageView) view.findViewById(2131827730)).setImageResource(2131231333);
            }
        } else {
            view.findViewById(2131827730).setVisibility(4);
            view.findViewById(2131827729).setVisibility(0);
        }
        b.t(aVar.ejo, cat.vHl);
        aVar.ejo.setTag(cat.vHl);
        if (aoM != null) {
            Oj = aoM.Oj();
        } else {
            Object Oj2 = cat.wCW != null ? cat.wCW : cat.vHl;
        }
        n YS = h.YS(SnsCommentDetailUI.o(this.rqN));
        if (YS != null) {
            aVar.gKl.setText(cat.ncM + " ");
            CharSequence a = d.a(this.rqN, cat, SnsCommentDetailUI.K(this.rqN), YS.field_type, YS.field_userName, 2);
            aVar.pnE.setText(Oj2, BufferType.SPANNABLE);
            com.tencent.mm.pluginsdk.ui.e.j.h(aVar.pnE, i2);
            k kVar = new k(aVar.pnE.getText());
            ab.i("MicroMsg.SnsCommentDetailUI", "test %s,%s", new Object[]{cat.vHl, Oj2});
            kVar.a(new o(cat.vHl, SnsCommentDetailUI.K(this.rqN), i2), Oj2, 0);
            aVar.pnE.setText(kVar, BufferType.SPANNABLE);
            aVar.timeTv.setText(aw.m(this.activity, ((long) cat.pcX) * 1000));
            aVar.gKl.setText(a, BufferType.SPANNABLE);
            aVar.gKl.setVisibility(0);
            SnsCommentDetailUI.L(this.rqN).c(view, SnsCommentDetailUI.B(this.rqN).rJU, SnsCommentDetailUI.B(this.rqN).rJH);
            SnsCommentDetailUI.L(this.rqN).c(aVar.gKl, SnsCommentDetailUI.B(this.rqN).rJU, SnsCommentDetailUI.B(this.rqN).rJH);
            String ga = ap.ga(SnsCommentDetailUI.o(this.rqN), String.valueOf(cat.wZG != 0 ? (long) cat.wZG : cat.wZJ));
            if (ap.db(ga, 4) && aVar.rrm != null) {
                ap.b Ye = ap.Ye(ga);
                if (Ye != null) {
                    aVar.rrm.setVisibility(0);
                    if (!Ye.foa) {
                        aVar.rrm.El(2);
                    } else if (Ye.aAR) {
                        aVar.rrm.setVisibility(8);
                    } else {
                        aVar.rrm.a(Ye, 2, Ye.result, Ye.fwM, Ye.qMV);
                    }
                } else {
                    aVar.rrm.setVisibility(8);
                }
            }
            view.setClickable(true);
            ab.d("MicroMsg.SnsCommentDetailUI", "position " + cat.vHl + " self " + SnsCommentDetailUI.M(this.rqN) + " commentid " + cat.wZG + " snsid " + SnsCommentDetailUI.o(this.rqN));
            if (SnsCommentDetailUI.M(this.rqN).equals(cat.vHl)) {
                aVar.info = cat;
            } else {
                aVar.info = new Object[]{Integer.valueOf(i), cat, cat.vHl, Oj2};
            }
            l lVar = new l(SnsCommentDetailUI.k(this.rqN), SnsCommentDetailUI.o(this.rqN), cat, cat.vHl, cat.ncM, aVar.gKl, 2);
            lVar.tag = aVar;
            view.setTag(lVar);
            aVar.gKl.setTag(lVar);
            view.setOnClickListener(SnsCommentDetailUI.N(this.rqN));
            aVar.gKl.setOnClickListener(SnsCommentDetailUI.N(this.rqN));
        }
        AppMethodBeat.o(38832);
        return view;
    }
}
