提交 a803f634 authored 作者: JarvanMo's avatar JarvanMo

优化Android图片分享逻辑,优先把LocalImagePath以最大限度保证图片质量

上级 164b0c13
...@@ -106,22 +106,15 @@ internal interface FluwxShareHandler : CoroutineScope { ...@@ -106,22 +106,15 @@ internal interface FluwxShareHandler : CoroutineScope {
val map: Map<String, Any> = call.argument("source") ?: mapOf() val map: Map<String, Any> = call.argument("source") ?: mapOf()
val imgHash = call.argument<String?>("imgDataHash") val imgHash = call.argument<String?>("imgDataHash")
val uint8List = map["uint8List"] as? ByteArray
val imageObject = uint8List?.let {
WXImageObject().apply {
imageData = it
imgDataHash = imgHash
}
} ?: run {
WXImageObject().apply {
val localImagePath = map["localImagePath"] as? String val localImagePath = map["localImagePath"] as? String
localImagePath?.also { val imageObject = localImagePath?.let {
WXImageObject().apply {
if (supportFileProvider && targetHigherThanN) { if (supportFileProvider && targetHigherThanN) {
if (localImagePath.startsWith("content://")) { if (localImagePath.startsWith("content://")) {
imagePath = localImagePath imagePath = localImagePath
} else { } else {
val tempFile = File(localImagePath) val tempFile = File(localImagePath)
val ecd = context.externalCacheDir ?: return@also val ecd = context.externalCacheDir ?: return@apply
val desPath = val desPath =
ecd.absolutePath + File.separator + cachePathName ecd.absolutePath + File.separator + cachePathName
if (tempFile.exists()) { if (tempFile.exists()) {
...@@ -140,11 +133,21 @@ internal interface FluwxShareHandler : CoroutineScope { ...@@ -140,11 +133,21 @@ internal interface FluwxShareHandler : CoroutineScope {
imagePath = getFileContentUri(target) imagePath = getFileContentUri(target)
} }
} }
} else {
imagePath = localImagePath
} }
imgDataHash = imgHash
} }
} ?: run {
WXImageObject().apply {
val uint8List = map["uint8List"] as? ByteArray
uint8List?.let {
imageData = it
imgDataHash = imgHash imgDataHash = imgHash
} }
} }
}
val msg = WXMediaMessage() val msg = WXMediaMessage()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论