From 8dd2d460305448d20af4d6051af8dd768f116c61 Mon Sep 17 00:00:00 2001 From: hujl Date: Wed, 11 Sep 2019 14:03:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BE=AE=E4=BF=A1=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sdk/social/wechat/WeChatManager.java | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/lib_social/src/main/java/com/android/sdk/social/wechat/WeChatManager.java b/lib_social/src/main/java/com/android/sdk/social/wechat/WeChatManager.java index 9fb06ba..76eb831 100644 --- a/lib_social/src/main/java/com/android/sdk/social/wechat/WeChatManager.java +++ b/lib_social/src/main/java/com/android/sdk/social/wechat/WeChatManager.java @@ -31,6 +31,7 @@ public class WeChatManager { private static String sAppId; private static String sAppSecret; + private static WeChatShareCallback sWeChatShareCallback; /** * @param context 上下文 @@ -298,10 +299,11 @@ public class WeChatManager { } /////////////////////////////////////////////////////////////////////////// - // 支付 + // 分享 /////////////////////////////////////////////////////////////////////////// - public boolean share(WeChatShareInfo.ShareContent content) { + public boolean share(WeChatShareInfo.ShareContent content, WeChatShareCallback shareCallback) { + sWeChatShareCallback = shareCallback; try { SendMessageToWX.Req baseReq = WeChatShareInfo.buildReq(content); mWxApi.sendReq(baseReq); @@ -312,8 +314,46 @@ public class WeChatManager { } } + /** + * 微信分享回调 + * + * @param baseResp + */ private static void handleSendMessageResp(BaseResp baseResp) { - // no op + switch (baseResp.errCode) { + case BaseResp.ErrCode.ERR_OK: + if (sWeChatShareCallback != null) { + sWeChatShareCallback.onSuccess(); + } + break; + case BaseResp.ErrCode.ERR_USER_CANCEL: + if (sWeChatShareCallback != null) { + sWeChatShareCallback.onCancel(); + } + break; + case BaseResp.ErrCode.ERR_AUTH_DENIED: + case BaseResp.ErrCode.ERR_SENT_FAILED: + case BaseResp.ErrCode.ERR_UNSUPPORT: + case BaseResp.ErrCode.ERR_COMM: + case BaseResp.ErrCode.ERR_BAN: + if (sWeChatShareCallback != null) { + sWeChatShareCallback.onFailed(baseResp); + } + break; + } } + public interface WeChatShareCallback { + + void onSuccess(); + + void onCancel(); + + void onFailed(BaseResp baseResp); + } + + public static void destroyShareCallback() { + if (sWeChatShareCallback != null) + sWeChatShareCallback = null; + } } \ No newline at end of file