Skip to content

Instantly share code, notes, and snippets.

@jungilhan
Last active May 22, 2018 22:50
Show Gist options
  • Save jungilhan/daf0397e1fb8fef37e2814b30219c736 to your computer and use it in GitHub Desktop.
Save jungilhan/daf0397e1fb8fef37e2814b30219c736 to your computer and use it in GitHub Desktop.
SelectionTracker.Builder
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
...
selectionTracker = SelectionTracker.Builder(
"selection-demo",
recyclerView,
StableIdKeyProvider(recyclerView),
itemDetailsLookup,
StorageStrategy.createLongStorage())
.withSelectionPredicate(selectionPredicate)
.build()
selectionTracker.addObserver(object : SelectionTracker.SelectionObserver<Long>() {
override fun onSelectionChanged() {
title = if (selectionTracker.hasSelection()) {
"Selection ${selectionTracker.selection.size()} / $MAXIMUM_SELECTION"
} else {
RecyclerViewSelectionActivity::class.java.simpleName
}
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment