mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Added check that Fragment is not null
This commit is contained in:
parent
5e500fa653
commit
4f654f3b72
1 changed files with 27 additions and 22 deletions
|
|
@ -133,34 +133,39 @@ public class CategorizationFragment extends SherlockFragment{
|
|||
|
||||
protected void setCatsAfterAsync(ArrayList<String> categories, String filter) {
|
||||
|
||||
ArrayList<CategoryItem> items = new ArrayList<CategoryItem>();
|
||||
HashSet<String> existingKeys = new HashSet<String>();
|
||||
for(CategoryItem item : categoriesAdapter.getItems()) {
|
||||
if(item.selected) {
|
||||
items.add(item);
|
||||
existingKeys.add(item.name);
|
||||
if (getActivity() != null) {
|
||||
ArrayList<CategoryItem> items = new ArrayList<CategoryItem>();
|
||||
HashSet<String> existingKeys = new HashSet<String>();
|
||||
for (CategoryItem item : categoriesAdapter.getItems()) {
|
||||
if (item.selected) {
|
||||
items.add(item);
|
||||
existingKeys.add(item.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
for(String category : categories) {
|
||||
if(!existingKeys.contains(category)) {
|
||||
items.add(new CategoryItem(category, false));
|
||||
for (String category : categories) {
|
||||
if (!existingKeys.contains(category)) {
|
||||
items.add(new CategoryItem(category, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
categoriesAdapter.setItems(items);
|
||||
categoriesAdapter.notifyDataSetInvalidated();
|
||||
categoriesSearchInProgress.setVisibility(View.GONE);
|
||||
categoriesAdapter.setItems(items);
|
||||
categoriesAdapter.notifyDataSetInvalidated();
|
||||
categoriesSearchInProgress.setVisibility(View.GONE);
|
||||
|
||||
if (categories.isEmpty()) {
|
||||
if(TextUtils.isEmpty(filter)) {
|
||||
// If we found no recent cats, show the skip message!
|
||||
categoriesSkip.setVisibility(View.VISIBLE);
|
||||
if (categories.isEmpty()) {
|
||||
if (TextUtils.isEmpty(filter)) {
|
||||
// If we found no recent cats, show the skip message!
|
||||
categoriesSkip.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
categoriesNotFoundView.setText(getString(R.string.categories_not_found, filter));
|
||||
categoriesNotFoundView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
} else {
|
||||
categoriesNotFoundView.setText(getString(R.string.categories_not_found, filter));
|
||||
categoriesNotFoundView.setVisibility(View.VISIBLE);
|
||||
categoriesList.smoothScrollToPosition(existingKeys.size());
|
||||
}
|
||||
} else {
|
||||
categoriesList.smoothScrollToPosition(existingKeys.size());
|
||||
}
|
||||
else {
|
||||
Log.e(TAG, "Error: Fragment is null");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue