/** * 2,分享图片 * * @param imgUrl 图片Url * @param imgDescription 图片描述 * @param sharePlatform 分享的平台:微信好友,微信朋友圈,QQ等 * @param object 目标分享平台的对象,eg:IWXAPI */ public void sharePicOnly(CommonShareBaseBean sharePicBean, Object object) { CommonSharePlatform sharePlatform = sharePicBean.getSharePlatform(); boolean isInstalled = CommonShareUtils.isSupport(mContext, sharePlatform, object); try { if (sharePlatform == CommonSharePlatform.WeixinFriend || sharePlatform == CommonSharePlatform.WeixinFriendCircle) { if (!isInstalled) { Toast.makeText( mContext, mContext.getResources().getString(R.string.share_not_supported), Toast.LENGTH_SHORT) .show(); return; } // 分享至微信好友 mWeixin.sharePicToWeixin( sharePicBean.getImgUrl(), sharePicBean.getDescription(), sharePlatform, (IWXAPI) object); } else if (sharePlatform == CommonSharePlatform.QQ_Weibo || sharePlatform == CommonSharePlatform.QQ_Zone || sharePlatform == CommonSharePlatform.QQ_Friend) { mQQ.sharePicJust( sharePicBean.getAppName(), sharePicBean.getImgUrl(), (Tencent) object, sharePicBean.getUiListener()); } } catch (ClassCastException e) { throw new IllegalArgumentException( "object必须传分享目标对象,eg:微信(IWXAPI),QQ(Tencent),微博(IWeiboShareAPI)"); } }
/** 5.分享视频 */ public void shareVideo(CommonShareVideo shareVideo, Object object) { CommonSharePlatform sharePlatform = shareVideo.getSharePlatform(); boolean isInstalled = CommonShareUtils.isSupport(mContext, sharePlatform, object); try { if (sharePlatform == CommonSharePlatform.WeixinFriend || sharePlatform == CommonSharePlatform.WeixinFriendCircle) { if (!isInstalled) { Toast.makeText( mContext, mContext.getResources().getString(R.string.share_not_supported), Toast.LENGTH_SHORT) .show(); return; } // 分享至微信好友 mWeixin.shareVideoToWeixin( shareVideo.getVideoUrl(), shareVideo.getBm(), shareVideo.getTitle(), shareVideo.getDescription(), sharePlatform, (IWXAPI) object); } } catch (ClassCastException e) { throw new IllegalArgumentException( "object必须传分享目标对象,eg:微信(IWXAPI),QQ(Tencent),微博(IWeiboShareAPI)"); } }