Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0279f279 authored by tibbi's avatar tibbi
Browse files

adding a helper recyclerview adapter function for getting selected item positions

parent 086fc7b7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ buildscript {
        propMinSdkVersion = 21
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '5.0.21'
        propVersionName = '5.0.22'
        kotlin_version = '1.2.71'
    }

+15 −0
Original line number Diff line number Diff line
@@ -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) {