package n;

import android.content.Context;
import android.view.ActionMode;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import androidx.collection.t0;
import java.util.ArrayList;
import n.b;

/* loaded from: classes.dex */
public class f extends ActionMode {

    /* renamed from: a, reason: collision with root package name */
    final Context f29670a;

    /* renamed from: b, reason: collision with root package name */
    final b f29671b;

    /* loaded from: classes.dex */
    public static class a implements b.a {

        /* renamed from: a, reason: collision with root package name */
        final ActionMode.Callback f29672a;

        /* renamed from: b, reason: collision with root package name */
        final Context f29673b;

        /* renamed from: c, reason: collision with root package name */
        final ArrayList f29674c = new ArrayList();

        /* renamed from: d, reason: collision with root package name */
        final t0 f29675d = new t0();

        public a(Context context, ActionMode.Callback callback) {
            this.f29673b = context;
            this.f29672a = callback;
        }

        private Menu f(Menu menu) {
            Menu menu2 = (Menu) this.f29675d.get(menu);
            if (menu2 != null) {
                return menu2;
            }
            o.d dVar = new o.d(this.f29673b, (n3.a) menu);
            this.f29675d.put(menu, dVar);
            return dVar;
        }

        @Override // n.b.a
        public boolean a(b bVar, Menu menu) {
            return this.f29672a.onCreateActionMode(e(bVar), f(menu));
        }

        @Override // n.b.a
        public boolean b(b bVar, Menu menu) {
            return this.f29672a.onPrepareActionMode(e(bVar), f(menu));
        }

        @Override // n.b.a
        public boolean c(b bVar, MenuItem menuItem) {
            return this.f29672a.onActionItemClicked(e(bVar), new o.c(this.f29673b, (n3.b) menuItem));
        }

        @Override // n.b.a
        public void d(b bVar) {
            this.f29672a.onDestroyActionMode(e(bVar));
        }

        public ActionMode e(b bVar) {
            int size = this.f29674c.size();
            for (int i10 = 0; i10 < size; i10++) {
                f fVar = (f) this.f29674c.get(i10);
                if (fVar != null && fVar.f29671b == bVar) {
                    return fVar;
                }
            }
            f fVar2 = new f(this.f29673b, bVar);
            this.f29674c.add(fVar2);
            return fVar2;
        }
    }

    public f(Context context, b bVar) {
        this.f29670a = context;
        this.f29671b = bVar;
    }

    @Override // android.view.ActionMode
    public void finish() {
        this.f29671b.c();
    }

    @Override // android.view.ActionMode
    public View getCustomView() {
        return this.f29671b.d();
    }

    @Override // android.view.ActionMode
    public Menu getMenu() {
        return new o.d(this.f29670a, (n3.a) this.f29671b.e());
    }

    @Override // android.view.ActionMode
    public MenuInflater getMenuInflater() {
        return this.f29671b.f();
    }

    @Override // android.view.ActionMode
    public CharSequence getSubtitle() {
        return this.f29671b.g();
    }

    @Override // android.view.ActionMode
    public Object getTag() {
        return this.f29671b.h();
    }

    @Override // android.view.ActionMode
    public CharSequence getTitle() {
        return this.f29671b.i();
    }

    @Override // android.view.ActionMode
    public boolean getTitleOptionalHint() {
        return this.f29671b.j();
    }

    @Override // android.view.ActionMode
    public void invalidate() {
        this.f29671b.k();
    }

    @Override // android.view.ActionMode
    public boolean isTitleOptional() {
        return this.f29671b.l();
    }

    @Override // android.view.ActionMode
    public void setCustomView(View view) {
        this.f29671b.m(view);
    }

    @Override // android.view.ActionMode
    public void setSubtitle(CharSequence charSequence) {
        this.f29671b.o(charSequence);
    }

    @Override // android.view.ActionMode
    public void setTag(Object obj) {
        this.f29671b.p(obj);
    }

    @Override // android.view.ActionMode
    public void setTitle(CharSequence charSequence) {
        this.f29671b.r(charSequence);
    }

    @Override // android.view.ActionMode
    public void setTitleOptionalHint(boolean z10) {
        this.f29671b.s(z10);
    }

    @Override // android.view.ActionMode
    public void setSubtitle(int i10) {
        this.f29671b.n(i10);
    }

    @Override // android.view.ActionMode
    public void setTitle(int i10) {
        this.f29671b.q(i10);
    }
}
