frankiesardo / icepick

Android Instance State made easy
Eclipse Public License 1.0
3.75k stars 208 forks source link

Feature Request: Default values #65

Closed jbaginski closed 9 years ago

jbaginski commented 9 years ago

is it possible to add support for default values?

frankiesardo commented 9 years ago

At the moment it only works for boxed primitives like Integer or Double but I see no reason not to make it work with all the other types. Some work is necessary to accommodate this feature but when I have some free time on my hands I can happily add it.

frankiesardo commented 9 years ago

Could you clarify your use case for me a bit?

At the moment the first time a Fragment is initialised the Bundle in null so Icepick doesn't do anything.

The first time a Fragment is paused Icepick writes in the Bundle the current value of your fields. If you've not reassigned them that's the default value you initialised them with.

The next time the Fragment is restored there will always be a value in the Bundle because it was paused at least once. It will be either the initial value that you used in initialisation or any value you assigned to the field.

Where do default values will have a chance of being used in such scenario?

jbaginski commented 9 years ago

silly me, please ignore this ticket :)