package defpackage;

import android.content.Context;
import android.content.res.XmlResourceParser;
import android.util.Log;
import android.util.Xml;
import androidx.constraintlayout.widget.a;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.HashMap;
import org.xmlpull.v1.XmlPullParserException;

/* JADX INFO: loaded from: classes.dex */
public class g35 {
    public static final HashMap b;
    public final HashMap a = new HashMap();

    static {
        HashMap map = new HashMap();
        b = map;
        try {
            map.put("KeyAttribute", x25.class.getConstructor(null));
            map.put("KeyPosition", l35.class.getConstructor(null));
            map.put("KeyCycle", z25.class.getConstructor(null));
            map.put("KeyTimeCycle", n35.class.getConstructor(null));
            map.put("KeyTrigger", o35.class.getConstructor(null));
        } catch (NoSuchMethodException e) {
            Log.e("KeyFrames", "unable to load", e);
        }
    }

    public g35(Context context, XmlResourceParser xmlResourceParser) {
        Exception e;
        w25 w25Var;
        Constructor constructor;
        HashMap map;
        HashMap map2;
        try {
            int eventType = xmlResourceParser.getEventType();
            w25 w25Var2 = null;
            while (eventType != 1) {
                if (eventType == 2) {
                    String name = xmlResourceParser.getName();
                    HashMap map3 = b;
                    if (map3.containsKey(name)) {
                        try {
                            constructor = (Constructor) map3.get(name);
                        } catch (Exception e2) {
                            w25 w25Var3 = w25Var2;
                            e = e2;
                            w25Var = w25Var3;
                        }
                        if (constructor == null) {
                            throw new NullPointerException("Keymaker for " + name + " not found");
                        }
                        w25Var = (w25) constructor.newInstance(null);
                        try {
                            w25Var.d(context, Xml.asAttributeSet(xmlResourceParser));
                            HashMap map4 = this.a;
                            if (!map4.containsKey(Integer.valueOf(w25Var.b))) {
                                map4.put(Integer.valueOf(w25Var.b), new ArrayList());
                            }
                            ArrayList arrayList = (ArrayList) map4.get(Integer.valueOf(w25Var.b));
                            if (arrayList != null) {
                                arrayList.add(w25Var);
                            }
                        } catch (Exception e3) {
                            e = e3;
                            Log.e("KeyFrames", "unable to create ", e);
                        }
                        w25Var2 = w25Var;
                        Log.e("KeyFrames", "unable to create ", e);
                        w25Var2 = w25Var;
                    } else if (name.equalsIgnoreCase("CustomAttribute")) {
                        if (w25Var2 != null && (map2 = w25Var2.c) != null) {
                            a.d(context, xmlResourceParser, map2);
                        }
                    } else if (name.equalsIgnoreCase("CustomMethod") && w25Var2 != null && (map = w25Var2.c) != null) {
                        a.d(context, xmlResourceParser, map);
                    }
                } else if (eventType == 3 && "KeyFrameSet".equals(xmlResourceParser.getName())) {
                    return;
                }
                eventType = xmlResourceParser.next();
            }
        } catch (IOException e4) {
            e4.printStackTrace();
        } catch (XmlPullParserException e5) {
            e5.printStackTrace();
        }
    }
}
