This commit is contained in:
Wenqi Li 2021-01-10 13:47:19 +08:00
parent 112f0ba7ee
commit 25e91dd962

View File

@ -465,19 +465,19 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
private fun getAlbumThumbnail(albumId: String, mediumType: String?, width: Int?, height: Int?): ByteArray? { private fun getAlbumThumbnail(albumId: String, mediumType: String?, width: Int?, height: Int?): ByteArray? {
return when (mediumType) { return when (mediumType) {
imageType -> { imageType -> {
getImageAlbumThubnail(albumId, width, height) getImageAlbumThumbnail(albumId, width, height)
} }
videoType -> { videoType -> {
getVideoAlbumThubnail(albumId, width, height) getVideoAlbumThumbnail(albumId, width, height)
} }
else -> { else -> {
getImageAlbumThubnail(albumId, width, height) getImageAlbumThumbnail(albumId, width, height)
?: getVideoAlbumThubnail(albumId, width, height) ?: getVideoAlbumThumbnail(albumId, width, height)
} }
} }
} }
private fun getImageAlbumThubnail(albumId: String, width: Int?, height: Int?): ByteArray? { private fun getImageAlbumThumbnail(albumId: String, width: Int?, height: Int?): ByteArray? {
return this.context?.run { return this.context?.run {
val imageCursor = this.contentResolver.query( val imageCursor = this.contentResolver.query(
MediaStore.Images.Media.EXTERNAL_CONTENT_URI, MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
@ -498,7 +498,7 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
} }
} }
private fun getVideoAlbumThubnail(albumId: String, width: Int?, height: Int?): ByteArray? { private fun getVideoAlbumThumbnail(albumId: String, width: Int?, height: Int?): ByteArray? {
return this.context?.run { return this.context?.run {
val videoCursor = this.contentResolver.query( val videoCursor = this.contentResolver.query(
MediaStore.Video.Media.EXTERNAL_CONTENT_URI, MediaStore.Video.Media.EXTERNAL_CONTENT_URI,