ref: 39faa85c5d0e2ec6212f990934bc974a8783effd
app/src/main/java/ml/adamsprogs/bimba/models/StopSegment.kt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
package ml.adamsprogs.bimba.models import android.os.Parcel import android.os.Parcelable import ml.adamsprogs.bimba.gtfs.AgencyAndId data class StopSegment(val stop: AgencyAndId, var plates: Set<Plate.ID>?) : Parcelable { constructor(parcel: Parcel) : this( parcel.readSerializable() as AgencyAndId, parcel.readString().split("|").map { Plate.ID.fromString(it) }.toSet() ) companion object CREATOR : Parcelable.Creator<StopSegment> { override fun createFromParcel(parcel: Parcel): StopSegment { return StopSegment(parcel) } override fun newArray(size: Int): Array<StopSegment?> { return arrayOfNulls(size) } } fun fillPlates() { plates = Timetable.getTimetable().getPlatesForStop(stop) } override fun writeToParcel(dest: Parcel?, flags: Int) { dest?.writeSerializable(stop) if (plates != null) dest?.writeString(plates!!.joinToString("|") { it.toString() }) } override fun describeContents(): Int { return Parcelable.CONTENTS_FILE_DESCRIPTOR } override fun equals(other: Any?): Boolean { if (other !is StopSegment) return false if (this.stop != other.stop) return false if (this.plates != null && other.plates == null) return false if (this.plates == null && other.plates != null) return false if (this.plates == null && other.plates == null) return true if (this.plates!!.size != other.plates!!.size) return false if (this.plates!!.containsAll(other.plates!!)) return true return false } override fun hashCode(): Int { return super.hashCode() } fun contains(plateId: Plate.ID): Boolean { if (plates == null) return false return plates!!.contains(plateId) } } |