lets try rescanning all paths at "Fix Date Taken values", before updating them

This commit is contained in:
tibbi 2019-04-01 19:17:01 +02:00
parent c7f57842c8
commit 2d34288550
1 changed files with 34 additions and 33 deletions

View File

@ -330,6 +330,7 @@ fun Activity.fixDateTaken(paths: ArrayList<String>, callback: (() -> Unit)? = nu
var didUpdateFile = false
val operations = ArrayList<ContentProviderOperation>()
val mediumDao = galleryDB.MediumDao()
rescanPaths(paths) {
for (path in paths) {
val dateTime = ExifInterface(path).getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL)
?: ExifInterface(path).getAttribute(ExifInterface.TAG_DATETIME) ?: continue
@ -363,13 +364,13 @@ fun Activity.fixDateTaken(paths: ArrayList<String>, callback: (() -> Unit)? = nu
val resultSize = contentResolver.applyBatch(MediaStore.AUTHORITY, operations).size
if (resultSize == 0) {
didUpdateFile = false
rescanPaths(paths)
}
toast(if (didUpdateFile) R.string.dates_fixed_successfully else R.string.unknown_error_occurred)
runOnUiThread {
callback?.invoke()
}
}
} catch (e: Exception) {
showErrorToast(e)
}