tweak the way files are deleted
This commit is contained in:
parent
6e6ea3a257
commit
bf952f71cf
|
@ -200,6 +200,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread({
|
Thread({
|
||||||
|
if (!file.delete()) {
|
||||||
if (needsPermissions) {
|
if (needsPermissions) {
|
||||||
val document = getFileDocument(file.absolutePath, config.treeUri)
|
val document = getFileDocument(file.absolutePath, config.treeUri)
|
||||||
|
|
||||||
|
@ -209,8 +210,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
||||||
if (uri.endsWith(filename)) {
|
if (uri.endsWith(filename)) {
|
||||||
document.delete()
|
document.delete()
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
file.delete()
|
|
||||||
}
|
}
|
||||||
}).start()
|
}).start()
|
||||||
}
|
}
|
||||||
|
|
|
@ -237,6 +237,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
var hadSuccess = false
|
var hadSuccess = false
|
||||||
files.filter { it.exists() && it.isImageVideoGif() }
|
files.filter { it.exists() && it.isImageVideoGif() }
|
||||||
.forEach {
|
.forEach {
|
||||||
|
if (!it.delete()) {
|
||||||
if (needsPermissions) {
|
if (needsPermissions) {
|
||||||
val document = getFileDocument(it.absolutePath, config.treeUri)
|
val document = getFileDocument(it.absolutePath, config.treeUri)
|
||||||
|
|
||||||
|
@ -248,9 +249,9 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
||||||
hadSuccess = true
|
hadSuccess = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (it.delete())
|
|
||||||
hadSuccess = true
|
hadSuccess = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
deleteFromMediaStore(it)
|
deleteFromMediaStore(it)
|
||||||
}
|
}
|
||||||
if (!hadSuccess)
|
if (!hadSuccess)
|
||||||
|
|
|
@ -8,6 +8,7 @@ import android.graphics.BitmapFactory
|
||||||
import android.graphics.Matrix
|
import android.graphics.Matrix
|
||||||
import android.media.ExifInterface
|
import android.media.ExifInterface
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.MediaStore
|
import android.provider.MediaStore
|
||||||
import android.support.v4.view.ViewPager
|
import android.support.v4.view.ViewPager
|
||||||
|
@ -286,7 +287,6 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return (floatD + floatM / 60 + floatS / 3600).toFloat()
|
return (floatD + floatM / 60 + floatS / 3600).toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
override fun onActivityResult(requestCode: Int, resultCode: Int, resultData: Intent?) {
|
||||||
if (requestCode == REQUEST_EDIT_IMAGE) {
|
if (requestCode == REQUEST_EDIT_IMAGE) {
|
||||||
if (resultCode == Activity.RESULT_OK && resultData != null) {
|
if (resultCode == Activity.RESULT_OK && resultData != null) {
|
||||||
|
@ -314,7 +314,8 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread({
|
Thread {
|
||||||
|
if (!file.delete()) {
|
||||||
if (needsPermissions) {
|
if (needsPermissions) {
|
||||||
val document = getFileDocument(file.absolutePath, config.treeUri)
|
val document = getFileDocument(file.absolutePath, config.treeUri)
|
||||||
|
|
||||||
|
@ -329,8 +330,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
}
|
}
|
||||||
return@Thread
|
return@Thread
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
file.delete()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (deleteFromMediaStore(file)) {
|
if (deleteFromMediaStore(file)) {
|
||||||
|
@ -340,7 +340,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
reloadViewPager()
|
reloadViewPager()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start()
|
}.start()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isDirEmpty(): Boolean {
|
private fun isDirEmpty(): Boolean {
|
||||||
|
|
Loading…
Reference in New Issue