Added More JavaDocs

This commit is contained in:
Madhur Gupta 2020-08-26 14:48:08 +05:30
parent 621c80348b
commit fb83594813
7 changed files with 218 additions and 6 deletions

View file

@ -30,7 +30,7 @@ public class ProfileActivity extends NavigationBaseActivity {
@BindView(R.id.tab_layout)
TabLayout tabLayout;
ViewPagerAdapter viewPagerAdapter;
private ViewPagerAdapter viewPagerAdapter;
private AchievementsFragment achievementsFragment;
private LeaderboardFragment leaderboardFragment;

View file

@ -5,18 +5,41 @@ package fr.free.nrw.commons.profile.leaderboard;
*/
public class LeaderboardConstants {
/**
* This is the size of the page i.e. number items to load in a batch when pagination is performed
*/
public static final int PAGE_SIZE = 10;
/**
* This is the starting offset, we set it to 0 to start loading from rank 1
*/
public static final int START_OFFSET = 0;
/**
* This is the prefix of the user's homepage url, appending the username will give us complete url
*/
public static final String USER_LINK_PREFIX = "https://commons.wikimedia.org/wiki/User:";
/**
* This is the a constant string for the state loading, when the pages are getting loaded we can
* use this constant to identify if we need to show the progress bar or not
*/
public final static String LOADING = "Loading";
/**
* This is the a constant string for the state loaded, when the pages are loaded we can
* use this constant to identify if we need to show the progress bar or not
*/
public final static String LOADED = "Loaded";
/**
* This API endpoint is to update the leaderboard avatar
*/
public final static String UPDATE_AVATAR_END_POINT = "/update_avatar.py";
/**
* This API endpoint is to get leaderboard data
*/
public final static String LEADERBOARD_END_POINT = "/leaderboard.py";
}

View file

@ -98,7 +98,16 @@ public class LeaderboardFragment extends CommonsDaggerSupportFragment {
hideLayouts();
setSpinners();
/**
* This array is for the duration filter, we have three filters weekly, yearly and all-time
* each filter have a key and value pair, the value represents the param of the API
*/
String[] durationValues = getContext().getResources().getStringArray(R.array.leaderboard_duration_values);
/**
* This array is for the category filter, we have three filters upload, used and nearby
* each filter have a key and value pair, the value represents the param of the API
*/
String[] categoryValues = getContext().getResources().getStringArray(R.array.leaderboard_category_values);
duration = durationValues[0];

View file

@ -13,50 +13,90 @@ import com.google.gson.annotations.SerializedName;
*/
public class LeaderboardList {
/**
* Username of the user
* Example value - Syced
*/
@SerializedName("username")
@Expose
private String username;
/**
* Count in the category
* Example value - 10
*/
@SerializedName("category_count")
@Expose
private Integer categoryCount;
/**
* URL of the avatar of user
* Example value = https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/Gnome-stock_person.svg/200px-Gnome-stock_person.svg.png
*/
@SerializedName("avatar")
@Expose
private String avatar;
/**
* Rank of the user
* Example value - 1
*/
@SerializedName("rank")
@Expose
private Integer rank;
/**
* @return the username of the user in the leaderboard list
*/
public String getUsername() {
return username;
}
/**
* Sets the username of the user in the leaderboard list
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @return the category count of the user in the leaderboard list
*/
public Integer getCategoryCount() {
return categoryCount;
}
/**
* Sets the category count of the user in the leaderboard list
*/
public void setCategoryCount(Integer categoryCount) {
this.categoryCount = categoryCount;
}
/**
* @return the avatar of the user in the leaderboard list
*/
public String getAvatar() {
return avatar;
}
/**
* Sets the avatar of the user in the leaderboard list
*/
public void setAvatar(String avatar) {
this.avatar = avatar;
}
/**
* @return the rank of the user in the leaderboard list
*/
public Integer getRank() {
return rank;
}
/**
* Sets the rank of the user in the leaderboard list
*/
public void setRank(Integer rank) {
this.rank = rank;
}
@ -80,6 +120,11 @@ public class LeaderboardList {
}
};
/**
* Returns true if two objects are equal, false otherwise
* @param obj
* @return
*/
@Override
public boolean equals(Object obj) {
if (obj == this) {

View file

@ -9,122 +9,227 @@ import com.google.gson.annotations.SerializedName;
*/
public class LeaderboardResponse {
/**
* Status Code returned from the API
* Example value - 200
*/
@SerializedName("status")
@Expose
private Integer status;
/**
* Username returned from the API
* Example value - Syced
*/
@SerializedName("username")
@Expose
private String username;
/**
* Category count returned from the API
* Example value - 10
*/
@SerializedName("category_count")
@Expose
private Integer categoryCount;
/**
* Limit returned from the API
* Example value - 10
*/
@SerializedName("limit")
@Expose
private int limit;
/**
* Avatar returned from the API
* Example value - https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/Gnome-stock_person.svg/200px-Gnome-stock_person.svg.png
*/
@SerializedName("avatar")
@Expose
private String avatar;
/**
* Offset returned from the API
* Example value - 0
*/
@SerializedName("offset")
@Expose
private int offset;
/**
* Duration returned from the API
* Example value - yearly
*/
@SerializedName("duration")
@Expose
private String duration;
/**
* Leaderboard list returned from the API
* Example value - [{
* "username": "",
* "category_count": 107147,
* "avatar": "https://upload.wikimedia.org/wikipedia/commons/thumb/0/0a/Gnome-stock_person.svg/200px-Gnome-stock_person.svg.png",
* "rank": 1
* }]
*/
@SerializedName("leaderboard_list")
@Expose
private List<LeaderboardList> leaderboardList = null;
/**
* Category returned from the API
* Example value - upload
*/
@SerializedName("category")
@Expose
private String category;
/**
* Rank returned from the API
* Example value - 1
*/
@SerializedName("rank")
@Expose
private Integer rank;
/**
* @return the status code
*/
public Integer getStatus() {
return status;
}
/**
* Sets the status code
*/
public void setStatus(Integer status) {
this.status = status;
}
/**
* @return the username
*/
public String getUsername() {
return username;
}
/**
* Sets the username
*/
public void setUsername(String username) {
this.username = username;
}
/**
* @return the category count
*/
public Integer getCategoryCount() {
return categoryCount;
}
/**
* Sets the category count
*/
public void setCategoryCount(Integer categoryCount) {
this.categoryCount = categoryCount;
}
/**
* @return the limit
*/
public int getLimit() {
return limit;
}
/**
* Sets the limit
*/
public void setLimit(int limit) {
this.limit = limit;
}
/**
* @return the avatar
*/
public String getAvatar() {
return avatar;
}
/**
* Sets the avatar
*/
public void setAvatar(String avatar) {
this.avatar = avatar;
}
/**
* @return the offset
*/
public int getOffset() {
return offset;
}
/**
* Sets the offset
*/
public void setOffset(int offset) {
this.offset = offset;
}
/**
* @return the duration
*/
public String getDuration() {
return duration;
}
/**
* Sets the duration
*/
public void setDuration(String duration) {
this.duration = duration;
}
/**
* @return the leaderboard list
*/
public List<LeaderboardList> getLeaderboardList() {
return leaderboardList;
}
/**
* Sets the leaderboard list
*/
public void setLeaderboardList(List<LeaderboardList> leaderboardList) {
this.leaderboardList = leaderboardList;
}
/**
* @return the category
*/
public String getCategory() {
return category;
}
/**
* Sets the category
*/
public void setCategory(String category) {
this.category = category;
}
/**
* @return the rank
*/
public Integer getRank() {
return rank;
}
/**
* Sets the rank
*/
public void setRank(Integer rank) {
this.rank = rank;
}

View file

@ -8,38 +8,68 @@ import com.google.gson.annotations.SerializedName;
*/
public class UpdateAvatarResponse {
/**
* Status Code returned from the API
* Example value - 200
*/
@SerializedName("status")
@Expose
private String status;
/**
* Message returned from the API
* Example value - Avatar Updated
*/
@SerializedName("message")
@Expose
private String message;
/**
* Username returned from the API
* Example value - Syced
*/
@SerializedName("user")
@Expose
private String user;
/**
* @return the status code
*/
public String getStatus() {
return status;
}
/**
* Sets the status code
*/
public void setStatus(String status) {
this.status = status;
}
/**
* @return the message
*/
public String getMessage() {
return message;
}
/**
* Sets the message
*/
public void setMessage(String message) {
this.message = message;
}
/**
* @return the username
*/
public String getUser() {
return user;
}
/**
* Sets the username
*/
public void setUser(String user) {
this.user = user;
}

View file

@ -16,7 +16,7 @@ import fr.free.nrw.commons.R;
*/
public class UserDetailAdapter extends RecyclerView.Adapter<UserDetailAdapter.DataViewHolder> {
LeaderboardResponse leaderboardResponse;
private LeaderboardResponse leaderboardResponse;
public UserDetailAdapter(LeaderboardResponse leaderboardResponse) {
this.leaderboardResponse = leaderboardResponse;
@ -24,10 +24,10 @@ public class UserDetailAdapter extends RecyclerView.Adapter<UserDetailAdapter.Da
public class DataViewHolder extends RecyclerView.ViewHolder {
TextView rank;
SimpleDraweeView avatar;
TextView username;
TextView count;
private TextView rank;
private SimpleDraweeView avatar;
private TextView username;
private TextView count;
public DataViewHolder(@NonNull View itemView) {
super(itemView);