Skip to content

Instantly share code, notes, and snippets.

@pranay1494
Last active June 15, 2020 18:57
Show Gist options
  • Save pranay1494/8c69a627359783960dd700fece3899f7 to your computer and use it in GitHub Desktop.
Save pranay1494/8c69a627359783960dd700fece3899f7 to your computer and use it in GitHub Desktop.
override fun onSectionClicked(entity: Sections, absolutePosition: Int) {
if (viewModel.orignalSectionList.size <= 1) return
val mainAdapter = adapterWrapper.getMainAdapter()
adapterWrapper.swapAdapter()
viewModel.sectionList.forEachIndexed { index, section ->
val nestedSelectHeaderAdapter = NestedSelectHeaderAdapter(section, this@NestedFilterViewFragment)
mainAdapter.addAdapter(nestedSelectHeaderAdapter)
if (entity.sectionIndex == index && section.isSelected) {
addAdapterToMergeAdapter(section, index + 1)
}
}
adapterWrapper.refreshAdapters()
}
private fun addAdapterToMergeAdapter(element: Sections, elementPosition: Int) {
adapterWrapper.addAdapterAt(
elementPosition,
FilterSelectionAdapter(
element.items.toMutableList(),
element.isMultiSelectEnabled
).apply {
setComponentInteractionListener(this@NestedFilterViewFragment)
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment