mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
CategoryItem: add javadocs to the file (#3332)
This commit is contained in:
parent
c682ba83d7
commit
cd4fc2cdf0
1 changed files with 35 additions and 0 deletions
|
|
@ -3,6 +3,10 @@ package fr.free.nrw.commons.category;
|
|||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
/**
|
||||
* Represents a Category Item.
|
||||
* Implemented as Parcelable so that its object could be parsed between activity components.
|
||||
*/
|
||||
public class CategoryItem implements Parcelable {
|
||||
private final String name;
|
||||
private boolean selected;
|
||||
|
|
@ -24,28 +28,53 @@ public class CategoryItem implements Parcelable {
|
|||
this.selected = selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads from the received Parcel
|
||||
* @param in
|
||||
*/
|
||||
private CategoryItem(Parcel in) {
|
||||
name = in.readString();
|
||||
selected = in.readInt() == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets Name
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if that Category Item has been selected.
|
||||
* @return
|
||||
*/
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the Category Item.
|
||||
* @param selected
|
||||
*/
|
||||
public void setSelected(boolean selected) {
|
||||
this.selected = selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by Parcelable
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes to the received Parcel
|
||||
* @param parcel
|
||||
* @param flags
|
||||
*/
|
||||
@Override
|
||||
public void writeToParcel(Parcel parcel, int flags) {
|
||||
parcel.writeString(name);
|
||||
|
|
@ -67,11 +96,17 @@ public class CategoryItem implements Parcelable {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns hash code for current object
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return String form of current object
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CategoryItem: '" + name + '\'';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue