Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CategoryItem: add javadocs to the file #3332

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions app/src/main/java/fr/free/nrw/commons/category/CategoryItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
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;
Expand All @@ -24,28 +28,53 @@ public CategoryItem(String name, boolean selected) {
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);
Expand All @@ -67,11 +96,17 @@ public boolean equals(Object o) {

}

/**
* 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 + '\'';
Expand Down