Aperture: Catch all exceptions for getThumbnail()
Also fallback to placeholder image if it fails.
Change-Id: I865bc71232831013141cadbb42189a8b5a1498ed
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 98bcb53..4bd92e5 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -66,7 +66,6 @@
import org.lineageos.aperture.utils.PhysicalCamera
import org.lineageos.aperture.utils.StorageUtils
import org.lineageos.aperture.utils.TimeUtils
-import java.io.FileNotFoundException
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.Timer
@@ -816,6 +815,9 @@
getThumbnail(uri)?.let {
galleryButton.setPadding(0)
galleryButton.setImageBitmap(it)
+ } ?: run {
+ galleryButton.setPadding(convertDpToPx(15))
+ galleryButton.setImageResource(R.drawable.ic_image)
}
} else if (keyguardManager.isKeyguardLocked) {
galleryButton.setPadding(convertDpToPx(15))
@@ -915,7 +917,7 @@
val sizeInPx = convertDpToPx(75)
contentResolver.loadThumbnail(it, Size(sizeInPx, sizeInPx), null)
}
- } catch (exception: FileNotFoundException) {
+ } catch (exception: Exception) {
Log.e(LOG_TAG, "${exception.message}")
null
}