From 99f4a65dc11c77d7131f424a28d021ab1467b266 Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 13 Aug 2018 21:43:24 +0200 Subject: [PATCH] wrap whole picasso loading in a try/catch block --- .../gallery/fragments/PhotoFragment.kt | 34 +++++++++++-------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt index 60f6e9471..1337c765f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/fragments/PhotoFragment.kt @@ -267,25 +267,29 @@ class PhotoFragment : ViewPagerFragment() { var pathToLoad = if (medium.path.startsWith("content://")) medium.path else "file://${medium.path}" pathToLoad = pathToLoad.replace("%", "%25").replace("#", "%23") - val picasso = Picasso.get() - .load(pathToLoad) - .centerInside() - .resize(targetWidth, targetHeight) - if (degrees != 0) { - picasso.rotate(degrees.toFloat()) - } + try { + val picasso = Picasso.get() + .load(pathToLoad) + .centerInside() + .resize(targetWidth, targetHeight) - picasso.into(view.photo_view, object : Callback { - override fun onSuccess() { - view.photo_view.isZoomable = degrees != 0 || context?.config?.allowZoomingImages == false - if (isFragmentVisible && degrees == 0) { - scheduleZoomableView() - } + if (degrees != 0) { + picasso.rotate(degrees.toFloat()) } - override fun onError(e: Exception) {} - }) + picasso.into(view.photo_view, object : Callback { + override fun onSuccess() { + view.photo_view.isZoomable = degrees != 0 || context?.config?.allowZoomingImages == false + if (isFragmentVisible && degrees == 0) { + scheduleZoomableView() + } + } + + override fun onError(e: Exception) {} + }) + } catch (ignored: Exception) { + } } private fun openPanorama() {