Last active
August 23, 2023 08:23
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you a lot, 4 years already but still helpful