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

import android.app.Activity;
import android.content.Context;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.model.r;
import com.tencent.mm.plugin.exdevice.f.b.a.c;
import com.tencent.mm.plugin.exdevice.f.b.a.d;
import com.tencent.mm.plugin.exdevice.ui.e.a;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.ui.base.NoMeasuredTextView;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public final class b extends BaseAdapter {
    private String igi = r.Yz();
    List<e> lCD;
    Map<String, String> lCE;
    String lCF;
    d lCG;
    private String lCH;
    private boolean lCI = false;
    private a lCJ = new a();
    private OnClickListener lCK = new 2(this);
    private OnClickListener lCL = new 3(this);
    private OnClickListener lCM = new 4(this);
    private Context mContext;

    static final class b {
        public View gbS;
        public View jOT;
        public ImageView lCP;
        public NoMeasuredTextView lCQ;
        public TextView lCR;
        public TextView lCS;
        public ExdeviceLikeView lCT;
        public View lCU;
        public View lCV;
        public View lCW;
        public TextView lCX;
        public TextView ltX;

        b() {
        }
    }

    public final /* synthetic */ Object getItem(int i) {
        AppMethodBeat.i(20108);
        e uU = uU(i);
        AppMethodBeat.o(20108);
        return uU;
    }

    public b(Context context, String str) {
        AppMethodBeat.i(20097);
        this.mContext = context;
        this.lCH = str;
        AppMethodBeat.o(20097);
    }

    private static void d(LinkedList<c> linkedList, String str) {
        AppMethodBeat.i(20098);
        Iterator it = linkedList.iterator();
        while (it.hasNext()) {
            if (((c) it.next()).field_username.equalsIgnoreCase(str)) {
                ab.d("MicroMsg.ExdeviceRankAdapter", "username: %s remove", new Object[]{((c) it.next()).toString()});
                it.remove();
            }
        }
        AppMethodBeat.o(20098);
    }

    private static boolean e(LinkedList<c> linkedList, String str) {
        AppMethodBeat.i(20099);
        try {
            Iterator it = linkedList.iterator();
            while (it.hasNext()) {
                if (((c) it.next()).field_username.equalsIgnoreCase(str)) {
                    AppMethodBeat.o(20099);
                    return true;
                }
            }
            AppMethodBeat.o(20099);
            return false;
        } catch (Exception e) {
            ab.d("MicroMsg.ExdeviceRankAdapter", e.toString());
            AppMethodBeat.o(20099);
            return false;
        }
    }

    private List<e> a(ArrayList<c> arrayList, ArrayList<d> arrayList2, boolean z) {
        a aVar;
        AppMethodBeat.i(20100);
        LinkedList linkedList = new LinkedList(arrayList);
        ArrayList arrayList3 = new ArrayList();
        d h = h(this.igi, arrayList2);
        if (h != null) {
            a aVar2 = this.lCJ;
            aVar2.lFy = h;
            aVar2.lFz = 3;
            if (h.field_score == 0) {
                ((com.tencent.mm.plugin.sport.a.b) g.K(com.tencent.mm.plugin.sport.a.b.class)).d((Activity) this.mContext, this.igi);
            }
        } else {
            aVar = this.lCJ;
            aVar.lFy = null;
            aVar.lCH = this.lCH;
            aVar.username = this.igi;
            aVar.lFz = 7;
        }
        if (z) {
            this.lCJ.auo = 2;
        } else {
            this.lCJ.auo = 1;
        }
        arrayList3.add(this.lCJ.bqg());
        aVar = this.lCJ;
        aVar.auo = 0;
        arrayList3.add(aVar.bqg());
        d(linkedList, this.igi);
        ArrayList arrayList4 = new ArrayList();
        ab.d("MicroMsg.ExdeviceRankAdapter", "ap: follow size %s, %s", new Object[]{Integer.valueOf(linkedList.size()), linkedList.toString()});
        Iterator it = arrayList2.iterator();
        while (it.hasNext()) {
            h = (d) it.next();
            a aVar3 = this.lCJ;
            aVar3.lFy = h;
            aVar3.auo = 1;
            aVar3.lFz = 4;
            arrayList4.add(aVar3.bqg());
            if (linkedList.size() > 0 && e(linkedList, h.field_username)) {
                aVar3 = this.lCJ;
                aVar3.lFy = h;
                aVar3.auo = 1;
                aVar3.lFz = 2;
                arrayList3.add(aVar3.bqg());
                d(linkedList, h.field_username);
            }
        }
        if (linkedList.size() > 0) {
            it = linkedList.iterator();
            while (it.hasNext()) {
                c cVar = (c) it.next();
                a aVar4 = this.lCJ;
                aVar4.username = cVar.field_username;
                aVar4.lCH = this.lCH;
                aVar4.lFy = null;
                aVar4.auo = 1;
                aVar4.lFz = 6;
                arrayList3.add(aVar4.bqg());
            }
        }
        if (arrayList3.size() > 2) {
            ((e) arrayList3.get(arrayList3.size() - 1)).lFz = (((e) arrayList3.get(arrayList3.size() - 1)).lFz | 2) | 1;
            aVar = this.lCJ;
            aVar.auo = 0;
            aVar.lFy = null;
            arrayList3.add(aVar.bqg());
        }
        if (arrayList4.size() > 1) {
            ((e) arrayList4.get(arrayList4.size() - 1)).lFz = 5;
        }
        arrayList3.addAll(arrayList4);
        ab.d("MicroMsg.ExdeviceRankAdapter", "rank: %d %s", new Object[]{Integer.valueOf(arrayList2.size()), arrayList2.toString()});
        ab.d("MicroMsg.ExdeviceRankAdapter", "all: %s %s", new Object[]{Integer.valueOf(arrayList3.size()), arrayList3.toString()});
        AppMethodBeat.o(20100);
        return arrayList3;
    }

    public final List<e> b(ArrayList<c> arrayList, ArrayList<d> arrayList2, boolean z) {
        ArrayList arrayList3;
        ArrayList arrayList22;
        AppMethodBeat.i(20101);
        if (arrayList3 == null) {
            try {
                arrayList3 = new ArrayList();
            } catch (Exception e) {
                ab.w("MicroMsg.ExdeviceRankAdapter", "ap: rank exception,null info");
                List<e> arrayList4 = new ArrayList();
                AppMethodBeat.o(20101);
                return arrayList4;
            }
        }
        if (arrayList22 == null) {
            arrayList22 = new ArrayList();
        }
        List a = a(arrayList3, arrayList22, z);
        AppMethodBeat.o(20101);
        return a;
    }

    public static d h(String str, ArrayList<d> arrayList) {
        AppMethodBeat.i(20102);
        if (arrayList == null) {
            AppMethodBeat.o(20102);
            return null;
        }
        Iterator it = arrayList.iterator();
        while (it.hasNext()) {
            d dVar = (d) it.next();
            if (str.equalsIgnoreCase(dVar.field_username)) {
                AppMethodBeat.o(20102);
                return dVar;
            }
        }
        AppMethodBeat.o(20102);
        return null;
    }

    public final int getViewTypeCount() {
        return 3;
    }

    public final boolean isEnabled(int i) {
        return false;
    }

    public final int getCount() {
        AppMethodBeat.i(20103);
        if (this.lCD == null) {
            AppMethodBeat.o(20103);
            return 0;
        }
        int size = this.lCD.size();
        AppMethodBeat.o(20103);
        return size;
    }

    public final e uU(int i) {
        AppMethodBeat.i(20104);
        e eVar = (e) this.lCD.get(i);
        AppMethodBeat.o(20104);
        return eVar;
    }

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

    public final int getItemViewType(int i) {
        AppMethodBeat.i(20105);
        int i2 = uU(i).auo;
        AppMethodBeat.o(20105);
        return i2;
    }

    public static void finish() {
        AppMethodBeat.i(20106);
        ((com.tencent.mm.plugin.sport.a.b) g.K(com.tencent.mm.plugin.sport.a.b.class)).cwa();
        AppMethodBeat.o(20106);
    }

    /* JADX WARNING: Removed duplicated region for block: B:79:0x0336  */
    /* JADX WARNING: Removed duplicated region for block: B:62:0x026c  */
    public final android.view.View getView(int r10, android.view.View r11, android.view.ViewGroup r12) {
        /*
        r9 = this;
        r0 = 20107; // 0x4e8b float:2.8176E-41 double:9.934E-320;
        com.tencent.matrix.trace.core.AppMethodBeat.i(r0);
        r0 = 0;
        r1 = r9.uU(r10);
        r2 = r1.lFy;
        r1 = r9.uU(r10);
        r3 = r9.getItemViewType(r10);
        r4 = r1.lFz;
        if (r11 != 0) goto L_0x0156;
    L_0x0018:
        r1 = r9.mContext;
        r1 = android.view.LayoutInflater.from(r1);
        switch(r3) {
            case 0: goto L_0x0110;
            case 1: goto L_0x012c;
            case 2: goto L_0x0146;
            default: goto L_0x0021;
        };
    L_0x0021:
        r1 = r0;
    L_0x0022:
        if (r1 == 0) goto L_0x00cb;
    L_0x0024:
        r0 = 2131821064; // 0x7f110208 float:1.927486E38 double:1.053259551E-314;
        r0 = r11.findViewById(r0);
        r1.gbS = r0;
        r0 = 2131823475; // 0x7f110b73 float:1.927975E38 double:1.053260742E-314;
        r0 = r11.findViewById(r0);
        r1.jOT = r0;
        r0 = 2131823719; // 0x7f110c67 float:1.9280246E38 double:1.0532608625E-314;
        r0 = r11.findViewById(r0);
        r0 = (android.widget.TextView) r0;
        r1.ltX = r0;
        r0 = 2131823720; // 0x7f110c68 float:1.9280248E38 double:1.053260863E-314;
        r0 = r11.findViewById(r0);
        r0 = (android.widget.ImageView) r0;
        r1.lCP = r0;
        r0 = 2131823723; // 0x7f110c6b float:1.9280254E38 double:1.0532608645E-314;
        r0 = r11.findViewById(r0);
        r0 = (com.tencent.mm.ui.base.NoMeasuredTextView) r0;
        r1.lCQ = r0;
        r0 = 2131823673; // 0x7f110c39 float:1.9280152E38 double:1.05326084E-314;
        r0 = r11.findViewById(r0);
        r0 = (android.widget.TextView) r0;
        r1.lCS = r0;
        r0 = 2131823722; // 0x7f110c6a float:1.9280252E38 double:1.053260864E-314;
        r0 = r11.findViewById(r0);
        r0 = (com.tencent.mm.plugin.exdevice.ui.ExdeviceLikeView) r0;
        r1.lCT = r0;
        r0 = 2131823725; // 0x7f110c6d float:1.9280258E38 double:1.0532608655E-314;
        r0 = r11.findViewById(r0);
        r1.lCU = r0;
        r0 = 2131823721; // 0x7f110c69 float:1.928025E38 double:1.0532608635E-314;
        r0 = r11.findViewById(r0);
        r1.lCW = r0;
        r0 = 2131823717; // 0x7f110c65 float:1.9280242E38 double:1.0532608616E-314;
        r0 = r11.findViewById(r0);
        r1.lCV = r0;
        r0 = 2131823726; // 0x7f110c6e float:1.928026E38 double:1.053260866E-314;
        r0 = r11.findViewById(r0);
        r0 = (android.widget.TextView) r0;
        r1.lCX = r0;
        r0 = r1.lCQ;
        if (r0 == 0) goto L_0x00c8;
    L_0x0097:
        r0 = r1.lCQ;
        r5 = 0;
        r6 = r9.mContext;
        r6 = r6.getResources();
        r7 = 2131427632; // 0x7f0b0130 float:1.8476886E38 double:1.0530651696E-314;
        r6 = r6.getDimension(r7);
        r0.setTextSize(r5, r6);
        r0 = r1.lCQ;
        r5 = r9.mContext;
        r5 = r5.getResources();
        r6 = 2131690006; // 0x7f0f0216 float:1.9009043E38 double:1.0531947995E-314;
        r5 = r5.getColor(r6);
        r0.setTextColor(r5);
        r0 = r1.lCQ;
        r5 = 1;
        r0.setSingleLine(r5);
        r0 = r1.lCQ;
        r5 = 1;
        r0.setShouldEllipsize(r5);
    L_0x00c8:
        r11.setTag(r1);
    L_0x00cb:
        if (r2 == 0) goto L_0x010a;
    L_0x00cd:
        if (r1 == 0) goto L_0x010a;
    L_0x00cf:
        r0 = r9.igi;
        r5 = r2.field_username;
        r0 = r0.equalsIgnoreCase(r5);
        if (r0 == 0) goto L_0x0165;
    L_0x00d9:
        r0 = 1;
        r9.lCI = r0;
    L_0x00dc:
        r0 = 2;
        if (r3 != r0) goto L_0x016a;
    L_0x00df:
        r0 = r1.ltX;
        r3 = r2.field_ranknum;
        r3 = java.lang.String.valueOf(r3);
        r0.setText(r3);
        r0 = r1.lCS;
        r3 = r2.field_score;
        r3 = java.lang.String.valueOf(r3);
        r0.setText(r3);
        r0 = r1.lCP;
        r2 = r2.field_username;
        com.tencent.mm.pluginsdk.ui.a.b.r(r0, r2);
        r0 = r1.gbS;
        r2 = r9.lCL;
        r0.setOnClickListener(r2);
        r0 = r1.lCX;
        r1 = r9.lCM;
        r0.setOnClickListener(r1);
    L_0x010a:
        r0 = 20107; // 0x4e8b float:2.8176E-41 double:9.934E-320;
        com.tencent.matrix.trace.core.AppMethodBeat.o(r0);
        return r11;
    L_0x0110:
        r5 = 2130969445; // 0x7f040365 float:1.7547572E38 double:1.052838795E-314;
        r6 = 0;
        r11 = r1.inflate(r5, r12, r6);
        r1 = new com.tencent.mm.plugin.exdevice.ui.b$a;
        r1.<init>();
        r5 = 2131823725; // 0x7f110c6d float:1.9280258E38 double:1.0532608655E-314;
        r5 = r11.findViewById(r5);
        r1.goc = r5;
        r11.setTag(r1);
        r1 = r0;
        goto L_0x0022;
    L_0x012c:
        r0 = 2130969444; // 0x7f040364 float:1.754757E38 double:1.0528387946E-314;
        r5 = 0;
        r11 = r1.inflate(r0, r12, r5);
        r1 = new com.tencent.mm.plugin.exdevice.ui.b$b;
        r1.<init>();
        r0 = 2131823724; // 0x7f110c6c float:1.9280256E38 double:1.053260865E-314;
        r0 = r11.findViewById(r0);
        r0 = (android.widget.TextView) r0;
        r1.lCR = r0;
        goto L_0x0022;
    L_0x0146:
        r0 = 2130969446; // 0x7f040366 float:1.7547574E38 double:1.0528387956E-314;
        r5 = 0;
        r11 = r1.inflate(r0, r12, r5);
        r0 = new com.tencent.mm.plugin.exdevice.ui.b$b;
        r0.<init>();
        r1 = r0;
        goto L_0x0022;
    L_0x0156:
        switch(r3) {
            case 1: goto L_0x015c;
            case 2: goto L_0x015c;
            default: goto L_0x0159;
        };
    L_0x0159:
        r1 = r0;
        goto L_0x00cb;
    L_0x015c:
        r0 = r11.getTag();
        r0 = (com.tencent.mm.plugin.exdevice.ui.b.b) r0;
        r1 = r0;
        goto L_0x00cb;
    L_0x0165:
        r0 = 0;
        r9.lCI = r0;
        goto L_0x00dc;
    L_0x016a:
        r0 = r1.lCR;
        if (r0 == 0) goto L_0x0197;
    L_0x016e:
        r0 = r4 & 4;
        r3 = 4;
        if (r0 == r3) goto L_0x02b0;
    L_0x0173:
        r0 = r1.lCR;
        r3 = 0;
        r0.setVisibility(r3);
        r0 = r1.lCR;
        r3 = r9.mContext;
        r3 = r3.getResources();
        r5 = 2131299367; // 0x7f090c27 float:1.8216733E38 double:1.053001798E-314;
        r6 = 1;
        r6 = new java.lang.Object[r6];
        r7 = 0;
        r8 = r2.field_ranknum;
        r8 = java.lang.Integer.valueOf(r8);
        r6[r7] = r8;
        r3 = r3.getString(r5, r6);
        r0.setText(r3);
    L_0x0197:
        r0 = r4 & 2;
        r3 = 2;
        if (r0 == r3) goto L_0x02b9;
    L_0x019c:
        r0 = r2.field_username;
        r3 = r9.lCF;
        r0 = r0.equalsIgnoreCase(r3);
        if (r0 == 0) goto L_0x02b9;
    L_0x01a6:
        r0 = r9.igi;
        r3 = r9.lCF;
        r0 = r0.equalsIgnoreCase(r3);
        if (r0 != 0) goto L_0x02b9;
    L_0x01b0:
        r0 = r1.jOT;
        r3 = r9.mContext;
        r3 = r3.getResources();
        r5 = 2131690000; // 0x7f0f0210 float:1.9009031E38 double:1.0531947966E-314;
        r3 = r3.getColor(r5);
        r0.setBackgroundColor(r3);
    L_0x01c2:
        r0 = r4 & 1;
        r3 = 1;
        if (r0 != r3) goto L_0x02cd;
    L_0x01c7:
        r0 = r1.lCU;
        r3 = 8;
        r0.setVisibility(r3);
    L_0x01ce:
        r0 = r2.field_ranknum;
        r3 = 100;
        if (r0 < r3) goto L_0x02d5;
    L_0x01d4:
        r0 = r1.ltX;
        r3 = 0;
        r5 = r9.mContext;
        r5 = r5.getResources();
        r6 = 2131427634; // 0x7f0b0132 float:1.847689E38 double:1.0530651706E-314;
        r5 = r5.getDimensionPixelSize(r6);
        r5 = (float) r5;
        r0.setTextSize(r3, r5);
    L_0x01e8:
        r0 = r4 & 2;
        r3 = 2;
        if (r0 != r3) goto L_0x02eb;
    L_0x01ed:
        r0 = r1.ltX;
        r3 = "";
        r0.setText(r3);
    L_0x01f5:
        r0 = r2.field_score;
        r3 = 10000; // 0x2710 float:1.4013E-41 double:4.9407E-320;
        if (r0 < r3) goto L_0x0301;
    L_0x01fb:
        r0 = r1.lCS;
        r3 = r9.mContext;
        r3 = r3.getResources();
        r4 = 2131690005; // 0x7f0f0215 float:1.9009041E38 double:1.053194799E-314;
        r3 = r3.getColor(r4);
        r0.setTextColor(r3);
    L_0x020d:
        r0 = r1.lCS;
        r3 = r2.field_score;
        r3 = java.lang.String.valueOf(r3);
        r0.setText(r3);
        r0 = r1.lCP;
        r3 = r2.field_username;
        com.tencent.mm.pluginsdk.ui.a.b.r(r0, r3);
        r0 = r9.lCI;
        if (r0 != 0) goto L_0x0315;
    L_0x0223:
        com.tencent.mm.model.aw.ZK();
        r0 = com.tencent.mm.model.c.XM();
        r3 = r2.field_username;
        r0 = r0.aoJ(r3);
        if (r0 != 0) goto L_0x0315;
    L_0x0232:
        r0 = r9.lCE;
        if (r0 == 0) goto L_0x0315;
    L_0x0236:
        r0 = r9.lCE;
        r3 = r2.field_username;
        r0 = r0.get(r3);
        r0 = (java.lang.String) r0;
        r0 = com.tencent.mm.sdk.platformtools.bo.isNullOrNil(r0);
        if (r0 != 0) goto L_0x0315;
    L_0x0246:
        r3 = r1.lCQ;
        r4 = r9.mContext;
        r0 = r9.lCE;
        r5 = r2.field_username;
        r0 = r0.get(r5);
        r0 = (java.lang.CharSequence) r0;
        r5 = r1.lCQ;
        r5 = r5.getTextSize();
        r0 = com.tencent.mm.pluginsdk.ui.e.j.b(r4, r0, r5);
        r3.setText(r0);
    L_0x0261:
        r0 = r1.lCT;
        r3 = r2.field_likecount;
        r0.setLikeNum(r3);
        r0 = r9.lCI;
        if (r0 == 0) goto L_0x0336;
    L_0x026c:
        r0 = r2.field_likecount;
        if (r0 == 0) goto L_0x032e;
    L_0x0270:
        r0 = r1.lCT;
        r3 = 1;
        r0.setSelfLikeState(r3);
    L_0x0276:
        r0 = r2.field_score;
        if (r0 > 0) goto L_0x027e;
    L_0x027a:
        r0 = r9.lCI;
        if (r0 == 0) goto L_0x033f;
    L_0x027e:
        r0 = r1.lCT;
        r3 = 1;
        r0.setClickable(r3);
        r0 = r1.lCT;
        r3 = new com.tencent.mm.plugin.exdevice.ui.b$1;
        r3.<init>(r9, r2);
        r0.setOnLikeViewClickListener(r3);
    L_0x028e:
        r0 = r1.lCV;
        r2 = java.lang.Integer.valueOf(r10);
        r0.setTag(r2);
        r0 = r1.lCV;
        r2 = r9.lCK;
        r0.setOnClickListener(r2);
        r0 = r1.lCW;
        r2 = java.lang.Integer.valueOf(r10);
        r0.setTag(r2);
        r0 = r1.lCW;
        r1 = r9.lCK;
        r0.setOnClickListener(r1);
        goto L_0x010a;
    L_0x02b0:
        r0 = r1.lCR;
        r3 = 8;
        r0.setVisibility(r3);
        goto L_0x0197;
    L_0x02b9:
        r0 = r1.jOT;
        r3 = r9.mContext;
        r3 = r3.getResources();
        r5 = 2131689999; // 0x7f0f020f float:1.900903E38 double:1.053194796E-314;
        r3 = r3.getColor(r5);
        r0.setBackgroundColor(r3);
        goto L_0x01c2;
    L_0x02cd:
        r0 = r1.lCU;
        r3 = 0;
        r0.setVisibility(r3);
        goto L_0x01ce;
    L_0x02d5:
        r0 = r1.ltX;
        r3 = 0;
        r5 = r9.mContext;
        r5 = r5.getResources();
        r6 = 2131427633; // 0x7f0b0131 float:1.8476888E38 double:1.05306517E-314;
        r5 = r5.getDimensionPixelSize(r6);
        r5 = (float) r5;
        r0.setTextSize(r3, r5);
        goto L_0x01e8;
    L_0x02eb:
        r0 = r1.ltX;
        r3 = new java.lang.StringBuilder;
        r3.<init>();
        r4 = r2.field_ranknum;
        r3 = r3.append(r4);
        r3 = r3.toString();
        r0.setText(r3);
        goto L_0x01f5;
    L_0x0301:
        r0 = r1.lCS;
        r3 = r9.mContext;
        r3 = r3.getResources();
        r4 = 2131690004; // 0x7f0f0214 float:1.900904E38 double:1.0531947986E-314;
        r3 = r3.getColor(r4);
        r0.setTextColor(r3);
        goto L_0x020d;
    L_0x0315:
        r0 = r1.lCQ;
        r3 = r9.mContext;
        r4 = r2.field_username;
        r4 = com.tencent.mm.model.s.mJ(r4);
        r5 = r1.lCQ;
        r5 = r5.getTextSize();
        r3 = com.tencent.mm.pluginsdk.ui.e.j.b(r3, r4, r5);
        r0.setText(r3);
        goto L_0x0261;
    L_0x032e:
        r0 = r1.lCT;
        r3 = 0;
        r0.setSelfLikeState(r3);
        goto L_0x0276;
    L_0x0336:
        r0 = r1.lCT;
        r3 = r2.field_selfLikeState;
        r0.setSelfLikeState(r3);
        goto L_0x0276;
    L_0x033f:
        r0 = r1.lCT;
        r2 = 0;
        r0.setClickable(r2);
        goto L_0x028e;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.tencent.mm.plugin.exdevice.ui.b.getView(int, android.view.View, android.view.ViewGroup):android.view.View");
    }
}
