diff options
author | Allan Wang <me@allanwang.ca> | 2017-08-19 00:50:34 -0700 |
---|---|---|
committer | Allan Wang <me@allanwang.ca> | 2017-08-30 12:24:19 -0400 |
commit | 17d18daaf591b4ab27e0a7df0bb1c3126e6488be (patch) | |
tree | 8e349517251e5ade10b9e859eef53c9e3b5a77c8 /mediapicker/src/main | |
parent | a101b528efdee74fc1970b7f1fe68263f0b20269 (diff) | |
download | kau-17d18daaf591b4ab27e0a7df0bb1c3126e6488be.tar.gz kau-17d18daaf591b4ab27e0a7df0bb1c3126e6488be.tar.bz2 kau-17d18daaf591b4ab27e0a7df0bb1c3126e6488be.zip |
Remove excess null check (#41)
Diffstat (limited to 'mediapicker/src/main')
-rw-r--r-- | mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt index 6f0241c..eada173 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt @@ -251,10 +251,6 @@ abstract class MediaPickerCore<T : IItem<*, *>>( return super.onActivityResult(requestCode, resultCode, data) } KL.d("Media result received") - if (data == null) { - KL.d("Media null intent") - return super.onActivityResult(requestCode, resultCode, data) - } when (requestCode) { MEDIA_ACTION_REQUEST_CAMERA -> onCameraResult(data) MEDIA_ACTION_REQUEST_PICKER -> onPickerResult(data) @@ -262,12 +258,12 @@ abstract class MediaPickerCore<T : IItem<*, *>>( } } - private fun onCameraResult(data: Intent) { + private fun onCameraResult(data: Intent?) { val f: File if (tempPath != null) { f = File(tempPath) tempPath = null - } else if (data.data != null) { + } else if (data?.data != null) { f = File(data.data.path) } else { KL.d("Media camera no file found") @@ -282,12 +278,12 @@ abstract class MediaPickerCore<T : IItem<*, *>>( } } - private fun onPickerResult(data: Intent) { + private fun onPickerResult(data: Intent?) { val items = mutableListOf<Uri>() - if (data.data != null) { + if (data?.data != null) { KL.v("Media picker data uri", data.data.path) items.add(data.data) - } else { + } else if (data != null) { val clip = data.clipData if (clip != null) { items.addAll((0 until clip.itemCount).map { |