adding a null check at handling Edit Photo result

This commit is contained in:
tibbi 2018-02-21 15:57:45 +01:00
parent bcdd8fe40f
commit 74140b1665
2 changed files with 8 additions and 3 deletions

View File

@ -94,7 +94,7 @@ class EditContactActivity : ContactActivity() {
super.onActivityResult(requestCode, resultCode, resultData)
if (resultCode == RESULT_OK) {
when (requestCode) {
INTENT_TAKE_PHOTO, INTENT_CHOOSE_PHOTO -> startCropPhotoIntent(lastPhotoIntentUri!!)
INTENT_TAKE_PHOTO, INTENT_CHOOSE_PHOTO -> startCropPhotoIntent(lastPhotoIntentUri)
INTENT_CROP_PHOTO -> updateContactPhoto(lastPhotoIntentUri.toString(), contact_photo)
}
}
@ -190,7 +190,12 @@ class EditContactActivity : ContactActivity() {
invalidateOptionsMenu()
}
private fun startCropPhotoIntent(uri: Uri) {
private fun startCropPhotoIntent(uri: Uri?) {
if (uri == null) {
toast(R.string.unknown_error_occurred)
return
}
lastPhotoIntentUri = getCachePhotoUri()
Intent("com.android.camera.action.CROP").apply {
setDataAndType(uri, "image/*")

View File

@ -35,7 +35,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
private val FIRST_CONTACT_ID = 1000000
private val mDb: SQLiteDatabase = writableDatabase
private val mDb = writableDatabase
companion object {
private const val DB_VERSION = 1