33import android .os .Parcel ;
44import android .os .Parcelable ;
55
6- /**
7- * Represents a Category Item.
8- * Implemented as Parcelable so that its object could be parsed between activity components.
9- */
6+
107public class CategoryItem implements Parcelable {
118 private final String name ;
129 private boolean selected ;
@@ -28,59 +25,37 @@ public CategoryItem(String name, boolean selected) {
2825 this .selected = selected ;
2926 }
3027
31- /**
32- * Reads from the received Parcel
33- * @param in
34- */
3528 private CategoryItem (Parcel in ) {
3629 name = in .readString ();
3730 selected = in .readInt () == 1 ;
3831 }
3932
40- /**
41- * Gets Name
42- * @return
43- */
4433 public String getName () {
4534 return name ;
4635 }
4736
48- /**
49- * Checks if that Category Item has been selected.
50- * @return
51- */
5237 public boolean isSelected () {
5338 return selected ;
5439 }
5540
56- /**
57- * Selects the Category Item.
58- * @param selected
59- */
6041 public void setSelected (boolean selected ) {
6142 this .selected = selected ;
6243 }
6344
64- /**
65- * Used by Parcelable
66- * @return
67- */
45+
6846 @ Override
6947 public int describeContents () {
7048 return 0 ;
7149 }
7250
73- /**
74- * Writes to the received Parcel
75- * @param parcel
76- * @param flags
77- */
51+
7852 @ Override
7953 public void writeToParcel (Parcel parcel , int flags ) {
8054 parcel .writeString (name );
8155 parcel .writeInt (selected ? 1 : 0 );
8256 }
8357
58+
8459 @ Override
8560 public boolean equals (Object o ) {
8661 if (this == o ) {
@@ -96,17 +71,13 @@ public boolean equals(Object o) {
9671
9772 }
9873
99- /**
100- * Returns hash code for current object
101- */
74+
10275 @ Override
10376 public int hashCode () {
10477 return name .hashCode ();
10578 }
10679
107- /**
108- * Return String form of current object
109- */
80+
11081 @ Override
11182 public String toString () {
11283 return "CategoryItem: '" + name + '\'' ;
0 commit comments