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

Commit 9796a7b2 authored by tibbi's avatar tibbi
Browse files

add a helper function at recyclerview adapter to remove selected items

parent 342646b1
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 = '3.0.5'
        propVersionName = '3.0.6'
        kotlin_version = '1.2.0'
        support_libs = '27.0.2'
    }
+16 −0
Original line number Diff line number Diff line
@@ -215,6 +215,22 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc
        holder.itemView.tag = holder
    }

    fun removeSelectedItems() {
        selectedPositions.sortedDescending().forEach {
            notifyItemRemoved(it)
            itemViews.put(it, null)
        }

        val newItems = SparseArray<View>()
        (0 until itemViews.size())
                .filter { itemViews[it] != null }
                .forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }

        itemViews = newItems
        selectableItemCount = itemCount
        finishActMode()
    }

    class ViewHolder(view: View, val adapterListener: MyAdapterListener, val activity: BaseSimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
                     val multiSelector: MultiSelector, val itemClick: (Any) -> (Unit)) : SwappingHolder(view, multiSelector) {
        fun bindView(any: Any, allowLongClick: Boolean = true, callback: (itemView: View, layoutPosition: Int) -> Unit): View {