diff --git a/build.gradle b/build.gradle index 4cdd829a8..5ff977f1b 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { propMinSdkVersion = 16 propTargetSdkVersion = propCompileSdkVersion propVersionCode = 1 - propVersionName = '4.2.0' + propVersionName = '4.2.1' kotlin_version = '1.2.50' support_libs = '27.1.1' } diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/adapters/FilepickerItemsAdapter.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/adapters/FilepickerItemsAdapter.kt index 9f09f3bed..a1f378e73 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/adapters/FilepickerItemsAdapter.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/adapters/FilepickerItemsAdapter.kt @@ -31,7 +31,7 @@ class FilepickerItemsAdapter(activity: BaseSimpleActivity, val fileDirItems: Lis override fun prepareItemSelection(viewHolder: ViewHolder) {} - override fun markItemHolderSelection(select: Boolean, viewHolder: ViewHolder?) {} + override fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) {} override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) = createViewHolder(R.layout.filepicker_list_item, parent) diff --git a/commons/src/main/kotlin/com/simplemobiletools/commons/adapters/MyRecyclerViewAdapter.kt b/commons/src/main/kotlin/com/simplemobiletools/commons/adapters/MyRecyclerViewAdapter.kt index 187d4b458..5c0cd5aba 100644 --- a/commons/src/main/kotlin/com/simplemobiletools/commons/adapters/MyRecyclerViewAdapter.kt +++ b/commons/src/main/kotlin/com/simplemobiletools/commons/adapters/MyRecyclerViewAdapter.kt @@ -28,7 +28,7 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc protected var primaryColor = baseConfig.primaryColor protected var textColor = baseConfig.textColor protected var backgroundColor = baseConfig.backgroundColor - protected var itemHolders = SparseArray() + protected var viewHolders = SparseArray() protected val selectedPositions = HashSet() protected var positionOffset = 0 @@ -41,7 +41,7 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc abstract fun prepareItemSelection(viewHolder: ViewHolder) - abstract fun markItemHolderSelection(select: Boolean, viewHolder: ViewHolder?) + abstract fun markViewHolderSelection(select: Boolean, viewHolder: ViewHolder?) abstract fun prepareActionMode(menu: Menu) @@ -53,15 +53,15 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc protected fun toggleItemSelection(select: Boolean, pos: Int) { if (select) { - if (itemHolders[pos] != null) { - prepareItemSelection(itemHolders[pos]) + if (viewHolders[pos] != null) { + prepareItemSelection(viewHolders[pos]) } selectedPositions.add(pos) } else { selectedPositions.remove(pos) } - markItemHolderSelection(select, itemHolders[pos]) + markViewHolderSelection(select, viewHolders[pos]) if (selectedPositions.isEmpty()) { finishActMode() @@ -236,7 +236,7 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc override fun onDestroyActionMode(actionMode: ActionMode?) { super.onDestroyActionMode(actionMode) selectedPositions.forEach { - markItemHolderSelection(false, itemHolders[it]) + markViewHolderSelection(false, viewHolders[it]) } selectedPositions.clear() actBarTextView?.text = "" @@ -251,17 +251,17 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc } protected fun bindViewHolder(holder: MyRecyclerViewAdapter.ViewHolder, position: Int, view: View) { - itemHolders.put(position, holder) + viewHolders.put(position, holder) toggleItemSelection(selectedPositions.contains(position), position) holder.itemView.tag = holder } override fun onViewRecycled(holder: ViewHolder) { super.onViewRecycled(holder) - val pos = itemHolders.indexOfValue(holder) + val pos = viewHolders.indexOfValue(holder) try { if (pos != -1) { - itemHolders.removeAt(pos) + viewHolders.removeAt(pos) } } catch (ignored: ArrayIndexOutOfBoundsException) { } @@ -269,17 +269,17 @@ abstract class MyRecyclerViewAdapter(val activity: BaseSimpleActivity, val recyc protected fun removeSelectedItems() { val newViewHolders = SparseArray() - val cnt = itemHolders.size() + val cnt = viewHolders.size() for (i in 0..cnt) { if (selectedPositions.contains(i)) { continue } - val view = itemHolders.get(i, null) + val view = viewHolders.get(i, null) val newIndex = i - selectedPositions.count { it <= i } newViewHolders.put(newIndex, view) } - itemHolders = newViewHolders + viewHolders = newViewHolders selectedPositions.sortedDescending().forEach { notifyItemRemoved(it + positionOffset)