futurice / freesound-android

Unofficial Android client for the Freesound Project
Apache License 2.0
85 stars 16 forks source link

Use @Parcelize #166

Closed peter-tackage closed 6 years ago

peter-tackage commented 6 years ago

It's still experimental, but worth exploring because it will save 100s of LOC. Some documentation here: https://github.com/Kotlin/KEEP/blob/master/proposals/extensions/android-parcelable.md

peter-tackage commented 6 years ago

@tomaszpolanski I've added a test for Sound.kt. Because there's no CREATOR object visible in the code, I've had to let Android perform the serialization/deserialization via Bundle.

joan-domingo commented 6 years ago

Does it work fine? I haven't tried with Kotlin 1.2, but in previous versions there was an issue parceling Date: https://stackoverflow.com/questions/46592138/nosuchmethoderror-using-parcelize-annotation-in-kotlin

peter-tackage commented 6 years ago

@joan-domingo I have a test which uses Date and passes. Also the Date issue in questions seems to be fixed. It's still experimental, so who knows, perhaps they could change the API or remove it. But given the simplicity of use - it's a great improvement over the old boilerplate.

peter-tackage commented 6 years ago

@joan-domingo, @tomaszpolanski has pointed out that the test I wrote doesn't effectively test the marshalling/unmarshalling - in fact sound and result are the same instance, hence will always pass the equality assertion.