Skip to content

Commit 519afe3

Browse files
committed
Add comments
1 parent 9ea223e commit 519afe3

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

app/src/main/java/fr/free/nrw/commons/category/CategorizationFragment.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,10 @@ public void writeToParcel(Parcel parcel, int flags) {
121121
}
122122
}
123123

124-
//TODO: Probably add 'suggest from filename' cats here. We want it to be displayed at start, not upon typing
125-
//TODO: Search using MethodA query, but can't use MethodAUpdater because we don't want it updating when user types
124+
/**
125+
* Retrieves category suggestions from title input
126+
* @return a list containing title-related categories
127+
*/
126128
protected ArrayList<String> titleCatQuery() {
127129

128130
TitleCategories titleCategoriesSub;
@@ -132,6 +134,7 @@ protected ArrayList<String> titleCatQuery() {
132134
String title = titleDesc.getString("Title", "");
133135
Log.d(TAG, "Title: " + title);
134136

137+
//Override onPostExecute to access the results of async API call
135138
titleCategoriesSub = new TitleCategories(title) {
136139
@Override
137140
protected void onPostExecute(ArrayList<String> result) {
@@ -142,8 +145,11 @@ protected void onPostExecute(ArrayList<String> result) {
142145
mergeLatch.countDown();
143146
}
144147
};
148+
145149
titleCategoriesSub.execute();
146150
Log.d(TAG, "TitleCatItems in titleCatQuery: " + titleCatItems);
151+
152+
//Only return titleCatItems after API call has finished
147153
try {
148154
mergeLatch.await();
149155
} catch (InterruptedException e) {
@@ -152,15 +158,13 @@ protected void onPostExecute(ArrayList<String> result) {
152158
return titleCatItems;
153159
}
154160

155-
156-
157161
/**
158162
* Retrieves recently-used categories
159163
* @return a list containing recent categories
160164
*/
161165
protected ArrayList<String> recentCatQuery() {
162166
ArrayList<String> items = new ArrayList<String>();
163-
167+
164168
try {
165169
Cursor cursor = client.query(
166170
CategoryContentProvider.BASE_URI,

app/src/main/java/fr/free/nrw/commons/category/TitleCategories.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@
1313

1414
import fr.free.nrw.commons.CommonsApplication;
1515

16-
16+
/**
17+
* Sends asynchronous queries to the Commons MediaWiki API to retrieve categories that are related to
18+
* the title entered in previous screen. The 'srsearch' action-specific parameter is used for this
19+
* purpose. This class should be subclassed in CategorizationFragment.java to add the results to recent and GPS cats.
20+
*/
1721
public class TitleCategories extends AsyncTask<Void, Void, ArrayList<String>> {
1822

1923
private final static int SEARCH_CATS_LIMIT = 25;

0 commit comments

Comments
 (0)