Skip to content

Commit ce53566

Browse files
jafu888Gerrit Code Review
authored and
Gerrit Code Review
committed
Merge "Changed from reflection to direct calls to constructors. Test: N/A" into androidx-main
2 parents cc3c175 + 158bd20 commit ce53566

File tree

1 file changed

+22
-11
lines changed
  • constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget

1 file changed

+22
-11
lines changed

constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyFrames.java

+22-11
Original file line numberDiff line numberDiff line change
@@ -91,19 +91,30 @@ public KeyFrames(Context context, XmlPullParser parser) {
9191
tagName = parser.getName();
9292

9393
if (sKeyMakers.containsKey(tagName)) {
94-
try {
95-
Constructor<? extends Key> keyMaker = sKeyMakers.get(tagName);
96-
if (keyMaker != null) {
97-
key = keyMaker.newInstance();
98-
key.load(context, Xml.asAttributeSet(parser));
99-
addKey(key);
100-
} else {
94+
95+
switch (tagName) {
96+
case KeyAttributes.NAME:
97+
key = new KeyAttributes();
98+
break;
99+
case KeyPosition.NAME:
100+
key = new KeyPosition();
101+
break;
102+
case KeyCycle.NAME:
103+
key = new KeyCycle();
104+
break;
105+
case KeyTimeCycle.NAME:
106+
key = new KeyTimeCycle();
107+
break;
108+
case KeyTrigger.NAME:
109+
key = new KeyTrigger();
110+
break;
111+
default:
101112
throw new NullPointerException(
102-
"Keymaker for " + tagName + " not found");
103-
}
104-
} catch (Exception e) {
105-
Log.e(TAG, "unable to create ", e);
113+
"Key " + tagName + " not found");
106114
}
115+
key.load(context, Xml.asAttributeSet(parser));
116+
addKey(key);
117+
107118
} else if (tagName.equalsIgnoreCase(CUSTOM_ATTRIBUTE)) {
108119
if (key != null && key.mCustomConstraints != null) {
109120
ConstraintAttribute.parse(context, parser, key.mCustomConstraints);

0 commit comments

Comments
 (0)