This commit is contained in:
@ -31,6 +31,7 @@ import com.facebook.imagepipeline.image.CloseableImage;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.gamecenter.R;
|
||||
import com.gh.gamecenter.WeiBoShareActivity;
|
||||
import com.gh.gamecenter.entity.ShareEntity;
|
||||
import com.gh.gamecenter.eventbus.EBShare;
|
||||
import com.lightgame.utils.Utils;
|
||||
import com.sina.weibo.sdk.WbSdk;
|
||||
@ -84,15 +85,27 @@ public class ShareUtils {
|
||||
};
|
||||
|
||||
public enum ShareType {
|
||||
news,
|
||||
game, // 普通游戏
|
||||
plugin, // 插件游戏
|
||||
tools,
|
||||
askInvite,
|
||||
askNormal, // 问答问题/答案
|
||||
shareGh,
|
||||
communityArticle,
|
||||
video
|
||||
news("资讯文章"),
|
||||
game("游戏详情"), // 普通游戏
|
||||
plugin("游戏详情"), // 插件游戏
|
||||
tools("工具箱"),
|
||||
askInvite("邀请回答"),
|
||||
askNormal("问题详情"), //问答问题
|
||||
answerNormal("回答详情"), //问答答案
|
||||
shareGh("APP分享"),
|
||||
communityArticle("文章详情"),
|
||||
video("视频"),
|
||||
web("web链接");
|
||||
|
||||
private String name;
|
||||
|
||||
ShareType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
}
|
||||
|
||||
private String[] arrLabel = {"微信好友", "朋友圈", "QQ好友", "QQ空间", "新浪微博", "短信", "复制链接", "取消"};
|
||||
@ -101,6 +114,8 @@ public class ShareUtils {
|
||||
|
||||
private ShareType mShareType;
|
||||
public static ShareType shareType;//全局保存shareType,分享成功后判断分享的类型
|
||||
public static String resourceId = "";//分析内容的id(事件上报用)
|
||||
public static ShareEntity shareEntity;//分享信息(事件上报用)
|
||||
|
||||
private WeakReference<Activity> mActivity;
|
||||
|
||||
@ -111,16 +126,22 @@ public class ShareUtils {
|
||||
public void onComplete(Object o) {
|
||||
Utils.toast(mContext, R.string.share_success_hint);
|
||||
EventBus.getDefault().post(new EBShare(ShareUtils.shareType));
|
||||
LogUtils.uploadShareResult(ShareUtils.shareType.getName(), "success",
|
||||
ShareUtils.shareEntity.getShareUrl(), ShareUtils.shareEntity.getShareTitle(), ShareUtils.shareEntity.getSummary(), ShareUtils.resourceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(UiError uiError) {
|
||||
Utils.toast(mContext, R.string.share_fail_hint);
|
||||
LogUtils.uploadShareResult(ShareUtils.shareType.getName(), "fail",
|
||||
ShareUtils.shareEntity.getShareUrl(), ShareUtils.shareEntity.getShareTitle(), ShareUtils.shareEntity.getSummary(), ShareUtils.resourceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
Utils.toast(mContext, R.string.share_cancel_hint);
|
||||
LogUtils.uploadShareResult(ShareUtils.shareType.getName(), "cancel",
|
||||
ShareUtils.shareEntity.getShareUrl(), ShareUtils.shareEntity.getShareTitle(), ShareUtils.shareEntity.getSummary(), ShareUtils.resourceId);
|
||||
}
|
||||
};
|
||||
|
||||
@ -153,7 +174,7 @@ public class ShareUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void showShareWindowsCallback(Activity activity, View view, String url, String icon, String shareTitle, String shareSummary, ShareType shareType, ShareCallBack callBack) {
|
||||
public void showShareWindowsCallback(Activity activity, View view, String url, String icon, String shareTitle, String shareSummary, ShareType shareType, String id, ShareCallBack callBack) {
|
||||
if (activity.isFinishing()) return;
|
||||
this.mActivity = new WeakReference<>(activity);
|
||||
this.shareIcon = icon;
|
||||
@ -162,6 +183,9 @@ public class ShareUtils {
|
||||
this.mTitle = shareTitle;
|
||||
this.mShareType = shareType;
|
||||
ShareUtils.shareType = mShareType;
|
||||
ShareUtils.resourceId = id;
|
||||
ShareUtils.shareEntity = new ShareEntity(shareUrl, mTitle, mSummary);
|
||||
LogUtils.uploadShareEnter(mShareType.getName(), shareUrl, mTitle, mSummary, id);
|
||||
|
||||
View contentView = View.inflate(mActivity.get(), R.layout.share_popup_layout, null);
|
||||
contentView.setFocusable(true);
|
||||
@ -239,8 +263,8 @@ public class ShareUtils {
|
||||
}
|
||||
|
||||
|
||||
public void showShareWindows(Activity activity, View view, String url, String icon, String shareTitle, String shareSummary, ShareType shareType) {
|
||||
showShareWindowsCallback(activity, view, url, icon, shareTitle, shareSummary, shareType, null);
|
||||
public void showShareWindows(Activity activity, View view, String url, String icon, String shareTitle, String shareSummary, ShareType shareType, String id) {
|
||||
showShareWindowsCallback(activity, view, url, icon, shareTitle, shareSummary, shareType, id, null);
|
||||
}
|
||||
|
||||
//QQ分享
|
||||
@ -253,6 +277,7 @@ public class ShareUtils {
|
||||
mSummary += "(光环加速版)";
|
||||
break;
|
||||
case askNormal:
|
||||
case answerNormal:
|
||||
case video:
|
||||
case communityArticle:
|
||||
mTitle += " - 光环助手";
|
||||
@ -294,6 +319,7 @@ public class ShareUtils {
|
||||
mSummary += "(光环加速版)";
|
||||
break;
|
||||
case askNormal:
|
||||
case answerNormal:
|
||||
case video:
|
||||
case communityArticle:
|
||||
mTitle += " - 光环助手";
|
||||
@ -402,6 +428,7 @@ public class ShareUtils {
|
||||
mSummary += "(光环加速版)";
|
||||
break;
|
||||
case askNormal:
|
||||
case answerNormal:
|
||||
case video:
|
||||
case communityArticle:
|
||||
mTitle += " - 光环助手";
|
||||
@ -452,6 +479,7 @@ public class ShareUtils {
|
||||
msg.title = mSummary;
|
||||
break;
|
||||
case askNormal:
|
||||
case answerNormal:
|
||||
case video:
|
||||
case communityArticle:
|
||||
msg.title = mTitle + " - 光环助手";
|
||||
@ -501,6 +529,7 @@ public class ShareUtils {
|
||||
switch (mShareType) {
|
||||
case news:
|
||||
case tools:
|
||||
case web:
|
||||
smsBody = mTitle + shareUrl;
|
||||
break;
|
||||
case plugin:
|
||||
@ -514,6 +543,7 @@ public class ShareUtils {
|
||||
break;
|
||||
case askInvite:
|
||||
case askNormal:
|
||||
case answerNormal:
|
||||
case video:
|
||||
case communityArticle:
|
||||
smsBody = mTitle + " - 光环助手" + shareUrl;
|
||||
@ -538,6 +568,7 @@ public class ShareUtils {
|
||||
|
||||
//复制文字链接
|
||||
private void copyLink(String copyContent) {
|
||||
LogUtils.uploadShareType("copy_link", shareUrl, mTitle, mSummary, resourceId);
|
||||
ClipboardManager cmb = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setText(copyContent);
|
||||
if (mShareType != ShareType.shareGh) {
|
||||
@ -576,22 +607,27 @@ public class ShareUtils {
|
||||
switch (holder.getPosition()) {
|
||||
case 0:
|
||||
MtaHelper.onEvent("内容分享", "微信好友", mTitle);
|
||||
LogUtils.uploadShareType("wechat_friend", shareUrl, mTitle, mSummary, resourceId);
|
||||
wechatShare();
|
||||
break;
|
||||
case 1:
|
||||
MtaHelper.onEvent("内容分享", "微信朋友圈", mTitle);
|
||||
LogUtils.uploadShareType("wechat_moment", shareUrl, mTitle, mSummary, resourceId);
|
||||
wechatMomentsShare();
|
||||
break;
|
||||
case 2:
|
||||
MtaHelper.onEvent("内容分享", "QQ好友", mTitle);
|
||||
LogUtils.uploadShareType("qq_friend", shareUrl, mTitle, mSummary, resourceId);
|
||||
qqShare();
|
||||
break;
|
||||
case 3:
|
||||
MtaHelper.onEvent("内容分享", "QQ空间", mTitle);
|
||||
LogUtils.uploadShareType("qq_zone", shareUrl, mTitle, mSummary, resourceId);
|
||||
qZoneShare();
|
||||
break;
|
||||
case 4:
|
||||
MtaHelper.onEvent("内容分享", "新浪微博", mTitle);
|
||||
LogUtils.uploadShareType("sina_weibo", shareUrl, mTitle, mSummary, resourceId);
|
||||
sinaWeiboShare();
|
||||
break;
|
||||
case 5:
|
||||
@ -602,7 +638,7 @@ public class ShareUtils {
|
||||
MtaHelper.onEvent("内容分享", "复制链接", mTitle);
|
||||
if (mShareType == ShareType.askInvite) {
|
||||
copyLink(mTitle + " - 光环助手" + shareUrl);
|
||||
} else if (mShareType == ShareType.askNormal) {
|
||||
} else if (mShareType == ShareType.askNormal || mShareType == ShareType.answerNormal) {
|
||||
copyLink(shareUrl);
|
||||
} else if (mShareType != ShareType.shareGh) {
|
||||
copyLink(shareUrl);
|
||||
@ -620,7 +656,7 @@ public class ShareUtils {
|
||||
if (mShareType != ShareType.shareGh) {
|
||||
popupWindow.get().dismiss();
|
||||
} else {
|
||||
copyLink("推荐光环助手,绿色安全的手游加速助手:" + shareUrl);
|
||||
LogUtils.uploadShareType("copy_link", shareUrl, mTitle, mSummary, resourceId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -655,12 +691,12 @@ public class ShareUtils {
|
||||
|
||||
void onCancel();
|
||||
}
|
||||
|
||||
|
||||
private static class SharePopupWindow extends PopupWindow {
|
||||
SharePopupWindow(View contentView, int width, int height, boolean focusable) {
|
||||
super(contentView, width, height, focusable);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
View backgroundView = getContentView().findViewById(R.id.share_container);
|
||||
@ -670,5 +706,5 @@ public class ShareUtils {
|
||||
getContentView().postDelayed(super::dismiss, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user