@@ -121,8 +121,10 @@ public void writeToParcel(Parcel parcel, int flags) {
121
121
}
122
122
}
123
123
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
+ */
126
128
protected ArrayList <String > titleCatQuery () {
127
129
128
130
TitleCategories titleCategoriesSub ;
@@ -132,6 +134,7 @@ protected ArrayList<String> titleCatQuery() {
132
134
String title = titleDesc .getString ("Title" , "" );
133
135
Log .d (TAG , "Title: " + title );
134
136
137
+ //Override onPostExecute to access the results of async API call
135
138
titleCategoriesSub = new TitleCategories (title ) {
136
139
@ Override
137
140
protected void onPostExecute (ArrayList <String > result ) {
@@ -142,8 +145,11 @@ protected void onPostExecute(ArrayList<String> result) {
142
145
mergeLatch .countDown ();
143
146
}
144
147
};
148
+
145
149
titleCategoriesSub .execute ();
146
150
Log .d (TAG , "TitleCatItems in titleCatQuery: " + titleCatItems );
151
+
152
+ //Only return titleCatItems after API call has finished
147
153
try {
148
154
mergeLatch .await ();
149
155
} catch (InterruptedException e ) {
@@ -152,15 +158,13 @@ protected void onPostExecute(ArrayList<String> result) {
152
158
return titleCatItems ;
153
159
}
154
160
155
-
156
-
157
161
/**
158
162
* Retrieves recently-used categories
159
163
* @return a list containing recent categories
160
164
*/
161
165
protected ArrayList <String > recentCatQuery () {
162
166
ArrayList <String > items = new ArrayList <String >();
163
-
167
+
164
168
try {
165
169
Cursor cursor = client .query (
166
170
CategoryContentProvider .BASE_URI ,
0 commit comments