package X6FRs_4.JZJr_16;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.TypeEvaluator;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Picture;
import android.graphics.RectF;
import android.os.Build;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
/* compiled from: TransitionUtils.java */
/* loaded from: classes.dex */
public class RfjZ_21 {
    public static final boolean KQgRr5e_0;
    public static final boolean PGPF6hQ_2;
    public static final boolean QxJ9d_1;

    /* compiled from: TransitionUtils.java */
    /* loaded from: classes.dex */
    public static class KQgRr5e_0 implements TypeEvaluator<Matrix> {

        /* renamed from: KQgRr5e_0  reason: collision with other field name */
        public final float[] f590KQgRr5e_0 = new float[9];
        public final float[] QxJ9d_1 = new float[9];
        public final Matrix KQgRr5e_0 = new Matrix();

        @Override // android.animation.TypeEvaluator
        /* renamed from: KQgRr5e_0 */
        public Matrix evaluate(float f, Matrix matrix, Matrix matrix2) {
            matrix.getValues(this.f590KQgRr5e_0);
            matrix2.getValues(this.QxJ9d_1);
            for (int i = 0; i < 9; i++) {
                float[] fArr = this.QxJ9d_1;
                float f2 = fArr[i];
                float[] fArr2 = this.f590KQgRr5e_0;
                fArr[i] = fArr2[i] + ((f2 - fArr2[i]) * f);
            }
            this.KQgRr5e_0.setValues(this.QxJ9d_1);
            return this.KQgRr5e_0;
        }
    }

    static {
        KQgRr5e_0 = Build.VERSION.SDK_INT >= 19;
        QxJ9d_1 = Build.VERSION.SDK_INT >= 18;
        PGPF6hQ_2 = Build.VERSION.SDK_INT >= 28;
    }

    public static View KQgRr5e_0(ViewGroup viewGroup, View view, View view2) {
        Matrix matrix = new Matrix();
        matrix.setTranslate(-view2.getScrollX(), -view2.getScrollY());
        JXypC6_34.QxJ9d_1(view, matrix);
        JXypC6_34.PGPF6hQ_2(viewGroup, matrix);
        RectF rectF = new RectF(0.0f, 0.0f, view.getWidth(), view.getHeight());
        matrix.mapRect(rectF);
        int round = Math.round(rectF.left);
        int round2 = Math.round(rectF.top);
        int round3 = Math.round(rectF.right);
        int round4 = Math.round(rectF.bottom);
        ImageView imageView = new ImageView(view.getContext());
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        Bitmap KQgRr5e_02 = KQgRr5e_0(view, matrix, rectF, viewGroup);
        if (KQgRr5e_02 != null) {
            imageView.setImageBitmap(KQgRr5e_02);
        }
        imageView.measure(View.MeasureSpec.makeMeasureSpec(round3 - round, 1073741824), View.MeasureSpec.makeMeasureSpec(round4 - round2, 1073741824));
        imageView.layout(round, round2, round3, round4);
        return imageView;
    }

    /* JADX WARN: Removed duplicated region for block: B:22:0x0071  */
    /* JADX WARN: Removed duplicated region for block: B:23:0x0088  */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public static Bitmap KQgRr5e_0(View view, Matrix matrix, RectF rectF, ViewGroup viewGroup) {
        boolean z;
        boolean z2;
        ViewGroup viewGroup2;
        int i;
        int round;
        int round2;
        if (KQgRr5e_0) {
            z = !view.isAttachedToWindow();
            if (viewGroup != null) {
                z2 = viewGroup.isAttachedToWindow();
                Bitmap bitmap = null;
                if (QxJ9d_1 || !z) {
                    viewGroup2 = null;
                    i = 0;
                } else if (!z2) {
                    return null;
                } else {
                    viewGroup2 = (ViewGroup) view.getParent();
                    i = viewGroup2.indexOfChild(view);
                    viewGroup.getOverlay().add(view);
                }
                round = Math.round(rectF.width());
                round2 = Math.round(rectF.height());
                if (round > 0 && round2 > 0) {
                    float min = Math.min(1.0f, 1048576.0f / (round * round2));
                    int round3 = Math.round(round * min);
                    int round4 = Math.round(round2 * min);
                    matrix.postTranslate(-rectF.left, -rectF.top);
                    matrix.postScale(min, min);
                    if (!PGPF6hQ_2) {
                        Picture picture = new Picture();
                        Canvas beginRecording = picture.beginRecording(round3, round4);
                        beginRecording.concat(matrix);
                        view.draw(beginRecording);
                        picture.endRecording();
                        bitmap = Bitmap.createBitmap(picture);
                    } else {
                        bitmap = Bitmap.createBitmap(round3, round4, Bitmap.Config.ARGB_8888);
                        Canvas canvas = new Canvas(bitmap);
                        canvas.concat(matrix);
                        view.draw(canvas);
                    }
                }
                if (QxJ9d_1 && z) {
                    viewGroup.getOverlay().remove(view);
                    viewGroup2.addView(view, i);
                }
                return bitmap;
            }
        } else {
            z = false;
        }
        z2 = false;
        Bitmap bitmap2 = null;
        if (QxJ9d_1) {
        }
        viewGroup2 = null;
        i = 0;
        round = Math.round(rectF.width());
        round2 = Math.round(rectF.height());
        if (round > 0) {
            float min2 = Math.min(1.0f, 1048576.0f / (round * round2));
            int round32 = Math.round(round * min2);
            int round42 = Math.round(round2 * min2);
            matrix.postTranslate(-rectF.left, -rectF.top);
            matrix.postScale(min2, min2);
            if (!PGPF6hQ_2) {
            }
        }
        if (QxJ9d_1) {
            viewGroup.getOverlay().remove(view);
            viewGroup2.addView(view, i);
        }
        return bitmap2;
    }

    public static Animator KQgRr5e_0(Animator animator, Animator animator2) {
        if (animator == null) {
            return animator2;
        }
        if (animator2 == null) {
            return animator;
        }
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(animator, animator2);
        return animatorSet;
    }
}
