Kotlin now has support for Parcelizable objects, using the @Parcelize annotation.
Watch the next video if you want a bit of history, but don't follow along with the code changes.
Things are much easier now. All you have to do, is add
@Parcelize
on the line before the class declaration for the Photo class.
The complete code in Photo.kt becomes:
package academy.learnprogramming.flickrbrowser // <-- use your own package name here
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize
@Parcelize
class Photo(var title: String, var author: String, var authorId: String, var link: String, var tags: String,
var image: String) : Parcelable
In the PhotoDetailsActivity class, change the code to use getParcelableExtra
val photo = intent.getParcelableExtra(PHOTO_TRANSFER) as Photo
instead of getSerializableExtra.