package defpackage;

import android.content.Context;
import android.content.res.TypedArray;
import android.content.res.XmlResourceParser;
import android.graphics.Rect;
import android.util.Log;
import android.util.Xml;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.AnimationUtils;
import android.view.animation.AnticipateInterpolator;
import android.view.animation.BounceInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.OvershootInterpolator;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.constraintlayout.widget.e;
import androidx.constraintlayout.widget.j;
import androidx.credentials.exceptions.publickeycredential.DomExceptionUtils;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import org.xmlpull.v1.XmlPullParserException;

/* JADX INFO: loaded from: classes.dex */
public class ila {
    public int a;
    public int e;
    public final g35 f;
    public final e.a g;
    public int j;
    public String k;
    public final Context o;
    public int b = -1;
    public boolean c = false;
    public int d = 0;
    public int h = -1;
    public int i = -1;
    public int l = 0;
    public String m = null;
    public int n = -1;
    public int p = -1;
    public int q = -1;
    public int r = -1;
    public int s = -1;
    public int t = -1;
    public int u = -1;

    public static class a {
        public final int a;
        public final int b;
        public final x96 c;
        public final int d;
        public final y25 e;
        public final lla f;
        public final Interpolator g;
        public boolean h;
        public float i;
        public float j;
        public long k;
        public final Rect l;
        public final boolean m;

        public a(lla llaVar, x96 x96Var, int i, int i2, int i3, Interpolator interpolator, int i4, int i5) {
            y25 y25Var = new y25();
            y25Var.a = new HashMap();
            this.e = y25Var;
            this.h = false;
            this.l = new Rect();
            this.m = false;
            this.f = llaVar;
            this.c = x96Var;
            this.d = i2;
            this.k = System.nanoTime();
            if (llaVar.e == null) {
                llaVar.e = new ArrayList();
            }
            llaVar.e.add(this);
            this.g = interpolator;
            this.a = i4;
            this.b = i5;
            if (i3 == 3) {
                this.m = true;
            }
            this.j = i == 0 ? Float.MAX_VALUE : 1.0f / i;
            a();
        }

        public final void a() {
            boolean z = this.h;
            int i = this.b;
            int i2 = this.a;
            Interpolator interpolator = this.g;
            lla llaVar = this.f;
            x96 x96Var = this.c;
            if (!z) {
                long jNanoTime = System.nanoTime();
                long j = jNanoTime - this.k;
                this.k = jNanoTime;
                float f = (((float) (j * 1.0E-6d)) * this.j) + this.i;
                this.i = f;
                if (f >= 1.0f) {
                    this.i = 1.0f;
                }
                boolean zB = x96Var.b(interpolator == null ? this.i : interpolator.getInterpolation(this.i), jNanoTime, this.e, x96Var.a);
                if (this.i >= 1.0f) {
                    if (i2 != -1) {
                        x96Var.a.setTag(i2, Long.valueOf(System.nanoTime()));
                    }
                    if (i != -1) {
                        x96Var.a.setTag(i, null);
                    }
                    if (!this.m) {
                        llaVar.f.add(this);
                    }
                }
                if (this.i < 1.0f || zB) {
                    llaVar.a.invalidate();
                    return;
                }
                return;
            }
            long jNanoTime2 = System.nanoTime();
            long j2 = jNanoTime2 - this.k;
            this.k = jNanoTime2;
            float f2 = this.i - (((float) (j2 * 1.0E-6d)) * this.j);
            this.i = f2;
            if (f2 < 0.0f) {
                this.i = 0.0f;
            }
            float interpolation = this.i;
            if (interpolator != null) {
                interpolation = interpolator.getInterpolation(interpolation);
            }
            boolean zB2 = x96Var.b(interpolation, jNanoTime2, this.e, x96Var.a);
            if (this.i <= 0.0f) {
                if (i2 != -1) {
                    x96Var.a.setTag(i2, Long.valueOf(System.nanoTime()));
                }
                if (i != -1) {
                    x96Var.a.setTag(i, null);
                }
                llaVar.f.add(this);
            }
            if (this.i > 0.0f || zB2) {
                llaVar.a.invalidate();
            }
        }

        public final void b() {
            this.h = true;
            int i = this.d;
            if (i != -1) {
                this.j = i == 0 ? Float.MAX_VALUE : 1.0f / i;
            }
            this.f.a.invalidate();
            this.k = System.nanoTime();
        }
    }

    /* JADX WARN: Failed to restore switch over string. Please report as a decompilation issue */
    /* JADX WARN: Removed duplicated region for block: B:36:0x0095 A[Catch: IOException -> 0x0041, XmlPullParserException -> 0x0044, TryCatch #2 {IOException -> 0x0041, XmlPullParserException -> 0x0044, blocks: (B:3:0x0024, B:11:0x0035, B:37:0x00c8, B:18:0x0047, B:19:0x004f, B:36:0x0095, B:21:0x0053, B:26:0x0064, B:24:0x005c, B:27:0x006c, B:29:0x0072, B:30:0x0076, B:32:0x007e, B:33:0x0086, B:35:0x008e), top: B:42:0x0024 }] */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
    */
    public ila(Context context, XmlResourceParser xmlResourceParser) {
        this.o = context;
        try {
            int eventType = xmlResourceParser.getEventType();
            while (eventType != 1) {
                if (eventType == 2) {
                    String name = xmlResourceParser.getName();
                    switch (name.hashCode()) {
                        case -1962203927:
                            if (!name.equals("ConstraintOverride")) {
                                Log.e("ViewTransition", cw1.a() + " unknown tag " + name);
                                StringBuilder sb = new StringBuilder();
                                sb.append(".xml:");
                                sb.append(xmlResourceParser.getLineNumber());
                                Log.e("ViewTransition", sb.toString());
                            } else {
                                this.g = e.e(context, xmlResourceParser);
                            }
                            break;
                        case -1239391468:
                            if (name.equals("KeyFrameSet")) {
                                this.f = new g35(context, xmlResourceParser);
                                break;
                            }
                            break;
                        case 61998586:
                            if (name.equals("ViewTransition")) {
                                d(context, xmlResourceParser);
                                break;
                            }
                            break;
                        case 366511058:
                            if (name.equals("CustomMethod")) {
                                androidx.constraintlayout.widget.a.d(context, xmlResourceParser, this.g.g);
                                break;
                            }
                            break;
                        case 1791837707:
                            if (name.equals("CustomAttribute")) {
                                androidx.constraintlayout.widget.a.d(context, xmlResourceParser, this.g.g);
                            }
                            Log.e("ViewTransition", cw1.a() + " unknown tag " + name);
                            StringBuilder sb2 = new StringBuilder();
                            sb2.append(".xml:");
                            sb2.append(xmlResourceParser.getLineNumber());
                            Log.e("ViewTransition", sb2.toString());
                            break;
                        default:
                            Log.e("ViewTransition", cw1.a() + " unknown tag " + name);
                            StringBuilder sb22 = new StringBuilder();
                            sb22.append(".xml:");
                            sb22.append(xmlResourceParser.getLineNumber());
                            Log.e("ViewTransition", sb22.toString());
                            break;
                    }
                } else if (eventType != 3) {
                    continue;
                } else if ("ViewTransition".equals(xmlResourceParser.getName())) {
                    return;
                }
                eventType = xmlResourceParser.next();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } catch (XmlPullParserException e2) {
            e2.printStackTrace();
        }
    }

    public final void a(lla llaVar, oa6 oa6Var, int i, e eVar, View... viewArr) {
        Interpolator interpolatorLoadInterpolator;
        if (this.c) {
            return;
        }
        int i2 = this.e;
        if (i2 != 2) {
            e.a aVar = this.g;
            if (i2 == 1) {
                for (int i3 : oa6Var.getConstraintSetIds()) {
                    if (i3 != i) {
                        ta6 ta6Var = oa6Var.a;
                        e eVarB = ta6Var == null ? null : ta6Var.b(i3);
                        for (View view : viewArr) {
                            e.a aVarI = eVarB.i(view.getId());
                            if (aVar != null) {
                                aVar.a(aVarI);
                                aVarI.g.putAll(aVar.g);
                            }
                        }
                    }
                }
            }
            e eVar2 = new e();
            HashMap map = eVar2.e;
            map.clear();
            for (Integer num : eVar.e.keySet()) {
                e.a aVar2 = (e.a) eVar.e.get(num);
                if (aVar2 != null) {
                    map.put(num, aVar2.clone());
                }
            }
            for (View view2 : viewArr) {
                e.a aVarI2 = eVar2.i(view2.getId());
                if (aVar != null) {
                    aVar.a(aVarI2);
                    aVarI2.g.putAll(aVar.g);
                }
            }
            ta6 ta6Var2 = oa6Var.a;
            if (ta6Var2 != null) {
                ta6Var2.g.put(i, eVar2);
            }
            oa6Var.a.b(oa6Var.d);
            oa6Var.a.b(oa6Var.f);
            throw null;
        }
        View view3 = viewArr[0];
        x96 x96Var = new x96();
        new Rect();
        x96Var.b = false;
        x96Var.c = -1;
        pa6 pa6Var = new pa6();
        x96Var.d = pa6Var;
        pa6 pa6Var2 = new pa6();
        x96Var.e = pa6Var2;
        t96 t96Var = new t96();
        x96Var.f = t96Var;
        t96 t96Var2 = new t96();
        x96Var.g = t96Var2;
        x96Var.j = 1.0f;
        x96Var.p = new float[4];
        x96Var.q = new ArrayList();
        ArrayList arrayList = new ArrayList();
        x96Var.r = arrayList;
        x96Var.w = -1;
        x96Var.x = -1;
        x96Var.y = null;
        x96Var.z = -1;
        x96Var.aa = Float.NaN;
        x96Var.ab = null;
        x96Var.ac = false;
        x96Var.a = view3;
        view3.getId();
        view3.getLayoutParams();
        pa6Var.b = 0.0f;
        pa6Var.c = 0.0f;
        x96Var.ac = true;
        float x = view3.getX();
        Interpolator interpolator = null;
        float y = view3.getY();
        float width = view3.getWidth();
        float height = view3.getHeight();
        pa6Var.d = x;
        pa6Var.e = y;
        pa6Var.f = width;
        pa6Var.i = height;
        float x2 = view3.getX();
        float y2 = view3.getY();
        float width2 = view3.getWidth();
        float height2 = view3.getHeight();
        pa6Var2.d = x2;
        pa6Var2.e = y2;
        pa6Var2.f = width2;
        pa6Var2.i = height2;
        view3.getX();
        view3.getY();
        view3.getWidth();
        view3.getHeight();
        t96Var.c = view3.getVisibility();
        t96Var.a = view3.getVisibility() != 0 ? 0.0f : view3.getAlpha();
        t96Var.d = view3.getElevation();
        t96Var.e = view3.getRotation();
        t96Var.f = view3.getRotationX();
        t96Var.i = view3.getRotationY();
        t96Var.j = view3.getScaleX();
        t96Var.k = view3.getScaleY();
        t96Var.l = view3.getPivotX();
        t96Var.m = view3.getPivotY();
        t96Var.n = view3.getTranslationX();
        t96Var.o = view3.getTranslationY();
        t96Var.p = view3.getTranslationZ();
        view3.getX();
        view3.getY();
        view3.getWidth();
        view3.getHeight();
        t96Var2.c = view3.getVisibility();
        t96Var2.a = view3.getVisibility() != 0 ? 0.0f : view3.getAlpha();
        t96Var2.d = view3.getElevation();
        t96Var2.e = view3.getRotation();
        t96Var2.f = view3.getRotationX();
        t96Var2.i = view3.getRotationY();
        t96Var2.j = view3.getScaleX();
        t96Var2.k = view3.getScaleY();
        t96Var2.l = view3.getPivotX();
        t96Var2.m = view3.getPivotY();
        t96Var2.n = view3.getTranslationX();
        t96Var2.o = view3.getTranslationY();
        t96Var2.p = view3.getTranslationZ();
        ArrayList arrayList2 = (ArrayList) this.f.a.get(-1);
        if (arrayList2 != null) {
            arrayList.addAll(arrayList2);
        }
        x96Var.c(oa6Var.getWidth(), oa6Var.getHeight(), System.nanoTime());
        int i4 = this.h;
        int i5 = this.i;
        int i6 = this.b;
        Context context = oa6Var.getContext();
        int i7 = this.l;
        if (i7 == -2) {
            interpolatorLoadInterpolator = AnimationUtils.loadInterpolator(context, this.n);
        } else if (i7 == -1) {
            interpolatorLoadInterpolator = new hla(ph2.b(this.m));
        } else if (i7 == 0) {
            interpolatorLoadInterpolator = new AccelerateDecelerateInterpolator();
        } else if (i7 == 1) {
            interpolatorLoadInterpolator = new AccelerateInterpolator();
        } else if (i7 == 2) {
            interpolatorLoadInterpolator = new DecelerateInterpolator();
        } else if (i7 == 4) {
            interpolatorLoadInterpolator = new BounceInterpolator();
        } else {
            if (i7 != 5) {
                if (i7 == 6) {
                    interpolatorLoadInterpolator = new AnticipateInterpolator();
                }
                new a(llaVar, x96Var, i4, i5, i6, interpolator, this.p, this.q);
            }
            interpolatorLoadInterpolator = new OvershootInterpolator();
        }
        interpolator = interpolatorLoadInterpolator;
        new a(llaVar, x96Var, i4, i5, i6, interpolator, this.p, this.q);
    }

    public final boolean b(View view) {
        int i = this.r;
        boolean z = i == -1 || view.getTag(i) != null;
        int i2 = this.s;
        return z && (i2 == -1 || view.getTag(i2) == null);
    }

    public final boolean c(View view) {
        String str;
        if (view == null) {
            return false;
        }
        if ((this.j == -1 && this.k == null) || !b(view)) {
            return false;
        }
        if (view.getId() == this.j) {
            return true;
        }
        return this.k != null && (view.getLayoutParams() instanceof ConstraintLayout.b) && (str = ((ConstraintLayout.b) view.getLayoutParams()).ay) != null && str.matches(this.k);
    }

    public final void d(Context context, XmlResourceParser xmlResourceParser) {
        TypedArray typedArrayObtainStyledAttributes = context.obtainStyledAttributes(Xml.asAttributeSet(xmlResourceParser), j.m.w);
        int indexCount = typedArrayObtainStyledAttributes.getIndexCount();
        for (int i = 0; i < indexCount; i++) {
            int index = typedArrayObtainStyledAttributes.getIndex(i);
            if (index == 0) {
                this.a = typedArrayObtainStyledAttributes.getResourceId(index, this.a);
            } else if (index == 8) {
                int i2 = oa6.ar;
                if (typedArrayObtainStyledAttributes.peekValue(index).type == 3) {
                    this.k = typedArrayObtainStyledAttributes.getString(index);
                } else {
                    this.j = typedArrayObtainStyledAttributes.getResourceId(index, this.j);
                }
            } else if (index == 9) {
                this.b = typedArrayObtainStyledAttributes.getInt(index, this.b);
            } else if (index == 12) {
                this.c = typedArrayObtainStyledAttributes.getBoolean(index, this.c);
            } else if (index == 10) {
                this.d = typedArrayObtainStyledAttributes.getInt(index, this.d);
            } else if (index == 4) {
                this.h = typedArrayObtainStyledAttributes.getInt(index, this.h);
            } else if (index == 13) {
                this.i = typedArrayObtainStyledAttributes.getInt(index, this.i);
            } else if (index == 14) {
                this.e = typedArrayObtainStyledAttributes.getInt(index, this.e);
            } else if (index == 7) {
                int i3 = typedArrayObtainStyledAttributes.peekValue(index).type;
                if (i3 == 1) {
                    int resourceId = typedArrayObtainStyledAttributes.getResourceId(index, -1);
                    this.n = resourceId;
                    if (resourceId != -1) {
                        this.l = -2;
                    }
                } else if (i3 == 3) {
                    String string = typedArrayObtainStyledAttributes.getString(index);
                    this.m = string;
                    if (string == null || string.indexOf(DomExceptionUtils.SEPARATOR) <= 0) {
                        this.l = -1;
                    } else {
                        this.n = typedArrayObtainStyledAttributes.getResourceId(index, -1);
                        this.l = -2;
                    }
                } else {
                    this.l = typedArrayObtainStyledAttributes.getInteger(index, this.l);
                }
            } else if (index == 11) {
                this.p = typedArrayObtainStyledAttributes.getResourceId(index, this.p);
            } else if (index == 3) {
                this.q = typedArrayObtainStyledAttributes.getResourceId(index, this.q);
            } else if (index == 6) {
                this.r = typedArrayObtainStyledAttributes.getResourceId(index, this.r);
            } else if (index == 5) {
                this.s = typedArrayObtainStyledAttributes.getResourceId(index, this.s);
            } else if (index == 2) {
                this.u = typedArrayObtainStyledAttributes.getResourceId(index, this.u);
            } else if (index == 1) {
                this.t = typedArrayObtainStyledAttributes.getInteger(index, this.t);
            }
        }
        typedArrayObtainStyledAttributes.recycle();
    }

    public final String toString() {
        return "ViewTransition(" + cw1.b(this.o, this.a) + ")";
    }
}
