From aea2f9365197304d19f0d39429dc92ab7ed465ca Mon Sep 17 00:00:00 2001 From: ligi Date: Wed, 30 Oct 2019 11:11:22 +0900 Subject: [PATCH] f --- .../org/ligi/passandroid/functions/InputStreamProvider.kt | 4 +++- .../java/org/ligi/passandroid/model/PastLocationsStore.kt | 2 +- .../main/java/org/ligi/passandroid/ui/edit/ImageEditHelper.kt | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/android/src/main/java/org/ligi/passandroid/functions/InputStreamProvider.kt b/android/src/main/java/org/ligi/passandroid/functions/InputStreamProvider.kt index 562ac5cc..965ff70b 100644 --- a/android/src/main/java/org/ligi/passandroid/functions/InputStreamProvider.kt +++ b/android/src/main/java/org/ligi/passandroid/functions/InputStreamProvider.kt @@ -65,6 +65,8 @@ private fun fromOKHttp(uri: Uri): InputStreamWithSource? { return null } -private fun fromContent(ctx: Context, uri: Uri) = InputStreamWithSource(uri.toString(), ctx.contentResolver.openInputStream(uri)) +private fun fromContent(ctx: Context, uri: Uri) = ctx.contentResolver.openInputStream(uri)?.let { + InputStreamWithSource(uri.toString(), it) +} private fun getDefaultInputStreamForUri(uri: Uri) = InputStreamWithSource(uri.toString(), BufferedInputStream(URL(uri.toString()).openStream(), 4096)) diff --git a/android/src/main/java/org/ligi/passandroid/model/PastLocationsStore.kt b/android/src/main/java/org/ligi/passandroid/model/PastLocationsStore.kt index 2246218f..f5dd0668 100644 --- a/android/src/main/java/org/ligi/passandroid/model/PastLocationsStore.kt +++ b/android/src/main/java/org/ligi/passandroid/model/PastLocationsStore.kt @@ -33,7 +33,7 @@ class PastLocationsStore constructor(private val sharedPreferences: SharedPrefer // feature not available for these versions val locations: Set - get() = sharedPreferences.getStringSet(KEY_PAST_LOCATIONS, emptySet()) + get() = sharedPreferences.getStringSet(KEY_PAST_LOCATIONS, emptySet())?: emptySet() companion object { diff --git a/android/src/main/java/org/ligi/passandroid/ui/edit/ImageEditHelper.kt b/android/src/main/java/org/ligi/passandroid/ui/edit/ImageEditHelper.kt index 31b49f19..46e34ea3 100644 --- a/android/src/main/java/org/ligi/passandroid/ui/edit/ImageEditHelper.kt +++ b/android/src/main/java/org/ligi/passandroid/ui/edit/ImageEditHelper.kt @@ -31,7 +31,7 @@ class ImageEditHelper(private val context: Activity, private val passStore: Pass } private fun extractImage(imageReturnedIntent: Intent, name: String) { - val extractedFile = imageReturnedIntent.data.loadImage(context) + val extractedFile = imageReturnedIntent.data?.loadImage(context) val pass = passStore.currentPass if (extractedFile != null && pass != null && extractedFile.exists()) { try {