diff options
Diffstat (limited to 'mediapicker/src')
-rw-r--r-- | mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt | 2 | ||||
-rw-r--r-- | mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt | 13 | ||||
-rw-r--r-- | mediapicker/src/main/res/values/strings_mediapicker.xml (renamed from mediapicker/src/main/res/values/strings.xml) | 0 |
3 files changed, 9 insertions, 6 deletions
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt index ae85558..26736d4 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaModel.kt @@ -21,7 +21,7 @@ data class MediaModel( @Throws(SQLException::class) constructor(@NonNull cursor: Cursor) : this( cursor.getString(0), - cursor.getString(1), + cursor.getString(1) ?: "", cursor.getLong(2), cursor.getLong(3), cursor.getString(4) 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 d518b78..ec5d2f0 100644 --- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt +++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt @@ -153,8 +153,7 @@ abstract class MediaPickerCore<T : IItem<*, *>>( * The adapter will be cleared on each successful call */ open fun loadItems() { - kauRequestPermissions(Manifest.permission.READ_EXTERNAL_STORAGE) { - granted, _ -> + kauRequestPermissions(Manifest.permission.READ_EXTERNAL_STORAGE) { granted, _ -> if (granted) { supportLoaderManager.initLoader(LOADER_ID, null, this) onStatusChange(true) @@ -191,7 +190,7 @@ abstract class MediaPickerCore<T : IItem<*, *>>( } catch (ignored: InterruptedException) { } catch (ignored: ExecutionException) { } finally { - glide.clear(target) + glide.clear(target) } } } @@ -238,9 +237,13 @@ abstract class MediaPickerCore<T : IItem<*, *>>( * See <a href="http://hmkcode.com/android-display-selected-image-and-its-real-path/"></a> */ private fun <R> ContentResolver.query(baseUri: Uri, uris: List<Uri>, block: (cursor: Cursor) -> R) { - val ids = uris.map { + val ids = uris.filter { + val valid = DocumentsContract.isDocumentUri(this@MediaPickerCore, it) + if (!valid) KL.d("Non document uri: ${it.encodedPath}") + valid + }.mapNotNull { DocumentsContract.getDocumentId(it).split(":").getOrNull(1) - }.filterNotNull().joinToString(prefix = "(", separator = ",", postfix = ")") + }.joinToString(prefix = "(", separator = ",", postfix = ")") //? query replacements are done for one arg at a time //since we potentially have a list of ids, we'll just format the WHERE clause ourself query(baseUri, MediaModel.projection, "${BaseColumns._ID} IN $ids", null, sortQuery)?.use(block) diff --git a/mediapicker/src/main/res/values/strings.xml b/mediapicker/src/main/res/values/strings_mediapicker.xml index 717e12b..717e12b 100644 --- a/mediapicker/src/main/res/values/strings.xml +++ b/mediapicker/src/main/res/values/strings_mediapicker.xml |