mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +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,16 +133,17 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
|
|
||||||
protected void setCatsAfterAsync(ArrayList<String> categories, String filter) {
|
protected void setCatsAfterAsync(ArrayList<String> categories, String filter) {
|
||||||
|
|
||||||
|
if (getActivity() != null) {
|
||||||
ArrayList<CategoryItem> items = new ArrayList<CategoryItem>();
|
ArrayList<CategoryItem> items = new ArrayList<CategoryItem>();
|
||||||
HashSet<String> existingKeys = new HashSet<String>();
|
HashSet<String> existingKeys = new HashSet<String>();
|
||||||
for(CategoryItem item : categoriesAdapter.getItems()) {
|
for (CategoryItem item : categoriesAdapter.getItems()) {
|
||||||
if(item.selected) {
|
if (item.selected) {
|
||||||
items.add(item);
|
items.add(item);
|
||||||
existingKeys.add(item.name);
|
existingKeys.add(item.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(String category : categories) {
|
for (String category : categories) {
|
||||||
if(!existingKeys.contains(category)) {
|
if (!existingKeys.contains(category)) {
|
||||||
items.add(new CategoryItem(category, false));
|
items.add(new CategoryItem(category, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -152,7 +153,7 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
categoriesSearchInProgress.setVisibility(View.GONE);
|
categoriesSearchInProgress.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (categories.isEmpty()) {
|
if (categories.isEmpty()) {
|
||||||
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!
|
||||||
categoriesSkip.setVisibility(View.VISIBLE);
|
categoriesSkip.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -163,6 +164,10 @@ public class CategorizationFragment extends SherlockFragment{
|
||||||
categoriesList.smoothScrollToPosition(existingKeys.size());
|
categoriesList.smoothScrollToPosition(existingKeys.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Log.e(TAG, "Error: Fragment is null");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private class CategoriesAdapter extends BaseAdapter {
|
private class CategoriesAdapter extends BaseAdapter {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue