News for hackers. Stuff that matters.
Re:Show HN: Realm for Android by zackb on Tuesday September 30, 2014 @05:17PM (#8391311)
I've always wondered how folks handle the Parcelable[1] interface with libraries like this. If you have a realm object that you want to have in memory between activity destroy/create how do you handle this? For instance if I rotate the screen the activity is destroyed and recreated for the new orientation. As I understand it the Parcelable interface and Bundle[2] is the way to handle this but how can you do this if you're using third party classes/objects?

Thanks!

[1]: http://developer.android.com/reference/android/os/Parcelable... [2]: http://developer.android.com/training/basics/activity-lifecy...

Re:Show HN: Realm for Android by makeramen on Tuesday September 30, 2014 @05:33PM (#8391418)
I use Parceler (https://github.com/johncarl81/parceler) with gson. So gson for network data, then parceler for passing parcels around between activities/fragments.
Re:Show HN: Realm for Android by zackb on Tuesday September 30, 2014 @06:08PM (#8391627)
Doesn't this require annotating the class? What if I can't change the class implementation?
Re:Show HN: Realm for Android by johncarl81 on Saturday October 04, 2014 @01:49PM (#8410010)
One way to use Parceler is to annotate the class. There are a lot of other options though, including configuring the class outside of the class using @ParcelClass (useful for libraries) or writing a ParcelConverter.
Re:Show HN: Realm for Android by emanuelez on Tuesday September 30, 2014 @05:26PM (#8391368)
The main difference is that with Parcelable you have two versions of your object (one persisted on disk and one in memory) while with Realm you are always working with your real data, not a representation of it.
Re:Show HN: Realm for Android by swanson on Tuesday September 30, 2014 @07:47PM (#8392092)
You can always just put the model id (or some other way to requery) in the Bundle and look it up again after the configuration change.