package ῲ.ᓆ;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import androidx.transition.R$id;
import ῲ.ᓆ.AbstractC1647;
import K.K.K.ʬ.C2369;

/* renamed from: ῲ.ᓆ.ᆯ  reason: contains not printable characters */
/* compiled from: Visibility */
public abstract class AbstractC1639 extends AbstractC1647 {
    public static final int MODE_IN = 1;
    public static final int MODE_OUT = 2;
    public static final String PROPNAME_PARENT = "android:visibility:parent";
    public static final String PROPNAME_SCREEN_LOCATION = "android:visibility:screenLocation";
    public static final String PROPNAME_VISIBILITY = "android:visibility:visibility";
    public static final String[] sTransitionProperties = {PROPNAME_VISIBILITY, PROPNAME_PARENT};
    public int mMode = 3;

    /* renamed from: ῲ.ᓆ.ᆯ$ʬ  reason: contains not printable characters */
    /* compiled from: Visibility */
    public static class C1640 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public int f5864;

        /* renamed from: ඓ  reason: contains not printable characters */
        public ViewGroup f5865;

        /* renamed from: ῲ  reason: contains not printable characters */
        public boolean f5866;

        /* renamed from: K  reason: contains not printable characters */
        public boolean f5867;

        /* renamed from: 㴹  reason: contains not printable characters */
        public ViewGroup f5868;

        /* renamed from: 㸾  reason: contains not printable characters */
        public int f5869;
    }

    /* renamed from: ῲ.ᓆ.ᆯ$K  reason: contains not printable characters */
    /* compiled from: Visibility */
    public class C1642 extends C1662 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final /* synthetic */ View f5876;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final /* synthetic */ View f5877;

        /* renamed from: K  reason: contains not printable characters */
        public final /* synthetic */ ViewGroup f5878;

        public C1642(ViewGroup viewGroup, View view, View view2) {
            this.f5878 = viewGroup;
            this.f5877 = view;
            this.f5876 = view2;
        }

        @Override // ῲ.ᓆ.AbstractC1647.AbstractC1652
        public void onTransitionEnd(AbstractC1647 r4) {
            this.f5876.setTag(R$id.save_overlay_view, null);
            C1631.m4210(this.f5878).remove(this.f5877);
            r4.removeListener(this);
        }

        @Override // ῲ.ᓆ.C1662, ῲ.ᓆ.AbstractC1647.AbstractC1652
        public void onTransitionPause(AbstractC1647 r2) {
            C1631.m4210(this.f5878).remove(this.f5877);
        }

        @Override // ῲ.ᓆ.C1662, ῲ.ᓆ.AbstractC1647.AbstractC1652
        public void onTransitionResume(AbstractC1647 r2) {
            if (this.f5877.getParent() == null) {
                C1631.m4210(this.f5878).add(this.f5877);
            } else {
                AbstractC1639.this.cancel();
            }
        }
    }

    public AbstractC1639() {
    }

    private void captureValues(C1646 r4) {
        r4.f5883.put(PROPNAME_VISIBILITY, Integer.valueOf(r4.f5882.getVisibility()));
        r4.f5883.put(PROPNAME_PARENT, r4.f5882.getParent());
        int[] iArr = new int[2];
        r4.f5882.getLocationOnScreen(iArr);
        r4.f5883.put(PROPNAME_SCREEN_LOCATION, iArr);
    }

    private C1640 getVisibilityChangeInfo(C1646 r8, C1646 r9) {
        C1640 r0 = new C1640();
        r0.f5867 = false;
        r0.f5866 = false;
        if (r8 == null || !r8.f5883.containsKey(PROPNAME_VISIBILITY)) {
            r0.f5864 = -1;
            r0.f5865 = null;
        } else {
            r0.f5864 = ((Integer) r8.f5883.get(PROPNAME_VISIBILITY)).intValue();
            r0.f5865 = (ViewGroup) r8.f5883.get(PROPNAME_PARENT);
        }
        if (r9 == null || !r9.f5883.containsKey(PROPNAME_VISIBILITY)) {
            r0.f5869 = -1;
            r0.f5868 = null;
        } else {
            r0.f5869 = ((Integer) r9.f5883.get(PROPNAME_VISIBILITY)).intValue();
            r0.f5868 = (ViewGroup) r9.f5883.get(PROPNAME_PARENT);
        }
        if (r8 == null || r9 == null) {
            if (r8 == null && r0.f5869 == 0) {
                r0.f5866 = true;
                r0.f5867 = true;
            } else if (r9 == null && r0.f5864 == 0) {
                r0.f5866 = false;
                r0.f5867 = true;
            }
        } else if (r0.f5864 == r0.f5869 && r0.f5865 == r0.f5868) {
            return r0;
        } else {
            int i = r0.f5864;
            int i2 = r0.f5869;
            if (i != i2) {
                if (i == 0) {
                    r0.f5866 = false;
                    r0.f5867 = true;
                } else if (i2 == 0) {
                    r0.f5866 = true;
                    r0.f5867 = true;
                }
            } else if (r0.f5868 == null) {
                r0.f5866 = false;
                r0.f5867 = true;
            } else if (r0.f5865 == null) {
                r0.f5866 = true;
                r0.f5867 = true;
            }
        }
        return r0;
    }

    @Override // ῲ.ᓆ.AbstractC1647
    public void captureEndValues(C1646 r1) {
        captureValues(r1);
    }

    @Override // ῲ.ᓆ.AbstractC1647
    public void captureStartValues(C1646 r1) {
        captureValues(r1);
    }

    @Override // ῲ.ᓆ.AbstractC1647
    public Animator createAnimator(ViewGroup viewGroup, C1646 r10, C1646 r11) {
        C1640 visibilityChangeInfo = getVisibilityChangeInfo(r10, r11);
        if (!visibilityChangeInfo.f5867) {
            return null;
        }
        if (visibilityChangeInfo.f5865 == null && visibilityChangeInfo.f5868 == null) {
            return null;
        }
        if (visibilityChangeInfo.f5866) {
            return onAppear(viewGroup, r10, visibilityChangeInfo.f5864, r11, visibilityChangeInfo.f5869);
        }
        return onDisappear(viewGroup, r10, visibilityChangeInfo.f5864, r11, visibilityChangeInfo.f5869);
    }

    public int getMode() {
        return this.mMode;
    }

    @Override // ῲ.ᓆ.AbstractC1647
    public String[] getTransitionProperties() {
        return sTransitionProperties;
    }

    @Override // ῲ.ᓆ.AbstractC1647
    public boolean isTransitionRequired(C1646 r5, C1646 r6) {
        if (r5 == null && r6 == null) {
            return false;
        }
        if (r5 != null && r6 != null && r6.f5883.containsKey(PROPNAME_VISIBILITY) != r5.f5883.containsKey(PROPNAME_VISIBILITY)) {
            return false;
        }
        C1640 visibilityChangeInfo = getVisibilityChangeInfo(r5, r6);
        if (!visibilityChangeInfo.f5867) {
            return false;
        }
        if (visibilityChangeInfo.f5864 == 0 || visibilityChangeInfo.f5869 == 0) {
            return true;
        }
        return false;
    }

    public boolean isVisible(C1646 r4) {
        if (r4 == null) {
            return false;
        }
        int intValue = ((Integer) r4.f5883.get(PROPNAME_VISIBILITY)).intValue();
        View view = (View) r4.f5883.get(PROPNAME_PARENT);
        if (intValue != 0 || view == null) {
            return false;
        }
        return true;
    }

    public abstract Animator onAppear(ViewGroup viewGroup, View view, C1646 v, C1646 v2);

    public Animator onAppear(ViewGroup viewGroup, C1646 r4, int i, C1646 r6, int i2) {
        if ((this.mMode & 1) != 1 || r6 == null) {
            return null;
        }
        if (r4 == null) {
            View view = (View) r6.f5882.getParent();
            if (getVisibilityChangeInfo(getMatchedTransitionValues(view, false), getTransitionValues(view, false)).f5867) {
                return null;
            }
        }
        return onAppear(viewGroup, r6.f5882, r4, r6);
    }

    public abstract Animator onDisappear(ViewGroup viewGroup, View view, C1646 v, C1646 v2);

    /* JADX WARNING: Code restructure failed: missing block: B:38:0x0080, code lost:
        if (r9.mCanRemoveViews != false) goto L_0x0082;
     */
    /* JADX WARNING: Removed duplicated region for block: B:24:0x0040  */
    public Animator onDisappear(ViewGroup viewGroup, C1646 r11, int i, C1646 r13, int i2) {
        View view;
        boolean z;
        boolean z2;
        if ((this.mMode & 2) != 2 || r11 == null) {
            return null;
        }
        View view2 = r11.f5882;
        View view3 = r13 != null ? r13.f5882 : null;
        View view4 = (View) view2.getTag(R$id.save_overlay_view);
        if (view4 != null) {
            view = null;
            z = true;
        } else {
            if (view3 == null || view3.getParent() == null) {
                if (view3 != null) {
                    view = null;
                    view4 = view3;
                }
                view4 = null;
                view = null;
                z2 = true;
                if (z2) {
                    if (view2.getParent() != null) {
                        if (view2.getParent() instanceof View) {
                            View view5 = (View) view2.getParent();
                            if (!getVisibilityChangeInfo(getTransitionValues(view5, true), getMatchedTransitionValues(view5, true)).f5867) {
                                view4 = C1632.m4213(viewGroup, view2, view5);
                            } else {
                                int id = view5.getId();
                                if (view5.getParent() == null) {
                                    if (id != -1) {
                                        if (viewGroup.findViewById(id) != null) {
                                        }
                                    }
                                }
                            }
                        }
                    }
                    view4 = view2;
                }
                z = false;
            } else {
                if (i2 == 4 || view2 == view3) {
                    view4 = null;
                    view = view3;
                }
                view4 = null;
                view = null;
                z2 = true;
                if (z2) {
                }
                z = false;
            }
            z2 = false;
            if (z2) {
            }
            z = false;
        }
        if (view4 != null) {
            if (!z) {
                int[] iArr = (int[]) r11.f5883.get(PROPNAME_SCREEN_LOCATION);
                int i3 = iArr[0];
                int i4 = iArr[1];
                int[] iArr2 = new int[2];
                viewGroup.getLocationOnScreen(iArr2);
                view4.offsetLeftAndRight((i3 - iArr2[0]) - view4.getLeft());
                view4.offsetTopAndBottom((i4 - iArr2[1]) - view4.getTop());
                C1631.m4210(viewGroup).add(view4);
            }
            Animator onDisappear = onDisappear(viewGroup, view4, r11, r13);
            if (!z) {
                if (onDisappear == null) {
                    C1631.m4210(viewGroup).remove(view4);
                } else {
                    view2.setTag(R$id.save_overlay_view, view4);
                    addListener(new C1642(viewGroup, view4, view2));
                }
            }
            return onDisappear;
        } else if (view == null) {
            return null;
        } else {
            int visibility = view.getVisibility();
            C1669.f5917.m4245(view, 0);
            Animator onDisappear2 = onDisappear(viewGroup, view, r11, r13);
            if (onDisappear2 != null) {
                C1641 r112 = new C1641(view, i2, true);
                onDisappear2.addListener(r112);
                int i5 = Build.VERSION.SDK_INT;
                onDisappear2.addPauseListener(r112);
                addListener(r112);
            } else {
                C1669.f5917.m4245(view, visibility);
            }
            return onDisappear2;
        }
    }

    public void setMode(int i) {
        if ((i & -4) == 0) {
            this.mMode = i;
            return;
        }
        throw new IllegalArgumentException("Only MODE_IN and MODE_OUT flags are allowed");
    }

    @SuppressLint({"RestrictedApi"})
    public AbstractC1639(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        TypedArray obtainStyledAttributes = context.obtainStyledAttributes(attributeSet, C1668.f5914);
        int r4 = C2369.m6277(obtainStyledAttributes, (XmlResourceParser) attributeSet, "transitionVisibilityMode", 0, 0);
        obtainStyledAttributes.recycle();
        if (r4 != 0) {
            setMode(r4);
        }
    }

    /* renamed from: ῲ.ᓆ.ᆯ$ῲ  reason: contains not printable characters */
    /* compiled from: Visibility */
    public static class C1641 extends AnimatorListenerAdapter implements AbstractC1647.AbstractC1652, AbstractC1658 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public final ViewGroup f5870;

        /* renamed from: ඓ  reason: contains not printable characters */
        public boolean f5871;

        /* renamed from: ῲ  reason: contains not printable characters */
        public final int f5872;

        /* renamed from: K  reason: contains not printable characters */
        public final View f5873;

        /* renamed from: 㴹  reason: contains not printable characters */
        public boolean f5874 = false;

        /* renamed from: 㸾  reason: contains not printable characters */
        public final boolean f5875;

        public C1641(View view, int i, boolean z) {
            this.f5873 = view;
            this.f5872 = i;
            this.f5870 = (ViewGroup) view.getParent();
            this.f5875 = z;
            m4234(true);
        }

        public void onAnimationCancel(Animator animator) {
            this.f5874 = true;
        }

        public void onAnimationEnd(Animator animator) {
            m4233();
        }

        public void onAnimationPause(Animator animator) {
            if (!this.f5874) {
                C1669.f5917.m4245(this.f5873, this.f5872);
            }
        }

        public void onAnimationRepeat(Animator animator) {
        }

        public void onAnimationResume(Animator animator) {
            if (!this.f5874) {
                C1669.f5917.m4245(this.f5873, 0);
            }
        }

        public void onAnimationStart(Animator animator) {
        }

        @Override // ῲ.ᓆ.AbstractC1647.AbstractC1652
        public void onTransitionCancel(AbstractC1647 r1) {
        }

        @Override // ῲ.ᓆ.AbstractC1647.AbstractC1652
        public void onTransitionEnd(AbstractC1647 r1) {
            m4233();
            r1.removeListener(this);
        }

        @Override // ῲ.ᓆ.AbstractC1647.AbstractC1652
        public void onTransitionPause(AbstractC1647 r1) {
            m4234(false);
        }

        @Override // ῲ.ᓆ.AbstractC1647.AbstractC1652
        public void onTransitionResume(AbstractC1647 r1) {
            m4234(true);
        }

        @Override // ῲ.ᓆ.AbstractC1647.AbstractC1652
        public void onTransitionStart(AbstractC1647 r1) {
        }

        /* renamed from: K  reason: contains not printable characters */
        public final void m4233() {
            if (!this.f5874) {
                C1669.f5917.m4245(this.f5873, this.f5872);
                ViewGroup viewGroup = this.f5870;
                if (viewGroup != null) {
                    viewGroup.invalidate();
                }
            }
            m4234(false);
        }

        /* renamed from: K  reason: contains not printable characters */
        public final void m4234(boolean z) {
            ViewGroup viewGroup;
            if (this.f5875 && this.f5871 != z && (viewGroup = this.f5870) != null) {
                this.f5871 = z;
                C1631.m4211(viewGroup, z);
            }
        }
    }
}
