You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
implement ObjectAnimator.ofInt() using reflection
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package android.animation;
|
package android.animation;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
import android.util.Property;
|
import android.util.Property;
|
||||||
|
|
||||||
@@ -25,7 +27,9 @@ public class ObjectAnimator extends ValueAnimator {
|
|||||||
return new ObjectAnimator();
|
return new ObjectAnimator();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> ObjectAnimator ofInt(T target, String propertyName, int... values) {
|
public static <T> ObjectAnimator ofInt(T target, String propertyName, int... values) throws ReflectiveOperationException {
|
||||||
|
Method setter = target.getClass().getMethod("set" + Character.toUpperCase(propertyName.charAt(0)) + propertyName.substring(1), int.class);
|
||||||
|
setter.invoke(target, values[values.length - 1]);
|
||||||
return new ObjectAnimator();
|
return new ObjectAnimator();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user