make sure copyRecursively works at moving paths in recycle bin

This commit is contained in:
tibbi 2018-07-17 13:56:22 +02:00
parent fa2eb4f7ed
commit 26d5fef4fd
2 changed files with 6 additions and 4 deletions

View file

@ -47,7 +47,7 @@ ext {
}
dependencies {
implementation 'com.simplemobiletools:commons:4.4.24'
implementation 'com.simplemobiletools:commons:4.4.27'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
implementation 'com.android.support:multidex:1.0.3'
implementation 'it.sephiroth.android.exif:library:1.0.1'

View file

@ -201,14 +201,16 @@ fun BaseSimpleActivity.tryDeleteFileDirItem(fileDirItem: FileDirItem, allowDelet
fun BaseSimpleActivity.movePathsInRecycleBin(paths: ArrayList<String>, callback: ((wasSuccess: Boolean) -> Unit)?) {
Thread {
val mediumDao = galleryDB.MediumDao()
var pathsCnt = paths.size
paths.forEach {
val file = File(it)
val internalFile = File(filesDir, it)
try {
file.copyRecursively(internalFile, true)
galleryDB.MediumDao().updateDeleted(it, System.currentTimeMillis())
pathsCnt--
if (file.copyRecursively(internalFile, true)) {
mediumDao.updateDeleted(it, System.currentTimeMillis())
pathsCnt--
}
} catch (ignored: Exception) {
}
}