Set PrefixUpdaterSub etc to anonymous type

This commit is contained in:
misaochan 2016-01-25 15:10:27 +13:00
parent 78a0d1c009
commit 74e999015b

View file

@ -53,8 +53,8 @@ public class CategorizationFragment extends SherlockFragment{
protected HashMap<String, ArrayList<String>> categoriesCache; protected HashMap<String, ArrayList<String>> categoriesCache;
private final Set<String> results = new LinkedHashSet<String>(); private final Set<String> results = new LinkedHashSet<String>();
//PrefixUpdaterSub prefixUpdaterSub = null; PrefixUpdater prefixUpdaterSub = null;
//MethodAUpdaterSub methodAUpdaterSub = null; MethodAUpdater methodAUpdaterSub = null;
private ContentProviderClient client; private ContentProviderClient client;
@ -334,7 +334,7 @@ public class CategorizationFragment extends SherlockFragment{
final CountDownLatch latch = new CountDownLatch(1); final CountDownLatch latch = new CountDownLatch(1);
Utils.executeAsyncTask(new PrefixUpdater(this) { prefixUpdaterSub = new PrefixUpdater(this) {
@Override @Override
protected ArrayList<String> doInBackground(Void... voids) { protected ArrayList<String> doInBackground(Void... voids) {
ArrayList<String> result = new ArrayList<String>(); ArrayList<String> result = new ArrayList<String>();
@ -357,9 +357,9 @@ public class CategorizationFragment extends SherlockFragment{
Log.d(TAG, "Prefix result: " + result); Log.d(TAG, "Prefix result: " + result);
categoriesAdapter.notifyDataSetChanged(); categoriesAdapter.notifyDataSetChanged();
} }
}); };
Utils.executeAsyncTask(new MethodAUpdater(this) { methodAUpdaterSub = new MethodAUpdater(this) {
@Override @Override
protected void onPostExecute(ArrayList<String> result) { protected void onPostExecute(ArrayList<String> result) {
results.clear(); results.clear();
@ -371,32 +371,26 @@ public class CategorizationFragment extends SherlockFragment{
latch.countDown(); latch.countDown();
} }
}); };
Utils.executeAsyncTask(prefixUpdaterSub);
Utils.executeAsyncTask(methodAUpdaterSub);
} }
private void startUpdatingCategoryList() { private void startUpdatingCategoryList() {
requestSearchResults(); if (prefixUpdaterSub != null) {
prefixUpdaterSub.cancel(true);
/*
if (prefixUpdater != null) {
prefixUpdater.cancel(true);
} }
if (methodAUpdaterSub != null) { if (methodAUpdaterSub != null) {
methodAUpdaterSub.cancel(true); methodAUpdaterSub.cancel(true);
} }
prefixUpdaterSub = new PrefixUpdaterSub(); requestSearchResults();
methodAUpdaterSub = new MethodAUpdaterSub();
Utils.executeAsyncTask(prefixUpdaterSub);
Utils.executeAsyncTask(methodAUpdaterSub);
Log.d(TAG, "Final results: " + results);
*/
//Log.d(TAG, "Final results: " + results);
} }
@Override @Override