adding some try/catch blocks

This commit is contained in:
tibbi 2020-10-01 17:23:29 +02:00
parent 7e0ebaace9
commit 60b44c27be
2 changed files with 31 additions and 25 deletions

View file

@ -77,7 +77,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.simplemobiletools:commons:5.30.17' implementation 'com.simplemobiletools:commons:5.30.25'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.19'

View file

@ -481,20 +481,23 @@ class MediaFetcher(val context: Context) {
val uri = Files.getContentUri("external") val uri = Files.getContentUri("external")
val cursor = context.contentResolver.query(uri, projection, null, null, null) try {
cursor?.use { val cursor = context.contentResolver.query(uri, projection, null, null, null)
if (cursor.moveToFirst()) { cursor?.use {
do { if (cursor.moveToFirst()) {
try { do {
val dateTaken = cursor.getLongValue(Images.Media.DATE_TAKEN) try {
if (dateTaken != 0L) { val dateTaken = cursor.getLongValue(Images.Media.DATE_TAKEN)
val path = cursor.getStringValue(Images.Media.DATA) if (dateTaken != 0L) {
dateTakens[path] = dateTaken val path = cursor.getStringValue(Images.Media.DATA)
dateTakens[path] = dateTaken
}
} catch (e: Exception) {
} }
} catch (e: Exception) { } while (cursor.moveToNext())
} }
} while (cursor.moveToNext())
} }
} catch (e: Exception) {
} }
val dateTakenValues = context.dateTakensDB.getAllDateTakens() val dateTakenValues = context.dateTakensDB.getAllDateTakens()
@ -547,20 +550,23 @@ class MediaFetcher(val context: Context) {
val uri = Files.getContentUri("external") val uri = Files.getContentUri("external")
val cursor = context.contentResolver.query(uri, projection, null, null, null) try {
cursor?.use { val cursor = context.contentResolver.query(uri, projection, null, null, null)
if (cursor.moveToFirst()) { cursor?.use {
do { if (cursor.moveToFirst()) {
try { do {
val lastModified = cursor.getLongValue(Images.Media.DATE_MODIFIED) * 1000 try {
if (lastModified != 0L) { val lastModified = cursor.getLongValue(Images.Media.DATE_MODIFIED) * 1000
val path = cursor.getStringValue(Images.Media.DATA) if (lastModified != 0L) {
lastModifieds[path] = lastModified val path = cursor.getStringValue(Images.Media.DATA)
lastModifieds[path] = lastModified
}
} catch (e: Exception) {
} }
} catch (e: Exception) { } while (cursor.moveToNext())
} }
} while (cursor.moveToNext())
} }
} catch (e: Exception) {
} }
return lastModifieds return lastModifieds