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

Commit ec10a6b7 authored by tibbi's avatar tibbi
Browse files

make sure we dont select unselectable items at recyclerviews, like section titles

parent 1c0b3d41
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@ buildscript {
        propMinSdkVersion = 16
        propTargetSdkVersion = propCompileSdkVersion
        propVersionCode = 1
        propVersionName = '4.2.9'
        propVersionName = '4.2.10'
        kotlin_version = '1.2.50'
        support_libs = '27.1.1'
    }
+2 −0
Original line number Diff line number Diff line
@@ -51,6 +51,8 @@ class FilepickerItemsAdapter(activity: BaseSimpleActivity, val fileDirItems: Lis

    override fun getSelectableItemCount() = fileDirItems.size

    override fun getIsItemSelectable(position: Int) = false

    override fun onViewRecycled(holder: MyRecyclerViewAdapter.ViewHolder) {
        super.onViewRecycled(holder)
        if (!activity.isActivityDestroyed()) {
+10 −2
Original line number Diff line number Diff line
@@ -49,9 +49,15 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc

    abstract fun getSelectableItemCount(): Int

    abstract fun getIsItemSelectable(position: Int): Boolean

    protected fun isOneItemSelected() = selectedPositions.size == 1

    protected fun toggleItemSelection(select: Boolean, pos: Int) {
        if (select && !getIsItemSelectable(pos)) {
            return
        }

        if (select) {
            if (viewHolders[pos] != null) {
                prepareItemSelection(viewHolders[pos])
@@ -85,9 +91,11 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc
    protected fun selectAll() {
        val cnt = itemCount - positionOffset
        for (i in 0 until cnt) {
            if (getIsItemSelectable(i)) {
                selectedPositions.add(i)
                notifyItemChanged(i + positionOffset)
            }
        }
        updateTitle(cnt)
        lastLongPressedItem = -1
    }