couple threading fixes related to delete
This commit is contained in:
parent
051ba24296
commit
a0ec0de5a4
5 changed files with 25 additions and 22 deletions
|
@ -190,11 +190,16 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
val document = getFileDocument(file.absolutePath, config.treeUri)
|
||||
|
||||
// double check we have the uri to the proper file path, not some parent folder
|
||||
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory)
|
||||
document.delete()
|
||||
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath())) {
|
||||
Thread({
|
||||
document.delete()
|
||||
}).start()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
file.delete()
|
||||
Thread({
|
||||
file.delete()
|
||||
}).start()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -214,10 +214,14 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
|
||||
// double check we have the uri to the proper file path, not some parent folder
|
||||
if (document.uri.toString().endsWith(it.absolutePath.getFilenameFromPath()) && !document.isDirectory) {
|
||||
document.delete()
|
||||
Thread({
|
||||
document.delete()
|
||||
}).start()
|
||||
}
|
||||
} else {
|
||||
it.delete()
|
||||
Thread({
|
||||
it.delete()
|
||||
}).start()
|
||||
}
|
||||
|
||||
deleteFromMediaStore(it)
|
||||
|
|
|
@ -160,9 +160,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
|
||||
private fun askConfirmDelete() {
|
||||
ConfirmationDialog(this) {
|
||||
Thread({
|
||||
deleteFile()
|
||||
}).start()
|
||||
deleteFile()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,10 +173,14 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
|||
if (!isShowingPermDialog(file)) {
|
||||
val document = getFileDocument(mPath, config.treeUri)
|
||||
if (document.uri.toString().endsWith(file.absolutePath.getFilenameFromPath()) && !document.isDirectory)
|
||||
document.delete()
|
||||
Thread({
|
||||
document.delete()
|
||||
}).start()
|
||||
}
|
||||
} else {
|
||||
file.delete()
|
||||
Thread({
|
||||
file.delete()
|
||||
}).start()
|
||||
}
|
||||
|
||||
if (deleteFromMediaStore(file)) {
|
||||
|
|
|
@ -231,9 +231,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
private fun askConfirmDelete() {
|
||||
ConfirmationDialog(activity) {
|
||||
actMode?.finish()
|
||||
Thread({
|
||||
deleteFiles()
|
||||
}).start()
|
||||
deleteFiles()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,9 +245,7 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
val directory = dirs[it]
|
||||
paths.add(directory.path)
|
||||
removeDirs.add(directory)
|
||||
activity.runOnUiThread {
|
||||
notifyItemRemoved(it)
|
||||
}
|
||||
notifyItemRemoved(it)
|
||||
}
|
||||
|
||||
dirs.removeAll(removeDirs)
|
||||
|
|
|
@ -171,9 +171,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
private fun askConfirmDelete() {
|
||||
ConfirmationDialog(activity) {
|
||||
actMode?.finish()
|
||||
Thread({
|
||||
deleteFiles()
|
||||
}).start()
|
||||
deleteFiles()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,9 +187,7 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
val medium = media[it]
|
||||
files.add(File(medium.path))
|
||||
removeMedia.add(medium)
|
||||
activity.runOnUiThread {
|
||||
notifyItemRemoved(it)
|
||||
}
|
||||
notifyItemRemoved(it)
|
||||
}
|
||||
|
||||
media.removeAll(removeMedia)
|
||||
|
|
Loading…
Reference in a new issue