use the helper function at deleting recyclerview items
This commit is contained in:
parent
d80f9a3698
commit
555dc21a35
3 changed files with 5 additions and 28 deletions
|
@ -46,7 +46,7 @@ ext {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.simplemobiletools:commons:3.0.5'
|
||||
implementation 'com.simplemobiletools:commons:3.0.6'
|
||||
|
||||
implementation files('../libs/RootTools.jar')
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.content.ClipboardManager
|
|||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.Uri
|
||||
import android.util.SparseArray
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -340,7 +339,6 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
private fun askConfirmDelete() {
|
||||
ConfirmationDialog(activity) {
|
||||
deleteFiles()
|
||||
finishActMode()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,27 +348,18 @@ class ItemsAdapter(activity: SimpleActivity, var fileDirItems: MutableList<FileD
|
|||
|
||||
val files = ArrayList<File>(selectedPositions.size)
|
||||
val removeFiles = ArrayList<FileDirItem>(selectedPositions.size)
|
||||
val SAFFile = File(fileDirItems[selectedPositions.first()].path)
|
||||
|
||||
activity.handleSAFDialog(File(fileDirItems[selectedPositions.first()].path)) {
|
||||
activity.handleSAFDialog(SAFFile) {
|
||||
selectedPositions.sortedDescending().forEach {
|
||||
val file = fileDirItems[it]
|
||||
files.add(File(file.path))
|
||||
removeFiles.add(file)
|
||||
notifyItemRemoved(it)
|
||||
itemViews.put(it, null)
|
||||
}
|
||||
|
||||
fileDirItems.removeAll(removeFiles)
|
||||
selectedPositions.clear()
|
||||
listener?.deleteFiles(files)
|
||||
|
||||
val newItems = SparseArray<View>()
|
||||
(0 until itemViews.size())
|
||||
.filter { itemViews[it] != null }
|
||||
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
|
||||
|
||||
itemViews = newItems
|
||||
selectableItemCount = fileDirItems.size
|
||||
removeSelectedItems()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package com.simplemobiletools.filemanager.adapters
|
||||
|
||||
import android.util.SparseArray
|
||||
import android.view.Menu
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
|
@ -71,22 +70,11 @@ class ManageFavoritesAdapter(activity: BaseSimpleActivity, var favorites: ArrayL
|
|||
selectedPositions.sortedDescending().forEach {
|
||||
val favorite = favorites[it]
|
||||
removeFavorites.add(favorite)
|
||||
notifyItemRemoved(it)
|
||||
itemViews.put(it, null)
|
||||
config.removeFavorite(favorite)
|
||||
}
|
||||
|
||||
favorites.removeAll(removeFavorites)
|
||||
selectedPositions.clear()
|
||||
|
||||
val newItems = SparseArray<View>()
|
||||
(0 until itemViews.size())
|
||||
.filter { itemViews[it] != null }
|
||||
.forEachIndexed { curIndex, i -> newItems.put(curIndex, itemViews[i]) }
|
||||
|
||||
itemViews = newItems
|
||||
selectableItemCount = favorites.size
|
||||
finishActMode()
|
||||
removeSelectedItems()
|
||||
if (favorites.isEmpty()) {
|
||||
listener?.refreshItems()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue