Skip to content

Conversation

@moqi2011
Copy link

Add auto generate Parcelable & Json serialize code

@noordawod
Copy link

@moqi2011 This is a great piece of code! Where are the authors?!
@greenrobot ? @greenrobot-team ?

Please take a look at the pull requests as this is really free service to you..

@danielsanfr
Copy link

Please, look this code!

@StanKocken
Copy link

Awesome addition!
Few suggestions:

  • currently not working with boolean (.readBoolean() and .writeBoolean() doesn't exist into Parcel, you must use .writeByte((byte) (myBoolean ? 1 : 0)); and myBoolean = in.readByte() != 0;)
  • It could be a good idea to separate this PR into two: one for Json and one for Parcelable.
  • You made some changes on the coding style, this could prevent the greendao author to merge it as is.

@StanKocken
Copy link

To fix boolean parcelable issue, replace:

<#list entity.properties as property>
${property.propertyName} = in.read${property.parcelableTypeInEntity}();
</#list>    

By

<#list entity.properties as property>
<#if property.parcelableTypeInEntity == "Boolean">
${property.propertyName} = in.readByte() != 0;
<#else>
${property.propertyName} = in.read${property.parcelableTypeInEntity}();
</#if>
</#list>

And

<#list entity.properties as property>
dest.write${property.parcelableTypeInEntity}(${property.propertyName});
</#list>

By

<#list entity.properties as property>
<#if property.parcelableTypeInEntity == "Boolean">
dest.writeByte((byte) (${property.propertyName} ? 1 : 0));
<#else>
dest.write${property.parcelableTypeInEntity}(${property.propertyName});
</#if>
</#list>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants