mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +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.Parcel;
|
||||||
import android.os.Parcelable;
|
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 {
|
public class CategoryItem implements Parcelable {
|
||||||
private final String name;
|
private final String name;
|
||||||
private boolean selected;
|
private boolean selected;
|
||||||
|
|
@ -24,28 +28,53 @@ public class CategoryItem implements Parcelable {
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads from the received Parcel
|
||||||
|
* @param in
|
||||||
|
*/
|
||||||
private CategoryItem(Parcel in) {
|
private CategoryItem(Parcel in) {
|
||||||
name = in.readString();
|
name = in.readString();
|
||||||
selected = in.readInt() == 1;
|
selected = in.readInt() == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets Name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if that Category Item has been selected.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean isSelected() {
|
public boolean isSelected() {
|
||||||
return selected;
|
return selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Selects the Category Item.
|
||||||
|
* @param selected
|
||||||
|
*/
|
||||||
public void setSelected(boolean selected) {
|
public void setSelected(boolean selected) {
|
||||||
this.selected = selected;
|
this.selected = selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by Parcelable
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes to the received Parcel
|
||||||
|
* @param parcel
|
||||||
|
* @param flags
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void writeToParcel(Parcel parcel, int flags) {
|
public void writeToParcel(Parcel parcel, int flags) {
|
||||||
parcel.writeString(name);
|
parcel.writeString(name);
|
||||||
|
|
@ -67,11 +96,17 @@ public class CategoryItem implements Parcelable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns hash code for current object
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return name.hashCode();
|
return name.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return String form of current object
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CategoryItem: '" + name + '\'';
|
return "CategoryItem: '" + name + '\'';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue