Skip to content

Commit 25fecce

Browse files
Gabi Scardine SilvaGabi Scardine Silva
authored andcommitted
Convert Category
1 parent dcd0f94 commit 25fecce

File tree

2 files changed

+51
-76
lines changed

2 files changed

+51
-76
lines changed

app/src/main/java/io/intrepid/contest/models/Category.java

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package io.intrepid.contest.models
2+
3+
import android.os.Parcel
4+
import android.os.Parcelable
5+
import java.util.*
6+
7+
class Category : Parcelable {
8+
val id: UUID? = null
9+
var name: String? = null
10+
var description: String? = null
11+
12+
constructor(name: String, description: String) {
13+
this.name = name
14+
this.description = description
15+
}
16+
17+
protected constructor(`in`: Parcel) {
18+
name = `in`.readString()
19+
description = `in`.readString()
20+
}
21+
22+
override fun writeToParcel(dest: Parcel, flags: Int) {
23+
dest.writeString(name)
24+
dest.writeString(description)
25+
}
26+
27+
override fun describeContents(): Int {
28+
return 0
29+
}
30+
31+
override fun equals(obj: Any?): Boolean {
32+
try {
33+
val otherCategory = obj as Category?
34+
return this.name == otherCategory!!.name && this.description == otherCategory.description
35+
} catch (exception: ClassCastException) {
36+
return false
37+
}
38+
}
39+
40+
companion object {
41+
val CREATOR: Parcelable.Creator<Category> = object : Parcelable.Creator<Category> {
42+
override fun createFromParcel(`in`: Parcel): Category {
43+
return Category(`in`)
44+
}
45+
46+
override fun newArray(size: Int): Array<Category?> {
47+
return arrayOfNulls(size)
48+
}
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)