rharter / auto-value-parcel

An Android Parcelable extension for Google's AutoValue.
Apache License 2.0
655 stars 64 forks source link

Ignore properties from parcelable #122

Closed DevAhamed closed 7 years ago

DevAhamed commented 7 years ago

Hi,

Is there a way properties can be excluded from parcelable implementation, such as add an annotation for a property to ignore it.

JakeWharton commented 7 years ago

Can you provide an example where this would be useful?

On Mon, Aug 7, 2017, 3:22 AM Riyaz Ahamed notifications@github.com wrote:

Hi,

Is there a way properties can be excluded from parcelable implementation, such as add an annotation for a property to ignore it.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rharter/auto-value-parcel/issues/122, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEe_OcRRgYsiRZA4neJegOMDB_GY-ks5sVuVugaJpZM4OvQK- .

rharter commented 7 years ago

This would break the value class semantics, as value classes define equality based on the value of their properties. If you were to ignore fields for serialization via Parcel, this would mean that the value object that you get back after parceling and unparceling would not be equal to the value object you put in. For that reason, this doesn't make sense in this context.

On Mon, Aug 7, 2017 at 9:44 AM Jake Wharton notifications@github.com wrote:

Can you provide an example where this would be useful?

On Mon, Aug 7, 2017, 3:22 AM Riyaz Ahamed notifications@github.com wrote:

Hi,

Is there a way properties can be excluded from parcelable implementation, such as add an annotation for a property to ignore it.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rharter/auto-value-parcel/issues/122, or mute the thread < https://github.com/notifications/unsubscribe-auth/AAEEEe_OcRRgYsiRZA4neJegOMDB_GY-ks5sVuVugaJpZM4OvQK-

.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rharter/auto-value-parcel/issues/122#issuecomment-320683768, or mute the thread https://github.com/notifications/unsubscribe-auth/ABPJbuN15xpHdp9SuOgeI8FY5jB1KqXEks5sVyLlgaJpZM4OvQK- .

DevAhamed commented 7 years ago

@JakeWharton I am trying to implement the MVI pattern which you explained in one of your talks. I have some view state class which holds the state values along with data as well. (Data is huge enough to cause TransactionTooLargeException) While saving/restoring the activity i don't want the data to be added to parcelable. If you have any suggestions i will be glad.

@rharter I never thought in that context. I made the changes and about to make a PR (changes are still in my clone), but this changed the entire perspective. Even if i override the equals method, i think it would become kind of niche feature.

DevAhamed commented 7 years ago

I made few changes to the lib in my clone and now it works best for me. Thanks for this awesome library. I am gonna close this.