[android] Fixed update collection and categories when hide all/show all button was pressed.

This commit is contained in:
velichkomarija 2020-11-25 15:01:22 +03:00 committed by Alexander Boriskov
parent 6e481ec3c6
commit c6b3fa0567

View file

@ -66,9 +66,15 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
BookmarkManager.INSTANCE.toggleCompilationVisibility(category, type);
if (type == BookmarkManager.COLLECTION)
{
notifyItemChanged(0);
mItemsCollection = BookmarkManager.INSTANCE.getChildrenCollections(mBookmarkCategory.getId());
}
else if (mItemsCollection.size() > 0)
{
notifyItemChanged(mItemsCollection.size() + 1);
mItemsCategory = BookmarkManager.INSTANCE.getChildrenCategories(mBookmarkCategory.getId());
}
else
notifyItemChanged(0);
}
@ -262,12 +268,10 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
return itemCount;
}
private void updateItemsByType(@BookmarkManager.CompilationType int compilationType)
private void updateAllItems()
{
if (compilationType == BookmarkManager.COLLECTION)
mItemsCollection = BookmarkManager.INSTANCE.getChildrenCollections(mBookmarkCategory.getId());
else
mItemsCategory = BookmarkManager.INSTANCE.getChildrenCategories(mBookmarkCategory.getId());
mItemsCollection = BookmarkManager.INSTANCE.getChildrenCollections(mBookmarkCategory.getId());
mItemsCategory = BookmarkManager.INSTANCE.getChildrenCategories(mBookmarkCategory.getId());
}
void show(boolean visible)
@ -283,7 +287,7 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
{
BookmarkManager.INSTANCE.setChildCategoriesVisibility(mBookmarkCategory.getId(),
compilationType, false);
updateItemsByType(compilationType);
updateAllItems();
notifyDataSetChanged();
}
@ -292,7 +296,7 @@ public class BookmarkCollectionAdapter extends RecyclerView.Adapter<RecyclerView
{
BookmarkManager.INSTANCE.setChildCategoriesVisibility(mBookmarkCategory.getId(),
compilationType, true);
updateItemsByType(compilationType);
updateAllItems();
notifyDataSetChanged();
}
}