package o;

import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import com.google.android.gms.common.R;
import java.util.ArrayList;

/* compiled from: r8-map-id-3b7cc9102578c509342fa2f0fabed2bfc72239cd258d579fc679bfcbc198b048 */
/* loaded from: classes.dex */
public final class LL extends BaseAdapter {
    public int a = -1;
    public final /* synthetic */ ML b;

    public LL(ML ml) {
        this.b = ml;
        a();
    }

    public final void a() {
        CO co = this.b.n;
        LO lo = co.v;
        if (lo != null) {
            co.i();
            ArrayList arrayList = co.j;
            int size = arrayList.size();
            for (int i = 0; i < size; i++) {
                if (((LO) arrayList.get(i)) == lo) {
                    this.a = i;
                    return;
                }
            }
        }
        this.a = -1;
    }

    @Override // android.widget.Adapter
    /* renamed from: b, reason: merged with bridge method [inline-methods] */
    public final LO getItem(int i) {
        ML ml = this.b;
        CO co = ml.n;
        co.i();
        ArrayList arrayList = co.j;
        ml.getClass();
        int i2 = this.a;
        if (i2 >= 0 && i >= i2) {
            i++;
        }
        return (LO) arrayList.get(i);
    }

    @Override // android.widget.Adapter
    public final int getCount() {
        ML ml = this.b;
        CO co = ml.n;
        co.i();
        int size = co.j.size();
        ml.getClass();
        return this.a < 0 ? size : size - 1;
    }

    @Override // android.widget.Adapter
    public final long getItemId(int i) {
        return i;
    }

    @Override // android.widget.Adapter
    public final View getView(int i, View view, ViewGroup viewGroup) {
        if (view == null) {
            view = this.b.m.inflate(R.layout.abc_list_menu_item_layout, viewGroup, false);
        }
        ((InterfaceC1381hP) view).a(getItem(i));
        return view;
    }

    @Override // android.widget.BaseAdapter
    public final void notifyDataSetChanged() {
        a();
        super.notifyDataSetChanged();
    }
}
