Skip to content
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

Add auto generate Parcelable & Json serialize code #280

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add auto generate Parcelable & Json serialize code #280

wants to merge 1 commit into from

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