Reputation: 486
I have a base generic abstract class, lets call it Base<T>
class.
This class extended by few subclass, with different types for T mData
.
Let's say that I have class Sub1 extends Base<byte []>
and class Sub2 extends Base<Object>
.
In addition, I have a instancesList with type of List<Base<T>>
, compounded from instances of Sub1
and Sub2
.
Parcelable
interface? Where does the CREATOR
goes, if any?Upvotes: 0
Views: 31
Reputation: 95626
Normally you implement the reader (CREATOR
) and the writer in the concrete classes, not in the abstract class.
When an instance of a concrete class is written to the Parcel
, the name of the concrete class is also automatically written to the Parcel
. When this is unparceled, the name of the concrete class is read, and the appropriate CREATOR
is called to create a new instance of that concrete class.
There are some situations where you need to implement the reader and writer in the abstract class. In that case see Parcelable inheritance: abstract class - Which CREATOR? for more complex solutions.
Upvotes: 0