-1

I'm trying to add the parcelable implementation of a variable declared as an Array of Double. When I try to generate this implementation automatically with Android Studio, the coordinateskey stays in TODO:

import android.os.Parcel
import android.os.Parcelable

class PointGeoJson (
    val type: String = "",
    val coordinates: Array<Double> = emptyArray()
) : Parcelable {
    constructor(parcel: Parcel) : this(
        parcel.readString(),
        TODO("coordinates")
    ) {
    }

    override fun writeToParcel(parcel: Parcel, flags: Int) {
        parcel.writeString(type)
    }

    override fun describeContents(): Int {
        return 0
    }

    companion object CREATOR : Parcelable.Creator<PointGeoJson> {
        override fun createFromParcel(parcel: Parcel): PointGeoJson {
            return PointGeoJson(parcel)
        }

        override fun newArray(size: Int): Array<PointGeoJson?> {
            return arrayOfNulls(size)
        }
    }
}
2

1 Answer 1

0
import android.os.Parcelable
import kotlinx.android.parcel.Parcelize

@Parcelize
class PointGeoJson(
        val type: String = "",
        val coordinates: Array<Double> = emptyArray()
) : Parcelable

This should work properly

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.