content: package androidx.constraintlayout.motion.widget;
  
  import android.content.Context;
  import android.util.Log;
  import android.util.Xml;
  import androidx.constraintlayout.core.motion.utils.TypedValues;
  import androidx.constraintlayout.widget.ConstraintAttribute;
  import androidx.constraintlayout.widget.ConstraintLayout;
  import java.io.IOException;
  import java.lang.reflect.Constructor;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.Set;
  import org.xmlpull.v1.XmlPullParser;
  import org.xmlpull.v1.XmlPullParserException;
  
  public class KeyFrames {
      private static final String CUSTOM_ATTRIBUTE = "CustomAttribute";
      private static final String CUSTOM_METHOD = "CustomMethod";
      private static final String TAG = "KeyFrames";
      public static final int UNSET = -1;
      static HashMap<String, Constructor<? extends Key>> sKeyMakers;
      private HashMap<Integer, ArrayList<Key>> mFramesMap = new HashMap<>();
  
      static {
          HashMap<String, Constructor<? extends Key>> hashMap = new HashMap<>();
          sKeyMakers = hashMap;
          try {
              hashMap.put("KeyAttribute", KeyAttributes.class.getConstructor(new Class[0]));
              sKeyMakers.put(TypedValues.PositionType.NAME, KeyPosition.class.getConstructor(new Class[0]));
              sKeyMakers.put(TypedValues.CycleType.NAME, KeyCycle.class.getConstructor(new Class[0]));
              sKeyMakers.put("KeyTimeCycle", KeyTimeCycle.class.getConstructor(new Class[0]));
              sKeyMakers.put(TypedValues.TriggerType.NAME, KeyTrigger.class.getConstructor(new Class[0]));
          } catch (NoSuchMethodException e) {
              Log.e(TAG, "unable to load", e);
          }
      }
  
      public KeyFrames() {
      }
  
      public KeyFrames(Context context, XmlPullParser parser) {
          Key key = null;
          try {
              int eventType = parser.getEventType();
              while (eventType != 1) {
                  switch (eventType) {
                      case 0:
                          break;
                      case 2:
                          String name = parser.getName();
                          if (!sKeyMakers.containsKey(name)) {
                              if (!name.equalsIgnoreCase("CustomAttribute")) {
                                  if (!(!name.equalsIgnoreCase("CustomMethod") || key == null || key.mCustomConstraints == null)) {
                                      ConstraintAttribute.parse(context, parser, key.mCustomConstraints);
                                      break;
                                  }
                              } else if (!(key == null || key.mCustomConstraints == null)) {
                                  ConstraintAttribute.parse(context, parser, key.mCustomConstraints);
                                  break;
                              }
                          } else {
                              try {
                                  Constructor constructor = sKeyMakers.get(name);
                                  if (constructor != null) {
                                      key = (Key) constructor.newInstance(new Object[0]);
                                      key.load(context, Xml.asAttributeSet(parser));
                                      addKey(key);
                                      break;
                                  } else {
                                      throw new NullPointerException("Keymaker for " + name + " not found");
                                  }
                              } catch (Exception e) {
                                  Log.e(TAG, "unable to create ", e);
                                  break;
                              }
                          }
                      case 3:
                          if (ViewTransition.KEY_FRAME_SET_TAG.equals(parser.getName())) {
                              return;
                          }
                          break;
                  }
                  eventType = parser.next();
              }
          } catch (XmlPullParserException e2) {
              e2.printStackTrace();
          } catch (IOException e3) {
              e3.printStackTrace();
          }
      }
  
      static String name(int viewId, Context context) {
          return context.getResources().getResourceEntryName(viewId);
      }
  
      public void addAllFrames(MotionController motionController) {
          ArrayList arrayList = this.mFramesMap.get(-1);
          if (arrayList != null) {
              motionController.addKeys(arrayList);
          }
      }
  
      public void addFrames(MotionController motionController) {
          ArrayList arrayList = this.mFramesMap.get(Integer.valueOf(motionController.mId));
          if (arrayList != null) {
              motionController.addKeys(arrayList);
          }
          ArrayList arrayList2 = this.mFramesMap.get(-1);
          if (arrayList2 != null) {
              Iterator it = arrayList2.iterator();
              while (it.hasNext()) {
                  Key key = (Key) it.next();
                  if (key.matches(((ConstraintLayout.LayoutParams) motionController.mView.getLayoutParams()).constraintTag)) {
                      motionController.addKey(key);
                  }
              }
          }
      }
  
      public void addKey(Key key) {
          if (!this.mFramesMap.containsKey(Integer.valueOf(key.mTargetId))) {
              this.mFramesMap.put(Integer.valueOf(key.mTargetId), new ArrayList());
          }
          ArrayList arrayList = this.mFramesMap.get(Integer.valueOf(key.mTargetId));
          if (arrayList != null) {
              arrayList.add(key);
          }
      }
  
      public ArrayList<Key> getKeyFramesForView(int id) {
          return this.mFramesMap.get(Integer.valueOf(id));
      }
  
      public Set<Integer> getKeys() {
          return this.mFramesMap.keySet();
      }
  }
  