Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
C
clx-fluwx
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
openSourceLibrary
clx-fluwx
Commits
27b8ea3a
提交
27b8ea3a
authored
8月 13, 2018
作者:
JarvanMo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
share music
上级
a5cc5f33
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
46 行增加
和
13 行删除
+46
-13
WeChatPluginHandler.kt
.../com/jarvanmo/wechatplugin/handler/WeChatPluginHandler.kt
+35
-0
WeChatThumbnailUtil.java
.../com/jarvanmo/wechatplugin/utils/WeChatThumbnailUtil.java
+0
-3
wechat_plugin.dart
lib/wechat_plugin.dart
+11
-10
没有找到文件。
android/src/main/kotlin/com/jarvanmo/wechatplugin/handler/WeChatPluginHandler.kt
浏览文件 @
27b8ea3a
...
...
@@ -11,6 +11,16 @@ import com.tencent.mm.opensdk.openapi.IWXAPI
import
io.flutter.plugin.common.MethodCall
import
io.flutter.plugin.common.MethodChannel
import
io.flutter.plugin.common.PluginRegistry
import
android.R.id.message
import
com.tencent.mm.opensdk.modelmsg.SendMessageToWX
import
com.jarvanmo.wechatplugin.utils.Util.bmpToByteArray
import
android.graphics.Bitmap
import
android.graphics.BitmapFactory
import
android.R.attr.description
import
com.tencent.mm.opensdk.modelmsg.WXMediaMessage
import
com.tencent.mm.opensdk.modelmsg.WXMusicObject
/***
...
...
@@ -51,6 +61,7 @@ object WeChatPluginHandler {
WeChatPluginMethods
.
SHARE_TEXT
->
shareText
(
call
,
result
)
WeChatPluginMethods
.
SHARE_MINI_PROGRAM
->
shareMiniProgram
(
call
,
result
)
WeChatPluginMethods
.
SHARE_IMAGE
->
shareImage
(
call
,
result
)
WeChatPluginMethods
.
SHARE_MUSIC
->
shareMusic
(
call
,
result
)
else
->
{
result
.
notImplemented
()
}
...
...
@@ -123,6 +134,30 @@ object WeChatPluginHandler {
wxApi
?.
sendReq
(
req
)
result
.
success
(
true
)
}
private
fun
shareMusic
(
call
:
MethodCall
,
result
:
MethodChannel
.
Result
)
{
val
music
=
WXMusicObject
()
val
musicUrl
:
String
?
=
call
.
argument
(
"musicUrl"
)
val
musicLowBandUrl
:
String
?
=
call
.
argument
(
"musicLowBandUrl"
)
if
(
musicUrl
!=
null
){
music
.
musicUrl
=
musicUrl
}
else
{
music
.
musicLowBandUrl
=
musicLowBandUrl
}
val
msg
=
WXMediaMessage
()
msg
.
mediaObject
=
music
msg
.
title
=
call
.
argument
(
"title"
)
msg
.
description
=
call
.
argument
(
"description"
)
val
thumbnail
:
String
?
=
call
.
argument
(
"thumbnail"
)
if
(
thumbnail
!=
null
&&
thumbnail
.
isNotBlank
()){
msg
.
thumbData
=
WeChatThumbnailUtil
.
thumbnailForCommon
(
thumbnail
,
registrar
)
}
val
req
=
SendMessageToWX
.
Req
()
setCommonArguments
(
call
,
req
)
req
.
message
=
msg
wxApi
?.
sendReq
(
req
)
result
.
success
(
true
)
}
// private fun createWxImageObject(imagePath:String):WXImageObject?{
// var imgObj: WXImageObject? = null
...
...
android/src/main/kotlin/com/jarvanmo/wechatplugin/utils/WeChatThumbnailUtil.java
浏览文件 @
27b8ea3a
...
...
@@ -4,15 +4,12 @@ import android.content.res.AssetFileDescriptor;
import
android.graphics.Bitmap
;
import
android.graphics.BitmapFactory
;
import
com.jarvanmo.wechatplugin.WechatPlugin
;
import
com.jarvanmo.wechatplugin.constant.WeChatPluginImageSchema
;
import
com.jarvanmo.wechatplugin.constant.WechatPluginKeys
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URLConnection
;
import
java.security.Key
;
import
io.flutter.plugin.common.PluginRegistry
;
import
okhttp3.OkHttpClient
;
...
...
lib/wechat_plugin.dart
浏览文件 @
27b8ea3a
...
...
@@ -4,31 +4,32 @@ import 'package:flutter/services.dart';
import
'package:wechat_plugin/src/wechat_share_models.dart'
;
class
WechatPlugin
{
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'wechat_plugin'
);
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'wechat_plugin'
);
static
StreamController
<
Map
>
_responseStreamController
=
new
StreamController
.
broadcast
();
static
Stream
<
Map
>
get
weChatResponseUpdate
=>
_responseStreamController
.
stream
;
static
Future
<
int
>
init
(
String
appId
)
async
{
StreamController
<
Map
>
_responseStreamController
=
new
StreamController
.
broadcast
();
Stream
<
Map
>
get
weChatResponseUpdate
=>
_responseStreamController
.
stream
;
Future
<
int
>
init
(
String
appId
)
async
{
return
await
_channel
.
invokeMethod
(
"initWeChat"
);
}
static
void
listen
(){
void
listen
(){
_channel
.
setMethodCallHandler
(
_handler
);
}
static
void
dispose
(){
void
dispose
(){
_responseStreamController
.
close
();
}
static
Future
<
String
>
get
platformVersion
async
{
Future
<
String
>
get
platformVersion
async
{
final
String
version
=
await
_channel
.
invokeMethod
(
'getPlatformVersion'
);
return
version
;
}
static
Future
shareText
(
WeChatShareTextModel
model
)
async
{
return
await
_channel
.
invokeMethod
(
"shareText"
,
model
.
toMap
());
Future
shareText
(
WeChatShareTextModel
model
)
async
{
await
_channel
.
invokeMethod
(
"shareText"
,
model
.
toMap
());
}
static
Future
shareMiniProgram
(
WeChatShareMiniProgramModel
model
)
async
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论