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

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.model.aw;
import com.tencent.mm.model.s;
import com.tencent.mm.plugin.exdevice.f.a.e;
import com.tencent.mm.plugin.exdevice.f.b.a.c;
import com.tencent.mm.pluginsdk.ui.e.j;
import com.tencent.mm.protocal.protobuf.mq;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.ui.base.NoMeasuredTextView;
import java.util.ArrayList;
import java.util.List;

final class a extends BaseAdapter {
    String igi;
    c lBs;
    private boolean lBt;
    boolean lBu;
    int lBv;
    int lBw;
    ArrayList<c> lBx;
    List<mq> lBy;
    private View lBz;
    private String mAppName;
    private Context mContext;

    class b {
        TextView jao;
        View lBC;

        b() {
        }
    }

    public a(Context context, String str, boolean z, String str2) {
        this.mContext = context;
        this.igi = str2;
        this.lBt = z;
        this.mAppName = str;
    }

    public final int getCount() {
        if (this.lBt) {
            return (this.lBv + 5) + this.lBw;
        }
        return 2;
    }

    public final int getViewTypeCount() {
        return 8;
    }

    public final Object getItem(int i) {
        AppMethodBeat.i(20007);
        Integer valueOf = Integer.valueOf(i);
        AppMethodBeat.o(20007);
        return valueOf;
    }

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

    public final int getItemViewType(int i) {
        if (this.lBt) {
            if (i == 0) {
                return 0;
            }
            if (i == 1) {
                return 6;
            }
            if (i > 1 && i <= this.lBv + 1) {
                return 1;
            }
            if (i == this.lBv + 2) {
                return 2;
            }
            if (i == this.lBv + 3) {
                return 5;
            }
            if (i <= this.lBv + 3 || i > (this.lBv + 3) + this.lBw) {
                return i == (this.lBv + this.lBw) + 4 ? 7 : 5;
            } else {
                return 3;
            }
        } else if (i == 0) {
            return 0;
        } else {
            return 4;
        }
    }

    public final View getView(int i, View view, ViewGroup viewGroup) {
        b bVar;
        b bVar2;
        c cVar;
        a aVar;
        d dVar;
        e eVar;
        f fVar;
        AppMethodBeat.i(20008);
        int itemViewType = getItemViewType(i);
        if (view != null) {
            switch (itemViewType) {
                case 0:
                    bVar = null;
                    bVar2 = null;
                    cVar = null;
                    aVar = null;
                    dVar = null;
                    eVar = null;
                    fVar = (f) view.getTag();
                    break;
                case 1:
                    bVar = null;
                    bVar2 = null;
                    cVar = null;
                    aVar = null;
                    dVar = null;
                    eVar = (e) view.getTag();
                    fVar = null;
                    break;
                case 2:
                    bVar = null;
                    bVar2 = null;
                    cVar = null;
                    aVar = (a) view.getTag();
                    dVar = null;
                    eVar = null;
                    fVar = null;
                    break;
                case 3:
                    bVar = null;
                    bVar2 = null;
                    cVar = (c) view.getTag();
                    aVar = null;
                    dVar = null;
                    eVar = null;
                    fVar = null;
                    break;
                case 4:
                    bVar = null;
                    bVar2 = null;
                    cVar = null;
                    aVar = null;
                    dVar = (d) view.getTag();
                    eVar = null;
                    fVar = null;
                    break;
                case 5:
                    view.getTag();
                    bVar = null;
                    bVar2 = null;
                    cVar = null;
                    aVar = null;
                    dVar = null;
                    eVar = null;
                    fVar = null;
                    break;
                case 6:
                    bVar = null;
                    bVar2 = (b) view.getTag();
                    cVar = null;
                    aVar = null;
                    dVar = null;
                    eVar = null;
                    fVar = null;
                    break;
                case 7:
                    bVar = (b) view.getTag();
                    bVar2 = null;
                    cVar = null;
                    aVar = null;
                    dVar = null;
                    eVar = null;
                    fVar = null;
                    break;
                default:
                    bVar = null;
                    bVar2 = null;
                    cVar = null;
                    aVar = null;
                    dVar = null;
                    eVar = null;
                    fVar = null;
                    break;
            }
        }
        switch (itemViewType) {
            case 0:
                if (this.lBz == null) {
                    this.lBz = LayoutInflater.from(this.mContext).inflate(2130969432, viewGroup, false);
                }
                view = this.lBz;
                fVar = new f(this);
                fVar.kEn = (ImageView) view.findViewById(2131823698);
                view.setTag(fVar);
                bVar = null;
                bVar2 = null;
                cVar = null;
                aVar = null;
                dVar = null;
                eVar = null;
                break;
            case 1:
                view = LayoutInflater.from(this.mContext).inflate(2130969431, viewGroup, false);
                eVar = new e(this);
                eVar.lBF = (NoMeasuredTextView) view.findViewById(2131823689);
                eVar.lBG = (TextView) view.findViewById(2131823690);
                eVar.kEn = (ImageView) view.findViewById(2131823686);
                eVar.lBB = view.findViewById(2131823685);
                eVar.lBF.setTextSize(0, this.mContext.getResources().getDimension(2131427632));
                eVar.lBF.setTextColor(this.mContext.getResources().getColor(2131690006));
                eVar.lBF.setSingleLine(true);
                eVar.lBF.setShouldEllipsize(true);
                view.setTag(eVar);
                bVar = null;
                bVar2 = null;
                cVar = null;
                aVar = null;
                dVar = null;
                fVar = null;
                break;
            case 2:
                view = LayoutInflater.from(this.mContext).inflate(2130969427, viewGroup, false);
                aVar = new a(this);
                aVar.jao = (TextView) view.findViewById(2131823672);
                aVar.lBB = view.findViewById(2131823668);
                aVar.lyB = (ImageView) view.findViewById(2131823669);
                view.setTag(aVar);
                bVar = null;
                bVar2 = null;
                cVar = null;
                dVar = null;
                eVar = null;
                fVar = null;
                break;
            case 3:
                view = LayoutInflater.from(this.mContext).inflate(2130969427, viewGroup, false);
                cVar = new c(this);
                cVar.jao = (TextView) view.findViewById(2131823672);
                cVar.lBB = view.findViewById(2131823668);
                cVar.lyB = (ImageView) view.findViewById(2131823669);
                cVar.lBD = view.findViewById(2131823674);
                view.setTag(cVar);
                bVar = null;
                bVar2 = null;
                aVar = null;
                dVar = null;
                eVar = null;
                fVar = null;
                break;
            case 4:
                view = LayoutInflater.from(this.mContext).inflate(2130969430, viewGroup, false);
                dVar = new d(this);
                dVar.lBE = (Button) view.findViewById(2131823683);
                view.setTag(dVar);
                bVar = null;
                bVar2 = null;
                cVar = null;
                aVar = null;
                eVar = null;
                fVar = null;
                break;
            case 5:
                view = LayoutInflater.from(this.mContext).inflate(2130969429, viewGroup, false);
                view.setTag(new b());
                bVar = null;
                bVar2 = null;
                cVar = null;
                aVar = null;
                dVar = null;
                eVar = null;
                fVar = null;
                break;
            case 6:
                view = LayoutInflater.from(this.mContext).inflate(2130969429, viewGroup, false);
                bVar2 = new b();
                bVar2.jao = (TextView) view.findViewById(2131823680);
                view.setTag(bVar2);
                bVar = null;
                cVar = null;
                aVar = null;
                dVar = null;
                eVar = null;
                fVar = null;
                break;
            case 7:
                view = LayoutInflater.from(this.mContext).inflate(2130969429, viewGroup, false);
                b bVar3 = new b();
                bVar3.lBC = view.findViewById(2131823678);
                view.setTag(bVar3);
                bVar = bVar3;
                bVar2 = null;
                cVar = null;
                aVar = null;
                dVar = null;
                eVar = null;
                fVar = null;
                break;
            default:
                bVar = null;
                bVar2 = null;
                cVar = null;
                aVar = null;
                dVar = null;
                eVar = null;
                fVar = null;
                break;
        }
        switch (itemViewType) {
            case 0:
                com.tencent.mm.pluginsdk.ui.a.b.s(fVar.kEn, this.igi);
                fVar.kEn.setOnClickListener(new 1(this));
                break;
            case 1:
                if (i - 2 >= 0 && !bo.ek(this.lBx)) {
                    c cVar2 = (c) this.lBx.get(i - 2);
                    if (cVar2 != null) {
                        int i2 = cVar2.field_step;
                        String str = cVar2.field_username;
                        if (cVar2.field_step >= 10000) {
                            eVar.lBG.setTextColor(this.mContext.getResources().getColor(2131690005));
                        } else {
                            eVar.lBG.setTextColor(this.mContext.getResources().getColor(2131690004));
                        }
                        eVar.lBF.setText(j.b(this.mContext, s.mJ(str), eVar.lBF.getTextSize()));
                        eVar.lBG.setText(String.valueOf(i2));
                        com.tencent.mm.pluginsdk.ui.a.b.r(eVar.kEn, str);
                        eVar.lBB.setOnClickListener(new 2(this, str));
                        break;
                    }
                }
                break;
            case 2:
                aVar.jao.setText(this.mContext.getResources().getText(2131299349));
                aVar.lyB.setImageResource(2131231210);
                aVar.lBB.setOnClickListener(new 3(this));
                break;
            case 3:
                if ((i - this.lBv) - 4 >= 0 && !bo.ek(this.lBy)) {
                    mq mqVar = (mq) this.lBy.get((i - this.lBv) - 4);
                    if (mqVar != null) {
                        String str2 = mqVar.title;
                        String str3 = mqVar.cIY;
                        cVar.jao.setText(str2);
                        if ((i - this.lBv) - 4 != this.lBw - 1) {
                            cVar.lBD.setVisibility(0);
                        }
                        e.a(this.mContext, cVar.lyB, str3);
                        cVar.lBB.setOnClickListener(new 4(this));
                        break;
                    }
                }
                break;
            case 4:
                if (!this.lBu) {
                    aw.ZK();
                    if (com.tencent.mm.model.c.XM().aoJ(this.igi)) {
                        dVar.lBE.setVisibility(0);
                        dVar.lBE.setOnClickListener(new 5(this));
                        break;
                    }
                }
                dVar.lBE.setVisibility(4);
                break;
            case 6:
                bVar2.jao.setText(this.mContext.getString(2131299358));
                break;
            case 7:
                bVar.lBC.setVisibility(0);
                break;
        }
        AppMethodBeat.o(20008);
        return view;
    }
}
