package e;

import android.content.Context;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import androidx.appcompat.widget.ActionBarContextView;
import java.lang.ref.WeakReference;

/* JADX INFO: loaded from: classes.dex */
public final class x0 extends j.c implements k.n {

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final Context f25360c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public final k.p f25361d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public j.b f25362e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public WeakReference f25363f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public final /* synthetic */ y0 f25364g;

    public x0(y0 y0Var, Context context, b0 b0Var) {
        this.f25364g = y0Var;
        this.f25360c = context;
        this.f25362e = b0Var;
        k.p pVar = new k.p(context);
        pVar.f28891l = 1;
        this.f25361d = pVar;
        pVar.f28884e = this;
    }

    @Override // j.c
    public final void a() {
        y0 y0Var = this.f25364g;
        if (y0Var.f25375j != this) {
            return;
        }
        boolean z10 = y0Var.f25382q;
        boolean z11 = y0Var.f25383r;
        if (z10 || z11) {
            y0Var.f25376k = this;
            y0Var.f25377l = this.f25362e;
        } else {
            this.f25362e.a(this);
        }
        this.f25362e = null;
        y0Var.u(false);
        ActionBarContextView actionBarContextView = y0Var.f25372g;
        if (actionBarContextView.f599k == null) {
            actionBarContextView.h();
        }
        y0Var.f25369d.setHideOnContentScrollEnabled(y0Var.f25388w);
        y0Var.f25375j = null;
    }

    @Override // j.c
    public final View b() {
        WeakReference weakReference = this.f25363f;
        if (weakReference != null) {
            return (View) weakReference.get();
        }
        return null;
    }

    @Override // j.c
    public final Menu c() {
        return this.f25361d;
    }

    @Override // j.c
    public final MenuInflater d() {
        return new j.k(this.f25360c);
    }

    @Override // j.c
    public final CharSequence e() {
        return this.f25364g.f25372g.getSubtitle();
    }

    @Override // k.n
    public final boolean f(k.p pVar, MenuItem menuItem) {
        j.b bVar = this.f25362e;
        if (bVar != null) {
            return bVar.b(this, menuItem);
        }
        return false;
    }

    @Override // j.c
    public final CharSequence g() {
        return this.f25364g.f25372g.getTitle();
    }

    @Override // j.c
    public final void h() {
        if (this.f25364g.f25375j != this) {
            return;
        }
        k.p pVar = this.f25361d;
        pVar.y();
        try {
            this.f25362e.d(this, pVar);
        } finally {
            pVar.x();
        }
    }

    @Override // j.c
    public final boolean i() {
        return this.f25364g.f25372g.V;
    }

    @Override // j.c
    public final void j(View view) {
        this.f25364g.f25372g.setCustomView(view);
        this.f25363f = new WeakReference(view);
    }

    @Override // j.c
    public final void k(int i10) {
        m(this.f25364g.f25366a.getResources().getString(i10));
    }

    @Override // k.n
    public final void l(k.p pVar) {
        if (this.f25362e == null) {
            return;
        }
        h();
        l.p pVar2 = this.f25364g.f25372g.f29634d;
        if (pVar2 != null) {
            pVar2.i();
        }
    }

    @Override // j.c
    public final void m(CharSequence charSequence) {
        this.f25364g.f25372g.setSubtitle(charSequence);
    }

    @Override // j.c
    public final void n(int i10) {
        o(this.f25364g.f25366a.getResources().getString(i10));
    }

    @Override // j.c
    public final void o(CharSequence charSequence) {
        this.f25364g.f25372g.setTitle(charSequence);
    }

    @Override // j.c
    public final void p(boolean z10) {
        this.f28435b = z10;
        this.f25364g.f25372g.setTitleOptional(z10);
    }
}
