mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Failed attempt at adding items to Adapter
This commit is contained in:
parent
9d3b76ac5f
commit
cb3ac0f824
1 changed files with 19 additions and 5 deletions
|
|
@ -50,6 +50,7 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
private OnCategoriesSaveHandler onCategoriesSaveHandler;
|
private OnCategoriesSaveHandler onCategoriesSaveHandler;
|
||||||
|
|
||||||
private HashMap<String, ArrayList<String>> categoriesCache;
|
private HashMap<String, ArrayList<String>> categoriesCache;
|
||||||
|
LinkedHashSet<CategoryItem> itemSet = new LinkedHashSet<CategoryItem>();
|
||||||
|
|
||||||
private ContentProviderClient client;
|
private ContentProviderClient client;
|
||||||
|
|
||||||
|
|
@ -201,6 +202,8 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
protected void onPostExecute(ArrayList<String> categories) {
|
protected void onPostExecute(ArrayList<String> categories) {
|
||||||
super.onPostExecute(categories);
|
super.onPostExecute(categories);
|
||||||
setCatsAfterAsync(categories, filter);
|
setCatsAfterAsync(categories, filter);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -259,10 +262,11 @@ 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: 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 call the next block after AsyncTask over?
|
//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);
|
itemSet.addAll(items);
|
||||||
categoriesAdapter.notifyDataSetInvalidated();
|
Log.d(TAG, "Item Set" + itemSet.toString());
|
||||||
categoriesSearchInProgress.setVisibility(View.GONE);
|
|
||||||
|
|
||||||
if (categories.size() == 0) {
|
if (categories.size() == 0) {
|
||||||
if(TextUtils.isEmpty(filter)) {
|
if(TextUtils.isEmpty(filter)) {
|
||||||
// If we found no recent cats, show the skip message!
|
// If we found no recent cats, show the skip message!
|
||||||
|
|
@ -274,6 +278,8 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
} else {
|
} else {
|
||||||
categoriesList.smoothScrollToPosition(existingKeys.size());
|
categoriesList.smoothScrollToPosition(existingKeys.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CategoriesAdapter extends BaseAdapter {
|
private class CategoriesAdapter extends BaseAdapter {
|
||||||
|
|
@ -283,7 +289,6 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
|
|
||||||
private CategoriesAdapter(Context context, ArrayList<CategoryItem> items) {
|
private CategoriesAdapter(Context context, ArrayList<CategoryItem> items) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
|
||||||
this.items = items;
|
this.items = items;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -452,12 +457,21 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
methodAUpdater.cancel(true);
|
methodAUpdater.cancel(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
methodAUpdater = new MethodAUpdater();
|
methodAUpdater = new MethodAUpdater();
|
||||||
lastUpdater = new CategoriesUpdater();
|
lastUpdater = new CategoriesUpdater();
|
||||||
|
|
||||||
Utils.executeAsyncTask(lastUpdater, executor);
|
Utils.executeAsyncTask(lastUpdater, executor);
|
||||||
Utils.executeAsyncTask(methodAUpdater, executor);
|
Utils.executeAsyncTask(methodAUpdater, executor);
|
||||||
|
|
||||||
|
ArrayList<CategoryItem> itemList = new ArrayList<CategoryItem>(itemSet);
|
||||||
|
|
||||||
|
categoriesAdapter.setItems(itemList);
|
||||||
|
Log.d(TAG, "After AsyncTask over, set items in adapter to " + itemList.toString());
|
||||||
|
|
||||||
|
categoriesAdapter.notifyDataSetInvalidated();
|
||||||
|
categoriesSearchInProgress.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue