package ῲ.ᓆ;

import android.animation.Animator;
import android.animation.AnimatorSet;
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;

/* renamed from: ῲ.ᓆ.ؿ  reason: contains not printable characters */
/* compiled from: TransitionUtils */
public class C1632 {

    /* renamed from: ʬ  reason: contains not printable characters */
    public static final boolean f5849;

    /* renamed from: ῲ  reason: contains not printable characters */
    public static final boolean f5850 = true;

    /* renamed from: K  reason: contains not printable characters */
    public static final boolean f5851 = true;

    static {
        int i = Build.VERSION.SDK_INT;
        boolean z = true;
        if (i < 28) {
            z = false;
        }
        f5849 = z;
    }

    /* JADX WARNING: Removed duplicated region for block: B:18:0x00d1  */
    /* JADX WARNING: Removed duplicated region for block: B:19:0x00e8  */
    /* JADX WARNING: Removed duplicated region for block: B:25:0x010b  */
    /* renamed from: K  reason: contains not printable characters */
    public static View m4213(ViewGroup viewGroup, View view, View view2) {
        boolean z;
        boolean z2;
        Bitmap bitmap;
        ViewGroup viewGroup2;
        int round;
        int round2;
        Matrix matrix = new Matrix();
        matrix.setTranslate((float) (-view2.getScrollX()), (float) (-view2.getScrollY()));
        C1669.f5917.m4247(view, matrix);
        C1669.f5917.m4242(viewGroup, matrix);
        RectF rectF = new RectF(0.0f, 0.0f, (float) view.getWidth(), (float) view.getHeight());
        matrix.mapRect(rectF);
        int round3 = Math.round(rectF.left);
        int round4 = Math.round(rectF.top);
        int round5 = Math.round(rectF.right);
        int round6 = Math.round(rectF.bottom);
        ImageView imageView = new ImageView(view.getContext());
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        int i = 0;
        if (f5851) {
            z2 = !view.isAttachedToWindow();
            if (viewGroup != null) {
                z = viewGroup.isAttachedToWindow();
                bitmap = null;
                if (f5850 || !z2) {
                    viewGroup2 = null;
                } else {
                    if (z) {
                        ViewGroup viewGroup3 = (ViewGroup) view.getParent();
                        int indexOfChild = viewGroup3.indexOfChild(view);
                        viewGroup.getOverlay().add(view);
                        viewGroup2 = viewGroup3;
                        i = indexOfChild;
                    }
                    if (bitmap != null) {
                        imageView.setImageBitmap(bitmap);
                    }
                    imageView.measure(View.MeasureSpec.makeMeasureSpec(round5 - round3, 1073741824), View.MeasureSpec.makeMeasureSpec(round6 - round4, 1073741824));
                    imageView.layout(round3, round4, round5, round6);
                    return imageView;
                }
                round = Math.round(rectF.width());
                round2 = Math.round(rectF.height());
                if (round > 0 && round2 > 0) {
                    float min = Math.min(1.0f, 1048576.0f / ((float) (round * round2)));
                    int round7 = Math.round(((float) round) * min);
                    int round8 = Math.round(((float) round2) * min);
                    matrix.postTranslate(-rectF.left, -rectF.top);
                    matrix.postScale(min, min);
                    if (!f5849) {
                        Picture picture = new Picture();
                        Canvas beginRecording = picture.beginRecording(round7, round8);
                        beginRecording.concat(matrix);
                        view.draw(beginRecording);
                        picture.endRecording();
                        bitmap = Bitmap.createBitmap(picture);
                    } else {
                        bitmap = Bitmap.createBitmap(round7, round8, Bitmap.Config.ARGB_8888);
                        Canvas canvas = new Canvas(bitmap);
                        canvas.concat(matrix);
                        view.draw(canvas);
                    }
                }
                if (f5850 && z2) {
                    viewGroup.getOverlay().remove(view);
                    viewGroup2.addView(view, i);
                }
                if (bitmap != null) {
                }
                imageView.measure(View.MeasureSpec.makeMeasureSpec(round5 - round3, 1073741824), View.MeasureSpec.makeMeasureSpec(round6 - round4, 1073741824));
                imageView.layout(round3, round4, round5, round6);
                return imageView;
            }
        } else {
            z2 = false;
        }
        z = false;
        bitmap = null;
        if (f5850) {
        }
        viewGroup2 = null;
        round = Math.round(rectF.width());
        round2 = Math.round(rectF.height());
        float min2 = Math.min(1.0f, 1048576.0f / ((float) (round * round2)));
        int round72 = Math.round(((float) round) * min2);
        int round82 = Math.round(((float) round2) * min2);
        matrix.postTranslate(-rectF.left, -rectF.top);
        matrix.postScale(min2, min2);
        if (!f5849) {
        }
        viewGroup.getOverlay().remove(view);
        viewGroup2.addView(view, i);
        if (bitmap != null) {
        }
        imageView.measure(View.MeasureSpec.makeMeasureSpec(round5 - round3, 1073741824), View.MeasureSpec.makeMeasureSpec(round6 - round4, 1073741824));
        imageView.layout(round3, round4, round5, round6);
        return imageView;
    }

    /* renamed from: K  reason: contains not printable characters */
    public static Animator m4212(Animator animator, Animator animator2) {
        if (animator == null) {
            return animator2;
        }
        if (animator2 == null) {
            return animator;
        }
        AnimatorSet animatorSet = new AnimatorSet();
        animatorSet.playTogether(animator, animator2);
        return animatorSet;
    }
}
