I cannot find a way to expand nested items using FastAdapter library.
Example:
Category 1
-- Subcategory 1 // Subitem of category
++ SubSubCategory 1 // Subitem of subcategory
++ SubSubCategory 2
-- Subcategory 2
++ SubSubCategory 3
++ SubSubCategory 4
Category 2
-- Subcategory 1
-- Subcategory 2
I'd like to expand "SubSubCategory 2". It works when I'm doing it manually, by clicking (obviously). But in some cases, I'd like to open it programmatically. I know how to do it if I'd like to open Subcategory - getExpandableExtension().expand(globalPosition)
. But how can I do that with SubSubCategory? I don't know any way to get their position. Changing isExpanded flag also doesn't help. I know the identifier of the item I'd like to open.
UPDATE:
It is now possible with the usage of the method expandAllOnPath
that was added in v5.2.2.
Thanks to the author of the library I realized why I couldn't find the nested object. I should have expanded it layer by layer, so first categories, then subcategories.
private fun expand(item: GenericItem) {
// Get position of the item.
val relativePosition = myAdapter.itemAdapter.getAdapterPosition(item)
val globalPosition = myAdapter.itemAdapter.getGlobalPosition(relativePosition)
// Expand item.
categoriesAdapter.getExpandableExtension().expand(globalPosition)
}
Finally, I simply used the above method twice, the first level then the next one.