catch exceptions at trying to display fullscreen photos

This commit is contained in:
tibbi 2017-01-14 13:49:13 +01:00
parent 8b37560ed4
commit eed7be0f40

View file

@ -1,6 +1,7 @@
package com.simplemobiletools.gallery.activities package com.simplemobiletools.gallery.activities
import android.content.Intent import android.content.Intent
import android.database.Cursor
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.provider.MediaStore import android.provider.MediaStore
@ -63,14 +64,20 @@ open class PhotoVideoActivity : SimpleActivity(), ViewPagerFragment.FragmentList
} }
val proj = arrayOf(MediaStore.Images.Media.TITLE) val proj = arrayOf(MediaStore.Images.Media.TITLE)
val cursor = contentResolver.query(mUri, proj, null, null, null) var cursor: Cursor? = null
try {
cursor = contentResolver.query(mUri, proj, null, null, null)
if (cursor != null && cursor.count != 0) { if (cursor != null && cursor.count != 0) {
val columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.TITLE) val columnIndex = cursor.getColumnIndexOrThrow(MediaStore.Images.Media.TITLE)
cursor.moveToFirst() cursor.moveToFirst()
title = cursor.getString(columnIndex) title = cursor.getString(columnIndex)
} }
} catch (e: Exception) {
title = mMedium?.name ?: ""
} finally {
cursor?.close() cursor?.close()
} }
}
override fun onResume() { override fun onResume() {
super.onResume() super.onResume()