From eed7be0f40aa2ba31c82d88c9b36c43681bd782e Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 14 Jan 2017 13:49:13 +0100 Subject: [PATCH] catch exceptions at trying to display fullscreen photos --- .../gallery/activities/PhotoVideoActivity.kt | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt index 2c76c1396..a30fd97e7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/PhotoVideoActivity.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.gallery.activities import android.content.Intent +import android.database.Cursor import android.net.Uri import android.os.Bundle import android.provider.MediaStore @@ -63,13 +64,19 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList } val proj = arrayOf(MediaStore.Images.Media.TITLE) - val cursor = contentResolver.query(mUri, proj, null, null, null) - if (cursor != null && cursor.count != 0) { - val columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.TITLE) - cursor.moveToFirst() - title = cursor.getString(columnIndex) + var cursor: Cursor? = null + try { + cursor = contentResolver.query(mUri, proj, null, null, null) + if (cursor != null && cursor.count != 0) { + val columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.TITLE) + cursor.moveToFirst() + title = cursor.getString(columnIndex) + } + } catch (e: Exception) { + title = mMedium?.name ?: "" + } finally { + cursor?.close() } - cursor?.close() } override fun onResume() {