mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-26 22:47:59 +01:00
catch exceptions thrown at fixing date taken values
This commit is contained in:
parent
429925ba18
commit
21305a6d6d
1 changed files with 45 additions and 30 deletions
|
@ -102,7 +102,8 @@ fun SimpleActivity.launchAbout() {
|
||||||
FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons),
|
FAQItem(R.string.faq_6_title_commons, R.string.faq_6_text_commons),
|
||||||
FAQItem(R.string.faq_7_title_commons, R.string.faq_7_text_commons),
|
FAQItem(R.string.faq_7_title_commons, R.string.faq_7_text_commons),
|
||||||
FAQItem(R.string.faq_9_title_commons, R.string.faq_9_text_commons),
|
FAQItem(R.string.faq_9_title_commons, R.string.faq_9_text_commons),
|
||||||
FAQItem(R.string.faq_10_title_commons, R.string.faq_10_text_commons))
|
FAQItem(R.string.faq_10_title_commons, R.string.faq_10_text_commons)
|
||||||
|
)
|
||||||
|
|
||||||
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
|
startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true)
|
||||||
}
|
}
|
||||||
|
@ -240,8 +241,10 @@ fun BaseSimpleActivity.tryCopyMoveFilesTo(fileDirItems: ArrayList<FileDirItem>,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun BaseSimpleActivity.tryDeleteFileDirItem(fileDirItem: FileDirItem, allowDeleteFolder: Boolean = false, deleteFromDatabase: Boolean,
|
fun BaseSimpleActivity.tryDeleteFileDirItem(
|
||||||
callback: ((wasSuccess: Boolean) -> Unit)? = null) {
|
fileDirItem: FileDirItem, allowDeleteFolder: Boolean = false, deleteFromDatabase: Boolean,
|
||||||
|
callback: ((wasSuccess: Boolean) -> Unit)? = null
|
||||||
|
) {
|
||||||
deleteFile(fileDirItem, allowDeleteFolder) {
|
deleteFile(fileDirItem, allowDeleteFolder) {
|
||||||
if (deleteFromDatabase) {
|
if (deleteFromDatabase) {
|
||||||
ensureBackgroundThread {
|
ensureBackgroundThread {
|
||||||
|
@ -445,7 +448,8 @@ fun AppCompatActivity.fixDateTaken(
|
||||||
val dateTakens = ArrayList<DateTaken>()
|
val dateTakens = ArrayList<DateTaken>()
|
||||||
|
|
||||||
for (path in paths) {
|
for (path in paths) {
|
||||||
val dateTime = ExifInterface(path).getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL)
|
try {
|
||||||
|
val dateTime: String = ExifInterface(path).getAttribute(ExifInterface.TAG_DATETIME_ORIGINAL)
|
||||||
?: ExifInterface(path).getAttribute(ExifInterface.TAG_DATETIME) ?: continue
|
?: ExifInterface(path).getAttribute(ExifInterface.TAG_DATETIME) ?: continue
|
||||||
|
|
||||||
// some formats contain a "T" in the middle, some don't
|
// some formats contain a "T" in the middle, some don't
|
||||||
|
@ -473,11 +477,22 @@ fun AppCompatActivity.fixDateTaken(
|
||||||
mediaDB.updateFavoriteDateTaken(path, timestamp)
|
mediaDB.updateFavoriteDateTaken(path, timestamp)
|
||||||
didUpdateFile = true
|
didUpdateFile = true
|
||||||
|
|
||||||
val dateTaken = DateTaken(null, path, path.getFilenameFromPath(), path.getParentPath(), timestamp, (System.currentTimeMillis() / 1000).toInt(), File(path).lastModified())
|
val dateTaken = DateTaken(
|
||||||
|
null,
|
||||||
|
path,
|
||||||
|
path.getFilenameFromPath(),
|
||||||
|
path.getParentPath(),
|
||||||
|
timestamp,
|
||||||
|
(System.currentTimeMillis() / 1000).toInt(),
|
||||||
|
File(path).lastModified()
|
||||||
|
)
|
||||||
dateTakens.add(dateTaken)
|
dateTakens.add(dateTaken)
|
||||||
if (!hasRescanned && getFileDateTaken(path) == 0L) {
|
if (!hasRescanned && getFileDateTaken(path) == 0L) {
|
||||||
pathsToRescan.add(path)
|
pathsToRescan.add(path)
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!didUpdateFile) {
|
if (!didUpdateFile) {
|
||||||
|
|
Loading…
Reference in a new issue