I love this idea, and I may be missing something obvious, but I'm not certain this works if you have arrays of inherited classes that need to be parceled. Here's the setup I'm trying:
public class Instruction extends GlobalParcelable {
protected intID;
protected intOrdinal;
protected strDescription;
public Instruction(Integer id, Integer ordinal, String description) {
this.intID = id;
this.intOrdinal = ordinal;
this.strDescription = description;
}
//also has getters/setters
}
public class Setup extends Instruction {
public Setup(Integer id, Integer ordinal, String description) {
super(id, ordinal, description);
}
}
public class Step extends Instruction {
public Step(Integer id, Integer ordinal, String description) {
super(id, ordinal, description);
}
}
public class Recipe extends GlobalParcelable {
...
private ArrayList<Step> steps;
private ArrayList<Setup> setups;
...
}
It's the Recipe object that gets passed around from Activity to Activity.
Do I need to put the Creator interface in each class even though I'm extending GlobalParcelable? Or is there a different way I should be trying to utilize GlobalParcelable in this type of case? I'm thinking the core of the issue is that it seems as though dehydrate/rehydrate only deal with basic data types and don't specifically handle Fields that are arrays of parcelable objects.
Also, side note while I'm doing some poking around to try to better understand this, would there be an issue with the Inheritance structure used above due to getDeclaredFields()? A Step has no defined fields other than those inherited from Instruction, and from the docs it seems getDeclaredFields doesn't include inherited fields. So would having GlobalParcelable use getFields() instead be a better approach in this case?
Thanks.