-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
annotate which field can be serialize? #73
Comments
Simply mark what fields you don't want included in the |
thank you. but baseModel is in other library which can not be modified, how can I exclude super class field in subClass? |
but baseModel is in other library which can not be modified, how can I exclude super class field in subClass? |
The best solution currently is to write a |
super class(which is can not be modified)
subclass
How can I do exclude BaseModel |
Annotate @Parcel(converter = ModelConverter.class)
public class Model extends BaseModel {
public String name;
} And define public static class ModelConverter implements ParcelConverter<Model>{
@Override
public void toParcel(Model input, android.os.Parcel parcel) {
parcel.writeString(input.name);
}
@Override
public Model fromParcel(android.os.Parcel parcel) {
Model model = new Model();
model.name = parcel.readString();
return model;
}
} (Until #62 is finished) |
I think a better approach is to make the model inherit this class instead of @ParcelClass(value = ModelAdapter.class, annotation = @Parcel(converter = ModelAdapterConverter.class))
public abstract class ParcelableBaseModel extends BaseModel {
} And having this: public class ModelAdapterConverter implements ParcelConverter<ModelAdapter> {
@Override
public void toParcel(ModelAdapter input, Parcel parcel) {
}
@Override
public ModelAdapter fromParcel(Parcel parcel) {
return null;
}
} Otherwise, it would be nice if |
@bryant1410 I'm getting "an enclosing instance that contains blahblah.ModelAdapterConverter is required" error in an auto generated dbflow class in. Error lines are marked with a "//HERE" comment in front of them. public class ModelAdapter$$Parcelable
implements Parcelable, ParcelWrapper<ModelAdapter>
{
private ModelAdapter modelAdapter$$0;
@SuppressWarnings("UnusedDeclaration")
public final static ModelAdapter$$Parcelable.Creator$$0 CREATOR = new ModelAdapter$$Parcelable.Creator$$0();
public ModelAdapter$$Parcelable(android.os.Parcel parcel$$0) {
modelAdapter$$0 = new com.shaya.poinila.android.data.database.PoinilaDataBase.ModelAdapterConverter().fromParcel(parcel$$0); // HERE!
}
public ModelAdapter$$Parcelable(ModelAdapter modelAdapter$$1) {
modelAdapter$$0 = modelAdapter$$1;
}
@Override
public void writeToParcel(android.os.Parcel parcel$$1, int flags) {
new com.shaya.poinila.android.data.database.PoinilaDataBase.ModelAdapterConverter().toParcel(modelAdapter$$0, parcel$$1); // HERE!
}
@Override
public int describeContents() {
return 0;
}
@Override
public ModelAdapter getParcel() {
return modelAdapter$$0;
}
public final static class Creator$$0 implements Creator<ModelAdapter$$Parcelable> {
@Override
public ModelAdapter$$Parcelable createFromParcel(android.os.Parcel parcel$$2) {
return new ModelAdapter$$Parcelable(parcel$$2);
}
@Override
public ModelAdapter$$Parcelable[] newArray(int size) {
return new ModelAdapter$$Parcelable[size] ;
}
}
} Any idea how to resolve this? |
DBFlow 3.0.0-beta1 |
@bryant1410 Tnx but I'm not very sure about using a beta version. |
@khafan I haven't used it. The other option that comes to my mind is to fork the last stable version and make |
@bryant1410, I'm not seeing |
Yeah! Sorry, I got confused! I meant that, to make it work with Parceler out of the box |
👍 |
@khafan, we do have another option if you want to ignore the base class entirely, if that is what you want. You can use the @Parcel(analyze=Model.class) // Will not analyze BaseModel
public class Model extends BaseModel {
public String name;
} |
@johncarl81 good tip! |
@johncarl81 Awesome! Completely satisfy my conditions. Will try that 👍 |
hi
I just want to parcel just on field of my class, how can I do?
or
auto ignore unparcel field.
I am using dbflow, and every bean class extends basemodel, but basemodel has a modeladapter, it can not be parceled.
The text was updated successfully, but these errors were encountered: