fix bugs that always return null
This commit is contained in:
parent
4735075797
commit
a68059733d
@ -793,7 +793,7 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getImageFile(mediumId: String, mimeType: String? = null): String? {
|
private fun getImageFile(mediumId: String, mimeType: String? = null): String? {
|
||||||
this.context.run {
|
return this.context.run {
|
||||||
mimeType?.let {
|
mimeType?.let {
|
||||||
val type = this.contentResolver.getType(
|
val type = this.contentResolver.getType(
|
||||||
ContentUris.withAppendedId(
|
ContentUris.withAppendedId(
|
||||||
@ -802,7 +802,7 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
if (it != type) {
|
if (it != type) {
|
||||||
return cacheImage(mediumId, it)
|
return@run cacheImage(mediumId, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -817,12 +817,12 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
|||||||
imageCursor?.use { cursor ->
|
imageCursor?.use { cursor ->
|
||||||
if (cursor.moveToNext()) {
|
if (cursor.moveToNext()) {
|
||||||
val dataColumn = cursor.getColumnIndex(MediaStore.Images.Media.DATA)
|
val dataColumn = cursor.getColumnIndex(MediaStore.Images.Media.DATA)
|
||||||
return cursor.getString(dataColumn)
|
return@run cursor.getString(dataColumn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getVideoFile(mediumId: String): String? {
|
private fun getVideoFile(mediumId: String): String? {
|
||||||
@ -867,7 +867,7 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap?.let {
|
return bitmap?.let {
|
||||||
val compressFormat: Bitmap.CompressFormat
|
val compressFormat: Bitmap.CompressFormat
|
||||||
when (mimeType) {
|
when (mimeType) {
|
||||||
"image/jpeg" -> {
|
"image/jpeg" -> {
|
||||||
@ -875,7 +875,7 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
|||||||
val out = FileOutputStream(path)
|
val out = FileOutputStream(path)
|
||||||
compressFormat = Bitmap.CompressFormat.JPEG
|
compressFormat = Bitmap.CompressFormat.JPEG
|
||||||
it.compress(compressFormat, 100, out)
|
it.compress(compressFormat, 100, out)
|
||||||
return path.absolutePath
|
path.absolutePath
|
||||||
}
|
}
|
||||||
|
|
||||||
"image/png" -> {
|
"image/png" -> {
|
||||||
@ -883,7 +883,7 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
|||||||
val out = FileOutputStream(path)
|
val out = FileOutputStream(path)
|
||||||
compressFormat = Bitmap.CompressFormat.PNG
|
compressFormat = Bitmap.CompressFormat.PNG
|
||||||
it.compress(compressFormat, 100, out)
|
it.compress(compressFormat, 100, out)
|
||||||
return path.absolutePath
|
path.absolutePath
|
||||||
}
|
}
|
||||||
|
|
||||||
"image/webp" -> {
|
"image/webp" -> {
|
||||||
@ -896,16 +896,14 @@ class PhotoGalleryPlugin : FlutterPlugin, MethodCallHandler {
|
|||||||
Bitmap.CompressFormat.WEBP
|
Bitmap.CompressFormat.WEBP
|
||||||
}
|
}
|
||||||
it.compress(compressFormat, 100, out)
|
it.compress(compressFormat, 100, out)
|
||||||
return path.absolutePath
|
path.absolutePath
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
return null
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getImageMetadata(cursor: Cursor): Map<String, Any?> {
|
private fun getImageMetadata(cursor: Cursor): Map<String, Any?> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user