mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Getting results but only from either method
This commit is contained in:
parent
0203a9cdec
commit
a51f4252bb
1 changed files with 61 additions and 66 deletions
|
|
@ -46,14 +46,15 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
TextView categoriesSkip;
|
||||
|
||||
CategoriesAdapter categoriesAdapter;
|
||||
PrefixUpdater lastUpdater = null;
|
||||
MethodAUpdater methodAUpdater = null;
|
||||
ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(2);
|
||||
|
||||
private OnCategoriesSaveHandler onCategoriesSaveHandler;
|
||||
|
||||
protected HashMap<String, ArrayList<String>> categoriesCache;
|
||||
|
||||
private final Set<String> results = new LinkedHashSet<String>();
|
||||
PrefixUpdaterSub prefixUpdaterSub = null;
|
||||
MethodAUpdaterSub methodAUpdaterSub = null;
|
||||
|
||||
private ContentProviderClient client;
|
||||
|
||||
|
|
@ -110,6 +111,7 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
Category cat = Category.fromCursor(cursor);
|
||||
items.add(cat.getName());
|
||||
}
|
||||
cursor.close();
|
||||
|
||||
if (MwVolleyApi.GpsCatExists.getGpsCatExists() == true){
|
||||
//Log.d(TAG, "GPS cats found in CategorizationFragment.java" + MwVolleyApi.getGpsCat().toString());
|
||||
|
|
@ -145,17 +147,10 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
}
|
||||
}
|
||||
|
||||
//TODO: This will set items twice in Adapter. Need to be able to 'add' items to adapter instead? Need to convert LinkedHashSet to ArrayList first?
|
||||
//TODO: Maybe DON'T call this Adapter method. Instead make an add(items) method that will build up the LinkedHashSet. Then move this whole thing to bottom
|
||||
categoriesAdapter.setItems(items);
|
||||
categoriesAdapter.notifyDataSetInvalidated();
|
||||
categoriesSearchInProgress.setVisibility(View.GONE);
|
||||
|
||||
/*
|
||||
itemSet.addAll(items);
|
||||
Log.d(TAG, "Item Set" + itemSet.toString());
|
||||
*/
|
||||
|
||||
if (categories.size() == 0) {
|
||||
if(TextUtils.isEmpty(filter)) {
|
||||
// If we found no recent cats, show the skip message!
|
||||
|
|
@ -335,11 +330,6 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
return rootView;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void startUpdatingCategoryList() {
|
||||
|
||||
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
|
||||
class PrefixUpdaterSub extends PrefixUpdater {
|
||||
|
|
@ -357,6 +347,7 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
}
|
||||
catch (InterruptedException e) {
|
||||
Log.w(TAG, e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -366,6 +357,7 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
super.onPostExecute(result);
|
||||
|
||||
results.addAll(result);
|
||||
Log.d(TAG, "Prefix result: " + result);
|
||||
categoriesAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
|
@ -379,30 +371,33 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(ArrayList<String> result) {
|
||||
results.clear();
|
||||
super.onPostExecute(result);
|
||||
|
||||
results.clear();
|
||||
results.addAll(result);
|
||||
Log.d(TAG, "Method A result: " + result);
|
||||
categoriesAdapter.notifyDataSetChanged();
|
||||
|
||||
latch.countDown();
|
||||
}
|
||||
}
|
||||
|
||||
if (lastUpdater != null) {
|
||||
lastUpdater.cancel(true);
|
||||
private void startUpdatingCategoryList() {
|
||||
|
||||
if (prefixUpdaterSub != null) {
|
||||
prefixUpdaterSub.cancel(true);
|
||||
}
|
||||
|
||||
if (methodAUpdater != null) {
|
||||
methodAUpdater.cancel(true);
|
||||
if (methodAUpdaterSub != null) {
|
||||
methodAUpdaterSub.cancel(true);
|
||||
}
|
||||
|
||||
|
||||
PrefixUpdaterSub prefixUpdaterSub = new PrefixUpdaterSub();
|
||||
MethodAUpdaterSub methodAUpdaterSub = new MethodAUpdaterSub();
|
||||
prefixUpdaterSub = new PrefixUpdaterSub();
|
||||
methodAUpdaterSub = new MethodAUpdaterSub();
|
||||
|
||||
Utils.executeAsyncTask(prefixUpdaterSub);
|
||||
Utils.executeAsyncTask(methodAUpdaterSub);
|
||||
Log.d(TAG, "Final results: " + results);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue