package com.tencent.mm.chatroom.ui;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.at.a.a.c;
import com.tencent.mm.chatroom.ui.SeeRoomManagerUI.a;
import com.tencent.mm.kernel.g;
import com.tencent.mm.model.r;
import com.tencent.mm.plugin.messenger.foundation.a.j;
import com.tencent.mm.pluginsdk.ui.a.b;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.bo;
import com.tencent.mm.storage.ad;
import com.tencent.mm.storage.bv;
import java.util.ArrayList;
import java.util.List;

public class SeeRoomManagerUI$b extends BaseAdapter {
    List<a> dataList = new ArrayList();
    private c elH;
    final /* synthetic */ SeeRoomManagerUI elM;
    Context mContext;

    public final /* synthetic */ Object getItem(int i) {
        AppMethodBeat.i(104295);
        a iF = iF(i);
        AppMethodBeat.o(104295);
        return iF;
    }

    public SeeRoomManagerUI$b(SeeRoomManagerUI seeRoomManagerUI, Context context) {
        this.elM = seeRoomManagerUI;
        AppMethodBeat.i(104289);
        this.mContext = context;
        Km();
        notifyDataSetChanged();
        c.a aVar = new c.a();
        aVar.ePH = true;
        aVar.ePZ = true;
        aVar.ePT = 2131231172;
        this.elH = aVar.ahG();
        AppMethodBeat.o(104289);
    }

    public final void notifyDataSetChanged() {
        AppMethodBeat.i(104290);
        super.notifyDataSetChanged();
        SeeRoomManagerUI.b(this.elM).post(new 1(this));
        AppMethodBeat.o(104290);
    }

    private void Km() {
        AppMethodBeat.i(104291);
        this.dataList.clear();
        SeeRoomManagerUI.a(this.elM, ((com.tencent.mm.plugin.chatroom.a.c) g.K(com.tencent.mm.plugin.chatroom.a.c.class)).XV().oa(bo.nullAsNil(SeeRoomManagerUI.c(this.elM))));
        if (SeeRoomManagerUI.d(this.elM) == null) {
            AppMethodBeat.o(104291);
            return;
        }
        for (String str : SeeRoomManagerUI.d(this.elM).afg()) {
            if (SeeRoomManagerUI.d(this.elM).aoo(str)) {
                ab.i("MicroMsg.SeeRoomManagerUI", "[resetData] Room Manager:%s", new Object[]{str});
                this.dataList.add(new a(this.elM, 1, ((j) g.K(j.class)).XM().aoO(str)));
            }
        }
        if (r.Yz().equals(SeeRoomManagerUI.d(this.elM).field_roomowner)) {
            this.dataList.add(new a(this.elM, 2, null));
            if (this.dataList.size() > 1) {
                this.dataList.add(new a(this.elM, 3, null));
            }
        }
        AppMethodBeat.o(104291);
    }

    public final int getCount() {
        AppMethodBeat.i(104292);
        int size = this.dataList.size();
        AppMethodBeat.o(104292);
        return size;
    }

    private a iF(int i) {
        AppMethodBeat.i(104293);
        a aVar = (a) this.dataList.get(i);
        AppMethodBeat.o(104293);
        return aVar;
    }

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

    public final View getView(int i, View view, ViewGroup viewGroup) {
        SeeRoomManagerUI.c ce;
        AppMethodBeat.i(104294);
        if (view == null) {
            view = View.inflate(this.mContext, 2130970531, null);
            ce = this.elM.ce(view);
        } else {
            ce = (SeeRoomManagerUI.c) view.getTag();
            if (ce == null) {
                ce = this.elM.ce(view);
            }
        }
        a iF = iF(i);
        if (iF == null) {
            ab.e("MicroMsg.SeeRoomManagerUI", "null == item! position:%s, count:%s", new Object[]{Integer.valueOf(i), Integer.valueOf(getCount())});
            AppMethodBeat.o(104294);
        } else {
            if (iF.type == 1) {
                ce.elJ.setVisibility(0);
                ad adVar = iF.ehM;
                ce.elJ.setText(SeeRoomManagerUI.a(this.elM, adVar.field_username, ce.elJ));
                b.b(ce.ejo, adVar.field_username);
            } else if (iF.type == 2) {
                ce.elJ.setVisibility(4);
                ce.ejo.setImageResource(2130837886);
            } else if (iF.type == 3) {
                ce.elJ.setVisibility(4);
                ce.ejo.setImageResource(2130837887);
            }
            view.setOnClickListener(new 2(this, i));
            AppMethodBeat.o(104294);
        }
        return view;
    }

    static /* synthetic */ String a(SeeRoomManagerUI$b seeRoomManagerUI$b, ad adVar) {
        String mJ;
        String Oi;
        AppMethodBeat.i(104296);
        if (bo.isNullOrNil(adVar.field_conRemark)) {
            mJ = SeeRoomManagerUI.d(seeRoomManagerUI$b.elM).mJ(adVar.field_username);
        } else {
            mJ = adVar.field_conRemark;
        }
        if (bo.isNullOrNil(mJ)) {
            Oi = adVar.Oi();
        } else {
            Oi = mJ;
        }
        if (!com.tencent.mm.n.a.jh(adVar.field_type)) {
            bv RB = ((j) g.K(j.class)).XN().RB(adVar.field_username);
            if (!(RB == null || bo.isNullOrNil(RB.field_conRemark))) {
                Oi = RB.field_conRemark;
            }
        }
        AppMethodBeat.o(104296);
        return Oi;
    }
}
