Is there plug-in to generate parcellables in Kotli...
# android
w
Is there plug-in to generate parcellables in Kotlin like in former java POJO classes?
s
wilburt: I would be careful about parcellables. If you need a plug-in there’s a good chance you are parceling way too much.
w
@scott I usually used them in POJO classes when it needs to be passed around via intents. Isn't that ok?
s
you definitely can. but I wouldn’t. There are restrictions on size, and can slow down main thread a ton. Better to just put the id of the object in the bundle like bundle.putInt(“somePojoId”,25) and then grab the object from the repository/interactor/etc.
then it’s simpler code, no crazy parcelable code, data will always be live and don’t need to copy anything, and faster initialization time of the new activity/fragment/etc.
w
Thanks. This makes more sense.
Ok let's say I got a json response and converted it into a list of POJOs. Now, I want to implement some kind list-detail fragments, if I pass the id of the pojo to the detail activity and send another request to get; is that too much overhead as compared to parcellables?
Please I am not saying you're wrong, I just needed a little clarification.
s
no problem. I don’t mind disagreement don’t worry. that data should NOT live in the activities anyway. that data lives outside the UI. and then you can do the request before and parcel the id or the query like bundle.putString(“moviesList”, “spielberg”)
data should live in some repository or datastore or something right. otherwise you lose the data when activity dies, config changes, etc.
and you can’t independantly test your data. and your data logic and persistance/caching is all in your activity which means it’s tightly coupled and you can’t reuse it.
w
It's more clearer now. Thanks.
s
👍