3
3
import android .os .Parcel ;
4
4
import android .os .Parcelable ;
5
5
6
+ /**
7
+ * Represents a Category Item.
8
+ * Implemented as Parcelable so that its object could be parsed between activity components.
9
+ */
6
10
public class CategoryItem implements Parcelable {
7
11
private final String name ;
8
12
private boolean selected ;
@@ -24,28 +28,53 @@ public CategoryItem(String name, boolean selected) {
24
28
this .selected = selected ;
25
29
}
26
30
31
+ /**
32
+ * Reads from the received Parcel
33
+ * @param in
34
+ */
27
35
private CategoryItem (Parcel in ) {
28
36
name = in .readString ();
29
37
selected = in .readInt () == 1 ;
30
38
}
31
39
40
+ /**
41
+ * Gets Name
42
+ * @return
43
+ */
32
44
public String getName () {
33
45
return name ;
34
46
}
35
47
48
+ /**
49
+ * Checks if that Category Item has been selected.
50
+ * @return
51
+ */
36
52
public boolean isSelected () {
37
53
return selected ;
38
54
}
39
55
56
+ /**
57
+ * Selects the Category Item.
58
+ * @param selected
59
+ */
40
60
public void setSelected (boolean selected ) {
41
61
this .selected = selected ;
42
62
}
43
63
64
+ /**
65
+ * Used by Parcelable
66
+ * @return
67
+ */
44
68
@ Override
45
69
public int describeContents () {
46
70
return 0 ;
47
71
}
48
72
73
+ /**
74
+ * Writes to the received Parcel
75
+ * @param parcel
76
+ * @param flags
77
+ */
49
78
@ Override
50
79
public void writeToParcel (Parcel parcel , int flags ) {
51
80
parcel .writeString (name );
@@ -67,11 +96,17 @@ public boolean equals(Object o) {
67
96
68
97
}
69
98
99
+ /**
100
+ * Returns hash code for current object
101
+ */
70
102
@ Override
71
103
public int hashCode () {
72
104
return name .hashCode ();
73
105
}
74
106
107
+ /**
108
+ * Return String form of current object
109
+ */
75
110
@ Override
76
111
public String toString () {
77
112
return "CategoryItem: '" + name + '\'' ;
0 commit comments