diff options
Diffstat (limited to 'core/java/android/os')
| -rw-r--r-- | core/java/android/os/Parcel.java | 3 | ||||
| -rw-r--r-- | core/java/android/os/Parcelable.java | 18 |
2 files changed, 21 insertions, 0 deletions
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java index 6b35215..e9ed676 100644 --- a/core/java/android/os/Parcel.java +++ b/core/java/android/os/Parcel.java @@ -1980,6 +1980,9 @@ public final class Parcel { } } + if (creator instanceof Parcelable.ClassLoaderCreator<?>) { + return ((Parcelable.ClassLoaderCreator<T>)creator).createFromParcel(this, loader); + } return creator.createFromParcel(this); } diff --git a/core/java/android/os/Parcelable.java b/core/java/android/os/Parcelable.java index 0a4b60f..594fbb2 100644 --- a/core/java/android/os/Parcelable.java +++ b/core/java/android/os/Parcelable.java @@ -113,4 +113,22 @@ public interface Parcelable { */ public T[] newArray(int size); } + + /** + * Specialization of {@link Creator} that allows you to receive the + * ClassLoader the object is being created in. + */ + public interface ClassLoaderCreator<T> extends Creator<T> { + /** + * Create a new instance of the Parcelable class, instantiating it + * from the given Parcel whose data had previously been written by + * {@link Parcelable#writeToParcel Parcelable.writeToParcel()} and + * using the given ClassLoader. + * + * @param source The Parcel to read the object's data from. + * @param loader The ClassLoader that this object is being created in. + * @return Returns a new instance of the Parcelable class. + */ + public T createFromParcel(Parcel source, ClassLoader loader); + } } |
