mirror of
https://github.com/moparisthebest/android_external_SafeParcel
synced 2024-12-04 14:32:17 -05:00
Fix Parcelable[]
This commit is contained in:
parent
982f1e1285
commit
7d4dec14e8
@ -96,11 +96,18 @@ public class SafeParcelUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Parcelable.Creator getCreator(Field field) throws IllegalAccessException {
|
private static Parcelable.Creator getCreator(Field field) throws IllegalAccessException {
|
||||||
try {
|
Class clazz = field.getType();
|
||||||
return (Parcelable.Creator) field.getType().getDeclaredField("CREATOR").get(null);
|
if (clazz.isArray()) {
|
||||||
} catch (NoSuchFieldException e) {
|
clazz = clazz.getComponentType();
|
||||||
throw new RuntimeException(field.getType() + " is an Parcelable without CREATOR");
|
|
||||||
}
|
}
|
||||||
|
if (Parcelable.class.isAssignableFrom(clazz)) {
|
||||||
|
try {
|
||||||
|
return (Parcelable.Creator) clazz.getDeclaredField("CREATOR").get(null);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
throw new RuntimeException(clazz + " is an Parcelable without CREATOR");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException(clazz + " is not an Parcelable");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ClassLoader getClassLoader(Field field) {
|
private static ClassLoader getClassLoader(Field field) {
|
||||||
|
Loading…
Reference in New Issue
Block a user