Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
98b008ae
提交
98b008ae
authored
10月 30, 2018
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update kotlin to 1.3.0
上级
b1e3a51d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
28 行增加
和
23 行删除
+28
-23
build.gradle
android/build.gradle
+3
-3
FluwxShareHandler.kt
...main/kotlin/com/jarvan/fluwx/handler/FluwxShareHandler.kt
+24
-19
build.gradle
example/android/build.gradle
+1
-1
没有找到文件。
android/build.gradle
浏览文件 @
98b008ae
...
...
@@ -2,7 +2,7 @@ group 'com.jarvan.fluwx'
version
'1.0-SNAPSHOT'
buildscript
{
ext
.
kotlin_version
=
'1.
2.71
'
ext
.
kotlin_version
=
'1.
3.0
'
repositories
{
google
()
jcenter
()
...
...
@@ -42,8 +42,8 @@ android {
dependencies
{
implementation
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
api
'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:5.1.4'
implementation
'org.jetbrains.kotlinx:kotlinx-coroutines-core:
0.30.2
'
implementation
'org.jetbrains.kotlinx:kotlinx-coroutines-android:
0.30.2
'
implementation
'org.jetbrains.kotlinx:kotlinx-coroutines-core:
1.0.0
'
implementation
'org.jetbrains.kotlinx:kotlinx-coroutines-android:
1.0.0
'
implementation
'top.zibin:Luban:1.1.8'
implementation
'com.squareup.okhttp3:okhttp:3.11.0'
}
android/src/main/kotlin/com/jarvan/fluwx/handler/FluwxShareHandler.kt
浏览文件 @
98b008ae
...
...
@@ -24,7 +24,7 @@ import com.tencent.mm.opensdk.modelmsg.*
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodChannel
import
io.flutter.plugin.common.PluginRegistry
import
kotlinx.coroutines.
experimental.
*
import
kotlinx.coroutines.*
/***
...
...
@@ -112,11 +112,11 @@ internal class FluwxShareHandler {
msg
.
description
=
call
.
argument
(
"description"
)
// 小程序消息desc
val
thumbnail
:
String
?
=
call
.
argument
(
WechatPluginKeys
.
THUMBNAIL
)
GlobalScope
.
launch
((
Dispatchers
.
Main
),
CoroutineStart
.
DEFAULT
,
{
GlobalScope
.
launch
((
Dispatchers
.
Main
),
CoroutineStart
.
DEFAULT
)
{
if
(
thumbnail
.
isNullOrBlank
())
{
msg
.
thumbData
=
null
}
else
{
msg
.
thumbData
=
getThumbnailByteArrayMiniProgram
(
registrar
,
thumbnail
!!
)
msg
.
thumbData
=
getThumbnailByteArrayMiniProgram
(
registrar
,
thumbnail
)
}
val
req
=
SendMessageToWX
.
Req
()
setCommonArguments
(
call
,
req
,
msg
)
...
...
@@ -129,38 +129,43 @@ internal class FluwxShareHandler {
)
)
}
)
}
}
private
suspend
fun
getThumbnailByteArrayMiniProgram
(
registrar
:
PluginRegistry
.
Registrar
?,
thumbnail
:
String
):
ByteArray
{
return
GlobalScope
.
async
(
Dispatchers
.
Default
,
CoroutineStart
.
DEFAULT
,
{
return
GlobalScope
.
async
(
Dispatchers
.
Default
,
CoroutineStart
.
DEFAULT
)
{
val
result
=
WeChatThumbnailUtil
.
thumbnailForMiniProgram
(
thumbnail
,
registrar
)
result
?:
byteArrayOf
()
}
)
.
await
()
}.
await
()
}
private
suspend
fun
getImageByteArrayCommon
(
registrar
:
PluginRegistry
.
Registrar
?,
imagePath
:
String
):
ByteArray
{
return
GlobalScope
.
async
(
Dispatchers
.
Default
,
CoroutineStart
.
DEFAULT
,
{
return
GlobalScope
.
async
(
Dispatchers
.
Default
,
CoroutineStart
.
DEFAULT
)
{
val
result
=
ShareImageUtil
.
getImageData
(
registrar
,
imagePath
)
result
?:
byteArrayOf
()
}
)
.
await
()
}.
await
()
}
// private suspend fun getThumbnailByteArrayCommon(registrar: PluginRegistry.Registrar?, thumbnail: String): ByteArray {
// return GlobalScope.async(Dispatchers.Default, CoroutineStart.DEFAULT, {
// val result = WeChatThumbnailUtil.thumbnailForCommon(thumbnail, registrar)
// result ?: byteArrayOf()
// }).await()
// }
private
suspend
fun
getThumbnailByteArrayCommon
(
registrar
:
PluginRegistry
.
Registrar
?,
thumbnail
:
String
):
ByteArray
{
return
GlobalScope
.
async
(
Dispatchers
.
Default
,
CoroutineStart
.
DEFAULT
,
{
return
GlobalScope
.
async
(
Dispatchers
.
Default
,
CoroutineStart
.
DEFAULT
)
{
val
result
=
WeChatThumbnailUtil
.
thumbnailForCommon
(
thumbnail
,
registrar
)
result
?:
byteArrayOf
()
}
)
.
await
()
}.
await
()
}
private
fun
shareImage
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
val
imagePath
=
call
.
argument
<
String
>(
WechatPluginKeys
.
IMAGE
)
GlobalScope
.
launch
(
Dispatchers
.
Main
,
CoroutineStart
.
DEFAULT
,
{
GlobalScope
.
launch
(
Dispatchers
.
Main
,
CoroutineStart
.
DEFAULT
)
{
val
byteArray
:
ByteArray
?
=
if
(
imagePath
.
isNullOrBlank
()){
byteArrayOf
()
}
else
{
...
...
@@ -188,7 +193,7 @@ internal class FluwxShareHandler {
// val thumbnailData = Util.bmpToByteArray(bitmap,true)
handleShareImage
(
imgObj
,
call
,
thumbnailData
,
result
)
}
)
}
}
...
...
@@ -234,7 +239,7 @@ internal class FluwxShareHandler {
msg
.
description
=
call
.
argument
(
"description"
)
val
thumbnail
:
String
?
=
call
.
argument
(
"thumbnail"
)
GlobalScope
.
launch
(
Dispatchers
.
Main
,
CoroutineStart
.
DEFAULT
,
{
GlobalScope
.
launch
(
Dispatchers
.
Main
,
CoroutineStart
.
DEFAULT
)
{
if
(
thumbnail
!=
null
&&
thumbnail
.
isNotBlank
())
{
msg
.
thumbData
=
getThumbnailByteArrayCommon
(
registrar
,
thumbnail
)
}
...
...
@@ -249,7 +254,7 @@ internal class FluwxShareHandler {
WechatPluginKeys
.
RESULT
to
done
)
)
}
)
}
}
...
...
@@ -269,7 +274,7 @@ internal class FluwxShareHandler {
msg
.
description
=
call
.
argument
(
WechatPluginKeys
.
DESCRIPTION
)
val
thumbnail
:
String
?
=
call
.
argument
(
WechatPluginKeys
.
THUMBNAIL
)
GlobalScope
.
launch
(
Dispatchers
.
Main
,
CoroutineStart
.
DEFAULT
,
{
GlobalScope
.
launch
(
Dispatchers
.
Main
,
CoroutineStart
.
DEFAULT
)
{
if
(
thumbnail
!=
null
&&
thumbnail
.
isNotBlank
())
{
msg
.
thumbData
=
getThumbnailByteArrayCommon
(
registrar
,
thumbnail
)
}
...
...
@@ -283,7 +288,7 @@ internal class FluwxShareHandler {
WechatPluginKeys
.
RESULT
to
done
)
)
}
)
}
}
...
...
@@ -298,7 +303,7 @@ internal class FluwxShareHandler {
msg
.
title
=
call
.
argument
(
WechatPluginKeys
.
TITLE
)
msg
.
description
=
call
.
argument
(
WechatPluginKeys
.
DESCRIPTION
)
val
thumbnail
:
String
?
=
call
.
argument
(
WechatPluginKeys
.
THUMBNAIL
)
GlobalScope
.
launch
(
Dispatchers
.
Main
,
CoroutineStart
.
DEFAULT
,
{
GlobalScope
.
launch
(
Dispatchers
.
Main
,
CoroutineStart
.
DEFAULT
)
{
if
(
thumbnail
!=
null
&&
thumbnail
.
isNotBlank
())
{
msg
.
thumbData
=
getThumbnailByteArrayCommon
(
registrar
,
thumbnail
)
}
...
...
@@ -312,7 +317,7 @@ internal class FluwxShareHandler {
WechatPluginKeys
.
RESULT
to
done
)
)
}
)
}
}
// private fun createWxImageObject(imagePath:String):WXImageObject?{
...
...
example/android/build.gradle
浏览文件 @
98b008ae
buildscript
{
ext
.
kotlin_version
=
'1.
2.71
'
ext
.
kotlin_version
=
'1.
3.0
'
repositories
{
google
()
jcenter
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论