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 | |
parent | a101b528efdee74fc1970b7f1fe68263f0b20269 (diff) | |
download | kau-17d18daaf591b4ab27e0a7df0bb1c3126e6488be.tar.gz kau-17d18daaf591b4ab27e0a7df0bb1c3126e6488be.tar.bz2 kau-17d18daaf591b4ab27e0a7df0bb1c3126e6488be.zip |
Remove excess null check (#41)
-rw-r--r-- | gradle.properties | 2 | ||||
-rw-r--r-- | mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt | 14 |
2 files changed, 6 insertions, 10 deletions
diff --git a/gradle.properties b/gradle.properties index d7837c8..baaf801 100644 --- a/gradle.properties +++ b/gradle.properties @@ -25,7 +25,7 @@ ANDROID_SUPPORT_LIBS=26.0.0 VERSION_NAME=3.3.3 -KOTLIN=1.1.3-2 +KOTLIN=1.1.4 ABOUT_LIBRARIES=5.9.7 ANKO=0.10.1 BLURRY=2.1.1 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 { |