Skip to content

Instantly share code, notes, and snippets.

@jeancsanchez
Created September 17, 2020 01:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeancsanchez/d85f1174c83742061e9a503feb8ce4f0 to your computer and use it in GitHub Desktop.
Save jeancsanchez/d85f1174c83742061e9a503feb8ce4f0 to your computer and use it in GitHub Desktop.
package br.com.onze.domain.models
import android.os.Parcel
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
/**
* @author Jean Carlos (Github: @jeancsanchez)
* @date 02/11/16.
* Jesus loves you.
*/
data class Racha(
val id: Int? = null,
val name: String? = "",
@SerializedName("photo_url") val photoUrl: String? = null,
val description: String? = null,
@SerializedName("days_week") val daysOfWeek: ArrayList<DayWeek>,
val location: Location? = null,
@SerializedName("hour_millis") val hourMillis: Long,
val players: ArrayList<Player>? = null,
@SerializedName("created_by") val createdBy: Player
) : Parcelable {
constructor(source: Parcel) : this(
source.readValue(Int::class.java.classLoader) as Int?,
source.readString(),
source.readString(),
source.readString(),
ArrayList<DayWeek>().apply { source.readList(this, DayWeek::class.java.classLoader) },
source.readParcelable<Location>(Location::class.java.classLoader),
source.readLong(),
source.createTypedArrayList(Player.CREATOR),
source.readParcelable<Player>(Player::class.java.classLoader)!!
)
override fun describeContents() = 0
override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
writeValue(id)
writeString(name)
writeString(photoUrl)
writeString(description)
writeList(daysOfWeek)
writeParcelable(location, 0)
writeLong(hourMillis)
writeTypedList(players)
writeParcelable(createdBy, 0)
}
companion object {
@JvmField
val CREATOR: Parcelable.Creator<Racha> = object : Parcelable.Creator<Racha> {
override fun createFromParcel(source: Parcel): Racha = Racha(source)
override fun newArray(size: Int): Array<Racha?> = arrayOfNulls(size)
}
}
override fun toString(): String = name ?: ""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment