Skip to content

Instantly share code, notes, and snippets.

@jeffdgr8
Last active August 23, 2023 08:23
Show Gist options
  • Save jeffdgr8/61a4c6432401bf2740cd17cd04f7ee4e to your computer and use it in GitHub Desktop.
Save jeffdgr8/61a4c6432401bf2740cd17cd04f7ee4e to your computer and use it in GitHub Desktop.
SectionedRecyclerViewAdapter that implements StickyHeaderHandler for using https://github.com/bgogetap/StickyHeaders with https://github.com/luizgrp/SectionedRecyclerViewAdapter
import com.brandongogetap.stickyheaders.exposed.StickyHeader
import com.brandongogetap.stickyheaders.exposed.StickyHeaderHandler
import io.github.luizgrp.sectionedrecyclerviewadapter.SectionedRecyclerViewAdapter
/**
* [SectionedRecyclerViewAdapter] that implements [StickyHeaderHandler].
*/
class StickyHeaderSectionedRecyclerViewAdapter: SectionedRecyclerViewAdapter(), StickyHeaderHandler {
override fun getAdapterData(): List<*> {
val data = ArrayList<StickyHeader?>()
copyOfSectionsMap.values.forEach { section ->
if (section.hasHeader()) {
data.add(StickyHeaderImpl())
}
repeat(section.contentItemsTotal) { data.add(null) }
}
return data
}
class StickyHeaderImpl: StickyHeader
}
@tamhuynhit
Copy link

Thank you a lot, 4 years already but still helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment