package defpackage;

import android.R;
import android.animation.ValueAnimator;
import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import androidx.appcompat.widget.ActionBarContainer;
import androidx.appcompat.widget.ActionBarContextView;
import androidx.appcompat.widget.ActionBarOverlayLayout;
import androidx.appcompat.widget.Toolbar;
import java.util.ArrayList;
import java.util.WeakHashMap;

/* renamed from: ᵫᵞᵻ, reason: contains not printable characters */
/* loaded from: classes3.dex */
public final class C3966 implements InterfaceC0070 {

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public InterfaceC0105 f14955;

    /* renamed from: ˌʾˀ, reason: contains not printable characters */
    public boolean f14956;

    /* renamed from: ˌᵜᵹᵩ, reason: contains not printable characters */
    public boolean f14957;

    /* renamed from: ˎˏʜʾ, reason: contains not printable characters */
    public final View f14958;

    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public ActionBarContextView f14959;

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public ActionBarOverlayLayout f14960;

    /* renamed from: ˑᵱ, reason: contains not printable characters */
    public boolean f14961;

    /* renamed from: ᵝᵵᵺ, reason: contains not printable characters */
    public C0959 f14962;

    /* renamed from: ᵞʡ, reason: contains not printable characters */
    public C2772 f14963;

    /* renamed from: ᵡʠ, reason: contains not printable characters */
    public boolean f14964;

    /* renamed from: ᵢˇᵭ, reason: contains not printable characters */
    public final C1205 f14965;

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public Context f14966;

    /* renamed from: ᵧᵾˀˈ, reason: contains not printable characters */
    public final C1205 f14967;

    /* renamed from: ᵨᵳʝ, reason: contains not printable characters */
    public boolean f14968;

    /* renamed from: ᵪʩ, reason: contains not printable characters */
    public int f14969;

    /* renamed from: ᵯٴᵦ, reason: contains not printable characters */
    public final ArrayList f14970;

    /* renamed from: ᵳٴᵶ, reason: contains not printable characters */
    public boolean f14971;

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public Context f14972;

    /* renamed from: ᵶᵷᵕ, reason: contains not printable characters */
    public C0959 f14973;

    /* renamed from: ᵸʓᵠ, reason: contains not printable characters */
    public boolean f14974;

    /* renamed from: ᵸˑ, reason: contains not printable characters */
    public ᵪᵨ f14975;

    /* renamed from: ᵹᵝᵶ, reason: contains not printable characters */
    public boolean f14976;

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public ActionBarContainer f14977;

    /* renamed from: ᵿʗᵝʽ, reason: contains not printable characters */
    public final ˊʘ f14978;

    /* renamed from: ᵾᵬ, reason: contains not printable characters */
    public static final AccelerateInterpolator f14954 = new AccelerateInterpolator();

    /* renamed from: ᵤᵙᵷ, reason: contains not printable characters */
    public static final DecelerateInterpolator f14953 = new DecelerateInterpolator();

    public C3966(Activity activity, boolean z) {
        new ArrayList();
        this.f14970 = new ArrayList();
        this.f14969 = 0;
        this.f14971 = true;
        this.f14974 = true;
        this.f14967 = new C1205(this, 0);
        this.f14965 = new C1205(this, 1);
        this.f14978 = new ˊʘ(27, this);
        View decorView = activity.getWindow().getDecorView();
        m8788(decorView);
        if (z) {
            return;
        }
        this.f14958 = decorView.findViewById(R.id.content);
    }

    public C3966(Dialog dialog) {
        new ArrayList();
        this.f14970 = new ArrayList();
        this.f14969 = 0;
        this.f14971 = true;
        this.f14974 = true;
        this.f14967 = new C1205(this, 0);
        this.f14965 = new C1205(this, 1);
        this.f14978 = new ˊʘ(27, this);
        m8788(dialog.getWindow().getDecorView());
    }

    /* renamed from: ˇʼʤˎ, reason: contains not printable characters */
    public final void m8786(boolean z) {
        if (z) {
            this.f14977.setTabContainer(null);
            ((C0062) this.f14955).getClass();
        } else {
            ((C0062) this.f14955).getClass();
            this.f14977.setTabContainer(null);
        }
        this.f14955.getClass();
        ((C0062) this.f14955).f1272.setCollapsible(false);
        this.f14960.setHasNonEmbeddedTabs(false);
    }

    /* JADX WARN: Type inference failed for: r1v2, types: [ˆⁱ, ˉᵢˇ] */
    /* JADX WARN: Type inference failed for: r1v3, types: [ˆⁱ, ˉᵢˇ] */
    /* renamed from: ˏˋٴ, reason: contains not printable characters */
    public final void m8787(boolean z) {
        boolean z2 = this.f14964 || !this.f14956;
        boolean z3 = this.f14974;
        final ˊʘ r8 = this.f14978;
        View view = this.f14958;
        if (!z2) {
            if (z3) {
                this.f14974 = false;
                C2772 c2772 = this.f14963;
                if (c2772 != null) {
                    c2772.m6844();
                }
                int i = this.f14969;
                ?? r1 = this.f14967;
                if (i != 0 || (!this.f14968 && !z)) {
                    r1.m3742();
                    return;
                }
                this.f14977.setAlpha(1.0f);
                this.f14977.setTransitioning(true);
                C2772 c27722 = new C2772();
                float f = -this.f14977.getHeight();
                if (z) {
                    this.f14977.getLocationInWindow(new int[]{0, 0});
                    f -= r12[1];
                }
                C1014 c1014M7024 = AbstractC2873.m7024(this.f14977);
                c1014M7024.m3378(f);
                final View view2 = (View) c1014M7024.f4456.get();
                if (view2 != null) {
                    view2.animate().setUpdateListener(r8 != null ? new ValueAnimator.AnimatorUpdateListener() { // from class: ᵽˌᵘ
                        @Override // android.animation.ValueAnimator.AnimatorUpdateListener
                        public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                            ((View) ((C3966) r8.ᵢˇᵭ).f14977.getParent()).invalidate();
                        }
                    } : null);
                }
                boolean z4 = c27722.f10699;
                ArrayList arrayList = c27722.f10702;
                if (!z4) {
                    arrayList.add(c1014M7024);
                }
                if (this.f14971 && view != null) {
                    C1014 c1014M70242 = AbstractC2873.m7024(view);
                    c1014M70242.m3378(f);
                    if (!c27722.f10699) {
                        arrayList.add(c1014M70242);
                    }
                }
                boolean z5 = c27722.f10699;
                if (!z5) {
                    c27722.f10701 = f14954;
                }
                if (!z5) {
                    c27722.f10703 = 250L;
                }
                if (!z5) {
                    c27722.f10704 = r1;
                }
                this.f14963 = c27722;
                c27722.m6845();
                return;
            }
            return;
        }
        if (z3) {
            return;
        }
        this.f14974 = true;
        C2772 c27723 = this.f14963;
        if (c27723 != null) {
            c27723.m6844();
        }
        this.f14977.setVisibility(0);
        int i2 = this.f14969;
        ?? r12 = this.f14965;
        if (i2 == 0 && (this.f14968 || z)) {
            this.f14977.setTranslationY(0.0f);
            float f2 = -this.f14977.getHeight();
            if (z) {
                this.f14977.getLocationInWindow(new int[]{0, 0});
                f2 -= r12[1];
            }
            this.f14977.setTranslationY(f2);
            C2772 c27724 = new C2772();
            C1014 c1014M70243 = AbstractC2873.m7024(this.f14977);
            c1014M70243.m3378(0.0f);
            final View view3 = (View) c1014M70243.f4456.get();
            if (view3 != null) {
                view3.animate().setUpdateListener(r8 != null ? new ValueAnimator.AnimatorUpdateListener() { // from class: ᵽˌᵘ
                    @Override // android.animation.ValueAnimator.AnimatorUpdateListener
                    public final void onAnimationUpdate(ValueAnimator valueAnimator) {
                        ((View) ((C3966) r8.ᵢˇᵭ).f14977.getParent()).invalidate();
                    }
                } : null);
            }
            boolean z6 = c27724.f10699;
            ArrayList arrayList2 = c27724.f10702;
            if (!z6) {
                arrayList2.add(c1014M70243);
            }
            if (this.f14971 && view != null) {
                view.setTranslationY(f2);
                C1014 c1014M70244 = AbstractC2873.m7024(view);
                c1014M70244.m3378(0.0f);
                if (!c27724.f10699) {
                    arrayList2.add(c1014M70244);
                }
            }
            boolean z7 = c27724.f10699;
            if (!z7) {
                c27724.f10701 = f14953;
            }
            if (!z7) {
                c27724.f10703 = 250L;
            }
            if (!z7) {
                c27724.f10704 = r12;
            }
            this.f14963 = c27724;
            c27724.m6845();
        } else {
            this.f14977.setAlpha(1.0f);
            this.f14977.setTranslationY(0.0f);
            if (this.f14971 && view != null) {
                view.setTranslationY(0.0f);
            }
            r12.m3742();
        }
        ActionBarOverlayLayout actionBarOverlayLayout = this.f14960;
        if (actionBarOverlayLayout != null) {
            WeakHashMap weakHashMap = AbstractC2873.f11133;
            actionBarOverlayLayout.requestApplyInsets();
        }
    }

    /* renamed from: ˏᵙ, reason: contains not printable characters */
    public final void m8788(View view) {
        InterfaceC0105 wrapper;
        ActionBarOverlayLayout actionBarOverlayLayout = (ActionBarOverlayLayout) view.findViewById(ar.tvplayer.tv.R.id._11_res_0x7f0b0119);
        this.f14960 = actionBarOverlayLayout;
        if (actionBarOverlayLayout != null) {
            actionBarOverlayLayout.setActionBarVisibilityCallback(this);
        }
        KeyEvent.Callback callbackFindViewById = view.findViewById(ar.tvplayer.tv.R.id._11_res_0x7f0b003b);
        if (callbackFindViewById instanceof InterfaceC0105) {
            wrapper = (InterfaceC0105) callbackFindViewById;
        } else {
            if (!(callbackFindViewById instanceof Toolbar)) {
                throw new IllegalStateException("Can't make a decor toolbar out of ".concat(callbackFindViewById != null ? callbackFindViewById.getClass().getSimpleName() : "null"));
            }
            wrapper = ((Toolbar) callbackFindViewById).getWrapper();
        }
        this.f14955 = wrapper;
        this.f14959 = (ActionBarContextView) view.findViewById(ar.tvplayer.tv.R.id._11_res_0x7f0b0043);
        ActionBarContainer actionBarContainer = (ActionBarContainer) view.findViewById(ar.tvplayer.tv.R.id._11_res_0x7f0b003d);
        this.f14977 = actionBarContainer;
        InterfaceC0105 interfaceC0105 = this.f14955;
        if (interfaceC0105 == null || this.f14959 == null || actionBarContainer == null) {
            ᵹˉᵞ.ᵳٴᵶ(C3966.class.getSimpleName().concat(" can only be used with a compatible window decor layout"));
            return;
        }
        Context context = ((C0062) interfaceC0105).f1272.getContext();
        this.f14966 = context;
        if ((((C0062) this.f14955).f1276 & 4) != 0) {
            this.f14976 = true;
        }
        int i = context.getApplicationInfo().targetSdkVersion;
        this.f14955.getClass();
        m8786(context.getResources().getBoolean(ar.tvplayer.tv.R.bool._11_res_0x7f050000));
        TypedArray typedArrayObtainStyledAttributes = this.f14966.obtainStyledAttributes(null, AbstractC0542.f2816, ar.tvplayer.tv.R.attr._11_res_0x7f040007, 0);
        if (typedArrayObtainStyledAttributes.getBoolean(14, false)) {
            ActionBarOverlayLayout actionBarOverlayLayout2 = this.f14960;
            if (!actionBarOverlayLayout2.f109) {
                ᵹˉᵞ.ᵳٴᵶ("Action bar must be in overlay mode (Window.FEATURE_OVERLAY_ACTION_BAR) to enable hide on content scroll");
                return;
            } else {
                this.f14961 = true;
                actionBarOverlayLayout2.setHideOnContentScrollEnabled(true);
            }
        }
        int dimensionPixelSize = typedArrayObtainStyledAttributes.getDimensionPixelSize(12, 0);
        if (dimensionPixelSize != 0) {
            ActionBarContainer actionBarContainer2 = this.f14977;
            WeakHashMap weakHashMap = AbstractC2873.f11133;
            actionBarContainer2.setElevation(dimensionPixelSize);
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    /* renamed from: ᵥᵯˎ, reason: contains not printable characters */
    public final void m8789(boolean z) {
        C1014 c1014M16;
        C1014 c1014M162;
        boolean z2 = this.f14964;
        if (z) {
            if (!z2) {
                this.f14964 = true;
                ActionBarOverlayLayout actionBarOverlayLayout = this.f14960;
                if (actionBarOverlayLayout != null) {
                    actionBarOverlayLayout.setShowingForActionMode(true);
                }
                m8787(false);
            }
        } else if (z2) {
            this.f14964 = false;
            ActionBarOverlayLayout actionBarOverlayLayout2 = this.f14960;
            if (actionBarOverlayLayout2 != null) {
                actionBarOverlayLayout2.setShowingForActionMode(false);
            }
            m8787(false);
        }
        boolean zIsLaidOut = this.f14977.isLaidOut();
        InterfaceC0105 interfaceC0105 = this.f14955;
        if (!zIsLaidOut) {
            if (z) {
                ((C0062) interfaceC0105).f1272.setVisibility(4);
                this.f14959.setVisibility(0);
                return;
            } else {
                ((C0062) interfaceC0105).f1272.setVisibility(0);
                this.f14959.setVisibility(8);
                return;
            }
        }
        if (z) {
            C0062 c0062 = (C0062) interfaceC0105;
            C1014 c1014M7024 = AbstractC2873.m7024(c0062.f1272);
            c1014M7024.m3380(0.0f);
            c1014M7024.m3379(100L);
            c1014M7024.m3382(new C5477(c0062, 4));
            c1014M162 = this.f14959.m16(200L, 0);
            c1014M16 = c1014M7024;
        } else {
            C0062 c00622 = (C0062) interfaceC0105;
            C1014 c1014M70242 = AbstractC2873.m7024(c00622.f1272);
            c1014M70242.m3380(1.0f);
            c1014M70242.m3379(200L);
            c1014M70242.m3382(new C5477(c00622, 0));
            c1014M16 = this.f14959.m16(100L, 8);
            c1014M162 = c1014M70242;
        }
        C2772 c2772 = new C2772();
        ArrayList arrayList = c2772.f10702;
        arrayList.add(c1014M16);
        View view = (View) c1014M16.f4456.get();
        long duration = view != null ? view.animate().getDuration() : 0L;
        View view2 = (View) c1014M162.f4456.get();
        if (view2 != null) {
            view2.animate().setStartDelay(duration);
        }
        arrayList.add(c1014M162);
        c2772.m6845();
    }

    /* renamed from: ᵴᵳ, reason: contains not printable characters */
    public final Context m8790() {
        if (this.f14972 == null) {
            TypedValue typedValue = new TypedValue();
            this.f14966.getTheme().resolveAttribute(ar.tvplayer.tv.R.attr._11_res_0x7f04000c, typedValue, true);
            int i = typedValue.resourceId;
            if (i != 0) {
                this.f14972 = new ContextThemeWrapper(this.f14966, i);
            } else {
                this.f14972 = this.f14966;
            }
        }
        return this.f14972;
    }

    /* renamed from: ᵻᵢﹳᵰ, reason: contains not printable characters */
    public final void m8791(boolean z) {
        if (this.f14976) {
            return;
        }
        int i = z ? 4 : 0;
        C0062 c0062 = (C0062) this.f14955;
        int i2 = c0062.f1276;
        this.f14976 = true;
        c0062.m1133((i & 4) | (i2 & (-5)));
    }
}
