From 0870c39e93309685bf925acdff9d154579a30b90 Mon Sep 17 00:00:00 2001 From: kunfei Date: Thu, 24 Oct 2019 16:57:56 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/utils/FileUtils.kt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/io/legado/app/utils/FileUtils.kt b/app/src/main/java/io/legado/app/utils/FileUtils.kt index 4626fe489..7821f6b49 100644 --- a/app/src/main/java/io/legado/app/utils/FileUtils.kt +++ b/app/src/main/java/io/legado/app/utils/FileUtils.kt @@ -122,12 +122,10 @@ object FileUtils { val type = split[0] var contentUri: Uri? = null - if ("image" == type) { - contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI - } else if ("video" == type) { - contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI - } else if ("audio" == type) { - contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI + when (type) { + "image" -> contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI + "video" -> contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI + "audio" -> contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI } val selection = "_id=?" @@ -136,7 +134,7 @@ object FileUtils { return getDataColumn(context, contentUri, selection, selectionArgs) }// MediaProvider // DownloadsProvider - } else if ("content".equals(uri.scheme!!, ignoreCase = true)) { + } else if ("content".equals(uri.scheme, ignoreCase = true)) { // Return the remote address return if (isGooglePhotosUri(uri)) uri.lastPathSegment else getDataColumn( @@ -146,11 +144,10 @@ object FileUtils { null ) - } else if ("file".equals(uri.scheme!!, ignoreCase = true)) { + } else if ("file".equals(uri.scheme, ignoreCase = true)) { return uri.path }// File // MediaStore (and general) - return null }