You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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);
}
}
In my app, all of this rolls up into a Recipe object that has:
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.
The text was updated successfully, but these errors were encountered:
@deragun don't know if you find a solution to this, but im also using this class, and as i notice your classes that will be put on the arraylist must also extends GlobalParcelable.
Doing that is working good to me... now im facing another problem... since my app is being destroyed after some time, when i reopen the app, the Parcelable classes are being destryoed and i must create an empty constructor to reinitiante then (which in my case is bad). Im going to try using a constructor with a Parcel value and use the default constructor of GlobalParcelable to do the jobs... im with fingers crossed here!
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:
In my app, all of this rolls up into a Recipe object that has:
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.
The text was updated successfully, but these errors were encountered: