Last active
May 22, 2018 22:50
-
-
Save jungilhan/daf0397e1fb8fef37e2814b30219c736 to your computer and use it in GitHub Desktop.
SelectionTracker.Builder
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
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