add some array size checks at deleting from media/directory view
This commit is contained in:
parent
6e1f56f864
commit
ae3555b1c5
2 changed files with 12 additions and 5 deletions
|
@ -297,11 +297,13 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
|
||||||
|
|
||||||
activity.handleSAFDialog(File(needPermissionForPath)) {
|
activity.handleSAFDialog(File(needPermissionForPath)) {
|
||||||
selectedPositions.sortedDescending().forEach {
|
selectedPositions.sortedDescending().forEach {
|
||||||
val directory = dirs[it]
|
if (dirs.size > it) {
|
||||||
folders.add(File(directory.path))
|
val directory = dirs[it]
|
||||||
removeFolders.add(directory)
|
folders.add(File(directory.path))
|
||||||
notifyItemRemoved(it)
|
removeFolders.add(directory)
|
||||||
itemViews.put(it, null)
|
notifyItemRemoved(it)
|
||||||
|
itemViews.put(it, null)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dirs.removeAll(removeFolders)
|
dirs.removeAll(removeFolders)
|
||||||
|
|
|
@ -232,6 +232,11 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
||||||
val files = ArrayList<File>(selectedPositions.size)
|
val files = ArrayList<File>(selectedPositions.size)
|
||||||
val removeMedia = ArrayList<Medium>(selectedPositions.size)
|
val removeMedia = ArrayList<Medium>(selectedPositions.size)
|
||||||
|
|
||||||
|
if (media.size <= selectedPositions.first()) {
|
||||||
|
actMode?.finish()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
activity.handleSAFDialog(File(media[selectedPositions.first()].path)) {
|
activity.handleSAFDialog(File(media[selectedPositions.first()].path)) {
|
||||||
selectedPositions.sortedDescending().forEach {
|
selectedPositions.sortedDescending().forEach {
|
||||||
val medium = media[it]
|
val medium = media[it]
|
||||||
|
|
Loading…
Reference in a new issue