package j0;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.Property;
import android.view.View;
import android.view.ViewGroup;
import java.util.Map;

/* JADX INFO: compiled from: ChangeBounds.java */
/* JADX INFO: loaded from: classes.dex */
public class c extends m {
    private static final String[] Q = {"android:changeBounds:bounds", "android:changeBounds:clip", "android:changeBounds:parent", "android:changeBounds:windowX", "android:changeBounds:windowY"};
    private static final Property<Drawable, PointF> R = new b(PointF.class, "boundsOrigin");
    private static final Property<k, PointF> S = new C0071c(PointF.class, "topLeft");
    private static final Property<k, PointF> T = new d(PointF.class, "bottomRight");
    private static final Property<View, PointF> U = new e(PointF.class, "bottomRight");
    private static final Property<View, PointF> V = new f(PointF.class, "topLeft");
    private static final Property<View, PointF> W = new g(PointF.class, "position");
    private static j0.k X = new j0.k();
    private int[] N = new int[2];
    private boolean O = false;
    private boolean P = false;

    /* JADX INFO: compiled from: ChangeBounds.java */
    class a extends AnimatorListenerAdapter {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ ViewGroup f4920a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final /* synthetic */ BitmapDrawable f4921b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        final /* synthetic */ View f4922c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        final /* synthetic */ float f4923d;

        a(c cVar, ViewGroup viewGroup, BitmapDrawable bitmapDrawable, View view, float f3) {
            this.f4920a = viewGroup;
            this.f4921b = bitmapDrawable;
            this.f4922c = view;
            this.f4923d = f3;
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public void onAnimationEnd(Animator animator) {
            c0.b(this.f4920a).d(this.f4921b);
            c0.g(this.f4922c, this.f4923d);
        }
    }

    /* JADX INFO: compiled from: ChangeBounds.java */
    static class b extends Property<Drawable, PointF> {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private Rect f4924a;

        b(Class cls, String str) {
            super(cls, str);
            this.f4924a = new Rect();
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
        public PointF get(Drawable drawable) {
            drawable.copyBounds(this.f4924a);
            Rect rect = this.f4924a;
            return new PointF(rect.left, rect.top);
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
        public void set(Drawable drawable, PointF pointF) {
            drawable.copyBounds(this.f4924a);
            this.f4924a.offsetTo(Math.round(pointF.x), Math.round(pointF.y));
            drawable.setBounds(this.f4924a);
        }
    }

    /* JADX INFO: renamed from: j0.c$c, reason: collision with other inner class name */
    /* JADX INFO: compiled from: ChangeBounds.java */
    static class C0071c extends Property<k, PointF> {
        C0071c(Class cls, String str) {
            super(cls, str);
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
        public PointF get(k kVar) {
            return null;
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
        public void set(k kVar, PointF pointF) {
            kVar.c(pointF);
        }
    }

    /* JADX INFO: compiled from: ChangeBounds.java */
    static class d extends Property<k, PointF> {
        d(Class cls, String str) {
            super(cls, str);
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
        public PointF get(k kVar) {
            return null;
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
        public void set(k kVar, PointF pointF) {
            kVar.a(pointF);
        }
    }

    /* JADX INFO: compiled from: ChangeBounds.java */
    static class e extends Property<View, PointF> {
        e(Class cls, String str) {
            super(cls, str);
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
        public PointF get(View view) {
            return null;
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
        public void set(View view, PointF pointF) {
            c0.f(view, view.getLeft(), view.getTop(), Math.round(pointF.x), Math.round(pointF.y));
        }
    }

    /* JADX INFO: compiled from: ChangeBounds.java */
    static class f extends Property<View, PointF> {
        f(Class cls, String str) {
            super(cls, str);
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
        public PointF get(View view) {
            return null;
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
        public void set(View view, PointF pointF) {
            c0.f(view, Math.round(pointF.x), Math.round(pointF.y), view.getRight(), view.getBottom());
        }
    }

    /* JADX INFO: compiled from: ChangeBounds.java */
    static class g extends Property<View, PointF> {
        g(Class cls, String str) {
            super(cls, str);
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: a, reason: merged with bridge method [inline-methods] */
        public PointF get(View view) {
            return null;
        }

        @Override // android.util.Property
        /* JADX INFO: renamed from: b, reason: merged with bridge method [inline-methods] */
        public void set(View view, PointF pointF) {
            int iRound = Math.round(pointF.x);
            int iRound2 = Math.round(pointF.y);
            c0.f(view, iRound, iRound2, view.getWidth() + iRound, view.getHeight() + iRound2);
        }
    }

    /* JADX INFO: compiled from: ChangeBounds.java */
    class h extends AnimatorListenerAdapter {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        final /* synthetic */ k f4925a;
        private k mViewBounds;

        h(c cVar, k kVar) {
            this.f4925a = kVar;
            this.mViewBounds = kVar;
        }
    }

    /* JADX INFO: compiled from: ChangeBounds.java */
    class i extends AnimatorListenerAdapter {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private boolean f4926a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final /* synthetic */ View f4927b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        final /* synthetic */ Rect f4928c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        final /* synthetic */ int f4929d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        final /* synthetic */ int f4930e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        final /* synthetic */ int f4931f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        final /* synthetic */ int f4932g;

        i(c cVar, View view, Rect rect, int i3, int i4, int i5, int i6) {
            this.f4927b = view;
            this.f4928c = rect;
            this.f4929d = i3;
            this.f4930e = i4;
            this.f4931f = i5;
            this.f4932g = i6;
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public void onAnimationCancel(Animator animator) {
            this.f4926a = true;
        }

        @Override // android.animation.AnimatorListenerAdapter, android.animation.Animator.AnimatorListener
        public void onAnimationEnd(Animator animator) {
            if (this.f4926a) {
                return;
            }
            androidx.core.view.y.y0(this.f4927b, this.f4928c);
            c0.f(this.f4927b, this.f4929d, this.f4930e, this.f4931f, this.f4932g);
        }
    }

    /* JADX INFO: compiled from: ChangeBounds.java */
    class j extends n {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        boolean f4933a = false;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        final /* synthetic */ ViewGroup f4934b;

        j(c cVar, ViewGroup viewGroup) {
            this.f4934b = viewGroup;
        }

        @Override // j0.n, j0.m.f
        public void a(m mVar) {
            x.c(this.f4934b, false);
            this.f4933a = true;
        }

        @Override // j0.n, j0.m.f
        public void c(m mVar) {
            x.c(this.f4934b, true);
        }

        @Override // j0.n, j0.m.f
        public void d(m mVar) {
            x.c(this.f4934b, false);
        }

        @Override // j0.m.f
        public void e(m mVar) {
            if (!this.f4933a) {
                x.c(this.f4934b, false);
            }
            mVar.P(this);
        }
    }

    /* JADX INFO: compiled from: ChangeBounds.java */
    private static class k {

        /* JADX INFO: renamed from: a, reason: collision with root package name */
        private int f4935a;

        /* JADX INFO: renamed from: b, reason: collision with root package name */
        private int f4936b;

        /* JADX INFO: renamed from: c, reason: collision with root package name */
        private int f4937c;

        /* JADX INFO: renamed from: d, reason: collision with root package name */
        private int f4938d;

        /* JADX INFO: renamed from: e, reason: collision with root package name */
        private View f4939e;

        /* JADX INFO: renamed from: f, reason: collision with root package name */
        private int f4940f;

        /* JADX INFO: renamed from: g, reason: collision with root package name */
        private int f4941g;

        k(View view) {
            this.f4939e = view;
        }

        private void b() {
            c0.f(this.f4939e, this.f4935a, this.f4936b, this.f4937c, this.f4938d);
            this.f4940f = 0;
            this.f4941g = 0;
        }

        void a(PointF pointF) {
            this.f4937c = Math.round(pointF.x);
            this.f4938d = Math.round(pointF.y);
            int i3 = this.f4941g + 1;
            this.f4941g = i3;
            if (this.f4940f == i3) {
                b();
            }
        }

        void c(PointF pointF) {
            this.f4935a = Math.round(pointF.x);
            this.f4936b = Math.round(pointF.y);
            int i3 = this.f4940f + 1;
            this.f4940f = i3;
            if (i3 == this.f4941g) {
                b();
            }
        }
    }

    private void c0(s sVar) {
        View view = sVar.f5039b;
        if (!androidx.core.view.y.V(view) && view.getWidth() == 0 && view.getHeight() == 0) {
            return;
        }
        sVar.f5038a.put("android:changeBounds:bounds", new Rect(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()));
        sVar.f5038a.put("android:changeBounds:parent", sVar.f5039b.getParent());
        if (this.P) {
            sVar.f5039b.getLocationInWindow(this.N);
            sVar.f5038a.put("android:changeBounds:windowX", Integer.valueOf(this.N[0]));
            sVar.f5038a.put("android:changeBounds:windowY", Integer.valueOf(this.N[1]));
        }
        if (this.O) {
            sVar.f5038a.put("android:changeBounds:clip", androidx.core.view.y.w(view));
        }
    }

    private boolean d0(View view, View view2) {
        if (!this.P) {
            return true;
        }
        s sVarT = t(view, true);
        if (sVarT == null) {
            if (view == view2) {
                return true;
            }
        } else if (view2 == sVarT.f5039b) {
            return true;
        }
        return false;
    }

    @Override // j0.m
    public String[] D() {
        return Q;
    }

    @Override // j0.m
    public void g(s sVar) {
        c0(sVar);
    }

    @Override // j0.m
    public void j(s sVar) {
        c0(sVar);
    }

    @Override // j0.m
    public Animator n(ViewGroup viewGroup, s sVar, s sVar2) {
        int i3;
        View view;
        int i4;
        Rect rect;
        ObjectAnimator objectAnimator;
        Animator animatorC;
        if (sVar == null || sVar2 == null) {
            return null;
        }
        Map<String, Object> map = sVar.f5038a;
        Map<String, Object> map2 = sVar2.f5038a;
        ViewGroup viewGroup2 = (ViewGroup) map.get("android:changeBounds:parent");
        ViewGroup viewGroup3 = (ViewGroup) map2.get("android:changeBounds:parent");
        if (viewGroup2 == null || viewGroup3 == null) {
            return null;
        }
        View view2 = sVar2.f5039b;
        if (!d0(viewGroup2, viewGroup3)) {
            int iIntValue = ((Integer) sVar.f5038a.get("android:changeBounds:windowX")).intValue();
            int iIntValue2 = ((Integer) sVar.f5038a.get("android:changeBounds:windowY")).intValue();
            int iIntValue3 = ((Integer) sVar2.f5038a.get("android:changeBounds:windowX")).intValue();
            int iIntValue4 = ((Integer) sVar2.f5038a.get("android:changeBounds:windowY")).intValue();
            if (iIntValue == iIntValue3 && iIntValue2 == iIntValue4) {
                return null;
            }
            viewGroup.getLocationInWindow(this.N);
            Bitmap bitmapCreateBitmap = Bitmap.createBitmap(view2.getWidth(), view2.getHeight(), Bitmap.Config.ARGB_8888);
            view2.draw(new Canvas(bitmapCreateBitmap));
            BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmapCreateBitmap);
            float fC = c0.c(view2);
            c0.g(view2, 0.0f);
            c0.b(viewGroup).b(bitmapDrawable);
            j0.g gVarV = v();
            int[] iArr = this.N;
            ObjectAnimator objectAnimatorOfPropertyValuesHolder = ObjectAnimator.ofPropertyValuesHolder(bitmapDrawable, j0.i.a(R, gVarV.a(iIntValue - iArr[0], iIntValue2 - iArr[1], iIntValue3 - iArr[0], iIntValue4 - iArr[1])));
            objectAnimatorOfPropertyValuesHolder.addListener(new a(this, viewGroup, bitmapDrawable, view2, fC));
            return objectAnimatorOfPropertyValuesHolder;
        }
        Rect rect2 = (Rect) sVar.f5038a.get("android:changeBounds:bounds");
        Rect rect3 = (Rect) sVar2.f5038a.get("android:changeBounds:bounds");
        int i5 = rect2.left;
        int i6 = rect3.left;
        int i7 = rect2.top;
        int i8 = rect3.top;
        int i9 = rect2.right;
        int i10 = rect3.right;
        int i11 = rect2.bottom;
        int i12 = rect3.bottom;
        int i13 = i9 - i5;
        int i14 = i11 - i7;
        int i15 = i10 - i6;
        int i16 = i12 - i8;
        Rect rect4 = (Rect) sVar.f5038a.get("android:changeBounds:clip");
        Rect rect5 = (Rect) sVar2.f5038a.get("android:changeBounds:clip");
        if ((i13 == 0 || i14 == 0) && (i15 == 0 || i16 == 0)) {
            i3 = 0;
        } else {
            i3 = (i5 == i6 && i7 == i8) ? 0 : 1;
            if (i9 != i10 || i11 != i12) {
                i3++;
            }
        }
        if ((rect4 != null && !rect4.equals(rect5)) || (rect4 == null && rect5 != null)) {
            i3++;
        }
        if (i3 <= 0) {
            return null;
        }
        if (this.O) {
            view = view2;
            c0.f(view, i5, i7, Math.max(i13, i15) + i5, Math.max(i14, i16) + i7);
            ObjectAnimator objectAnimatorA = (i5 == i6 && i7 == i8) ? null : j0.f.a(view, W, v().a(i5, i7, i6, i8));
            if (rect4 == null) {
                i4 = 0;
                rect = new Rect(0, 0, i13, i14);
            } else {
                i4 = 0;
                rect = rect4;
            }
            Rect rect6 = rect5 == null ? new Rect(i4, i4, i15, i16) : rect5;
            if (rect.equals(rect6)) {
                objectAnimator = null;
            } else {
                androidx.core.view.y.y0(view, rect);
                j0.k kVar = X;
                Object[] objArr = new Object[2];
                objArr[i4] = rect;
                objArr[1] = rect6;
                ObjectAnimator objectAnimatorOfObject = ObjectAnimator.ofObject(view, "clipBounds", kVar, objArr);
                objectAnimatorOfObject.addListener(new i(this, view, rect5, i6, i8, i10, i12));
                objectAnimator = objectAnimatorOfObject;
            }
            animatorC = r.c(objectAnimatorA, objectAnimator);
        } else {
            view = view2;
            c0.f(view, i5, i7, i9, i11);
            if (i3 != 2) {
                animatorC = (i5 == i6 && i7 == i8) ? j0.f.a(view, U, v().a(i9, i11, i10, i12)) : j0.f.a(view, V, v().a(i5, i7, i6, i8));
            } else if (i13 == i15 && i14 == i16) {
                animatorC = j0.f.a(view, W, v().a(i5, i7, i6, i8));
            } else {
                k kVar2 = new k(view);
                ObjectAnimator objectAnimatorA2 = j0.f.a(kVar2, S, v().a(i5, i7, i6, i8));
                ObjectAnimator objectAnimatorA3 = j0.f.a(kVar2, T, v().a(i9, i11, i10, i12));
                AnimatorSet animatorSet = new AnimatorSet();
                animatorSet.playTogether(objectAnimatorA2, objectAnimatorA3);
                animatorSet.addListener(new h(this, kVar2));
                animatorC = animatorSet;
            }
        }
        if (view.getParent() instanceof ViewGroup) {
            ViewGroup viewGroup4 = (ViewGroup) view.getParent();
            x.c(viewGroup4, true);
            a(new j(this, viewGroup4));
        }
        return animatorC;
    }
}
