adding a helper recyclerview adapter function for getting selected item positions

This commit is contained in:
tibbi 2018-10-15 14:29:42 +02:00
parent 086fc7b7dc
commit 0279f27988
2 changed files with 16 additions and 1 deletions

View file

@ -7,7 +7,7 @@ buildscript {
propMinSdkVersion = 21
propTargetSdkVersion = propCompileSdkVersion
propVersionCode = 1
propVersionName = '5.0.21'
propVersionName = '5.0.22'
kotlin_version = '1.2.71'
}

View file

@ -147,6 +147,21 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc
protected fun isKeySelected(key: Int) = selectedKeys.contains(key)
protected fun getSelectedItemPositions(keys: List<Int>, sortDescending: Boolean = true): ArrayList<Int> {
val positions = ArrayList<Int>()
keys.forEach {
val position = getItemKeyPosition(it)
if (position != -1) {
positions.add(position)
}
}
if (sortDescending) {
positions.sortDescending()
}
return positions
}
protected fun selectAll() {
val cnt = itemCount - positionOffset
for (i in 0 until cnt) {