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

View file

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