修改分享事件上报
This commit is contained in:
@ -84,7 +84,7 @@ public class ShareUtils {
|
||||
R.drawable.share_cancel_logo
|
||||
};
|
||||
|
||||
public enum ShareType {
|
||||
public enum ShareEntrance {
|
||||
news("资讯文章"),
|
||||
game("游戏详情"), // 普通游戏
|
||||
plugin("游戏详情"), // 插件游戏
|
||||
@ -99,7 +99,7 @@ public class ShareUtils {
|
||||
|
||||
private String name;
|
||||
|
||||
ShareType(String name) {
|
||||
ShareEntrance(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@ -112,9 +112,10 @@ public class ShareUtils {
|
||||
|
||||
private WeakReference<PopupWindow> popupWindow;
|
||||
|
||||
private ShareType mShareType;
|
||||
public static ShareType shareType;//全局保存shareType,分享成功后判断分享的类型
|
||||
public static String resourceId = "";//分析内容的id(事件上报用)
|
||||
private ShareEntrance mShareEntrance;
|
||||
public static String shareType = "";//分享类型(事件上报用)
|
||||
public static ShareEntrance shareEntrance;//分享入口(事件上报和视频分享统计用)
|
||||
public static String resourceId = "";//分享内容的id(事件上报用)
|
||||
public static ShareEntity shareEntity;//分享信息(事件上报用)
|
||||
|
||||
private WeakReference<Activity> mActivity;
|
||||
@ -125,22 +126,22 @@ public class ShareUtils {
|
||||
@Override
|
||||
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",
|
||||
EventBus.getDefault().post(new EBShare(ShareUtils.shareEntrance));
|
||||
LogUtils.uploadShareResult(shareType, ShareUtils.shareEntrance.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",
|
||||
LogUtils.uploadShareResult(shareType, ShareUtils.shareEntrance.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",
|
||||
LogUtils.uploadShareResult(shareType, ShareUtils.shareEntrance.getName(), "cancel",
|
||||
ShareUtils.shareEntity.getShareUrl(), ShareUtils.shareEntity.getShareTitle(), ShareUtils.shareEntity.getSummary(), ShareUtils.resourceId);
|
||||
}
|
||||
};
|
||||
@ -174,18 +175,18 @@ public class ShareUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void showShareWindowsCallback(Activity activity, View view, String url, String icon, String shareTitle, String shareSummary, ShareType shareType, String id, ShareCallBack callBack) {
|
||||
public void showShareWindowsCallback(Activity activity, View view, String url, String icon, String shareTitle, String shareSummary, ShareEntrance shareEntrance, String id, ShareCallBack callBack) {
|
||||
if (activity.isFinishing()) return;
|
||||
this.mActivity = new WeakReference<>(activity);
|
||||
this.shareIcon = icon;
|
||||
this.shareUrl = url;
|
||||
this.mSummary = shareSummary;
|
||||
this.mTitle = shareTitle;
|
||||
this.mShareType = shareType;
|
||||
ShareUtils.shareType = mShareType;
|
||||
this.mShareEntrance = shareEntrance;
|
||||
ShareUtils.shareEntrance = mShareEntrance;
|
||||
ShareUtils.resourceId = id;
|
||||
ShareUtils.shareEntity = new ShareEntity(shareUrl, mTitle, mSummary);
|
||||
LogUtils.uploadShareEnter(mShareType.getName(), shareUrl, mTitle, mSummary, id);
|
||||
LogUtils.uploadShareEnter(mShareEntrance.getName(), shareUrl, mTitle, mSummary, id);
|
||||
|
||||
View contentView = View.inflate(mActivity.get(), R.layout.share_popup_layout, null);
|
||||
contentView.setFocusable(true);
|
||||
@ -215,7 +216,7 @@ public class ShareUtils {
|
||||
}
|
||||
});
|
||||
|
||||
if (mShareType == ShareType.shareGh) {
|
||||
if (mShareEntrance == ShareEntrance.shareGh) {
|
||||
RelativeLayout layout = (RelativeLayout) view;
|
||||
layout.addView(contentView);
|
||||
arrLabel[6] = "邮件";
|
||||
@ -263,8 +264,8 @@ public class ShareUtils {
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
public void showShareWindows(Activity activity, View view, String url, String icon, String shareTitle, String shareSummary, ShareEntrance shareEntrance, String id) {
|
||||
showShareWindowsCallback(activity, view, url, icon, shareTitle, shareSummary, shareEntrance, id, null);
|
||||
}
|
||||
|
||||
//QQ分享
|
||||
@ -272,7 +273,7 @@ public class ShareUtils {
|
||||
Utils.toast(mContext, R.string.share_skip);
|
||||
Bundle params = new Bundle();
|
||||
|
||||
switch (mShareType) {
|
||||
switch (mShareEntrance) {
|
||||
case plugin:
|
||||
mSummary += "(光环加速版)";
|
||||
break;
|
||||
@ -296,7 +297,7 @@ public class ShareUtils {
|
||||
mTencent.shareToQQ(activity, params, QqShareListener);
|
||||
}
|
||||
|
||||
if (mShareType != ShareType.shareGh) {
|
||||
if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
popupWindow.get().dismiss();
|
||||
}
|
||||
}
|
||||
@ -314,7 +315,7 @@ public class ShareUtils {
|
||||
WXMediaMessage msg = new WXMediaMessage(webpage);
|
||||
webpage.webpageUrl = shareUrl;
|
||||
|
||||
switch (mShareType) {
|
||||
switch (mShareEntrance) {
|
||||
case plugin:
|
||||
mSummary += "(光环加速版)";
|
||||
break;
|
||||
@ -336,7 +337,7 @@ public class ShareUtils {
|
||||
req.scene = SendMessageToWX.Req.WXSceneSession;
|
||||
|
||||
loadBitMap(shareIcon, msg, req);
|
||||
if (mShareType != ShareType.shareGh) {
|
||||
if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
popupWindow.get().dismiss();
|
||||
}
|
||||
}
|
||||
@ -349,14 +350,14 @@ public class ShareUtils {
|
||||
ImageUtils.display(mContext, iconUrl, new BaseBitmapDataSubscriber() {
|
||||
@Override
|
||||
protected void onNewResultImpl(Bitmap bitmap) {
|
||||
if (mShareType == ShareType.video) {
|
||||
if (mShareEntrance == ShareEntrance.video) {
|
||||
// 分享类型为视频时裁为正方形
|
||||
int dimension = Math.min(bitmap.getWidth(), bitmap.getHeight());
|
||||
bitmap = ThumbnailUtils.extractThumbnail(bitmap, dimension, dimension);
|
||||
}
|
||||
|
||||
Bitmap compressBp = compressBitmap(bitmap);
|
||||
if (mShareType == ShareType.askNormal || mShareType == ShareType.askInvite) {
|
||||
if (mShareEntrance == ShareEntrance.askNormal || mShareEntrance == ShareEntrance.askInvite) {
|
||||
msg.thumbData = ImageUtils.bmpToByteArray(compressBp, true);
|
||||
} else {
|
||||
Bitmap resultBp = addBackGround(compressBp);
|
||||
@ -423,7 +424,7 @@ public class ShareUtils {
|
||||
Utils.toast(mContext, R.string.share_skip);
|
||||
Bundle params = new Bundle();
|
||||
|
||||
switch (mShareType) {
|
||||
switch (mShareEntrance) {
|
||||
case plugin:
|
||||
mSummary += "(光环加速版)";
|
||||
break;
|
||||
@ -452,7 +453,7 @@ public class ShareUtils {
|
||||
mTencent.shareToQzone(activity, params, QqShareListener);
|
||||
}
|
||||
|
||||
if (mShareType != ShareType.shareGh) {
|
||||
if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
popupWindow.get().dismiss();
|
||||
}
|
||||
}
|
||||
@ -471,7 +472,7 @@ public class ShareUtils {
|
||||
|
||||
webpage.webpageUrl = shareUrl;
|
||||
|
||||
switch (mShareType) {
|
||||
switch (mShareEntrance) {
|
||||
case plugin:
|
||||
msg.title = mSummary + "(光环加速版)";
|
||||
break;
|
||||
@ -497,7 +498,7 @@ public class ShareUtils {
|
||||
req.scene = SendMessageToWX.Req.WXSceneTimeline;
|
||||
|
||||
loadBitMap(shareIcon, msg, req);
|
||||
if (mShareType != ShareType.shareGh) {
|
||||
if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
popupWindow.get().dismiss();
|
||||
}
|
||||
}
|
||||
@ -513,12 +514,12 @@ public class ShareUtils {
|
||||
shareIcon,
|
||||
mTitle,
|
||||
mSummary,
|
||||
mShareType.toString());
|
||||
mShareEntrance.toString());
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
|
||||
|
||||
if (mShareType != ShareType.shareGh) {
|
||||
if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
popupWindow.get().dismiss();
|
||||
}
|
||||
}
|
||||
@ -526,7 +527,7 @@ public class ShareUtils {
|
||||
//短信分享
|
||||
private void shortMessageShare() {
|
||||
String smsBody;
|
||||
switch (mShareType) {
|
||||
switch (mShareEntrance) {
|
||||
case news:
|
||||
case tools:
|
||||
case web:
|
||||
@ -561,17 +562,18 @@ public class ShareUtils {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (mShareType != ShareType.shareGh) {
|
||||
if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
popupWindow.get().dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
//复制文字链接
|
||||
private void copyLink(String copyContent) {
|
||||
LogUtils.uploadShareType("copy_link", shareUrl, mTitle, mSummary, resourceId);
|
||||
shareType = "copy_link";
|
||||
LogUtils.uploadShareType(shareType, shareEntrance.getName(), shareUrl, mTitle, mSummary, resourceId);
|
||||
ClipboardManager cmb = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setText(copyContent);
|
||||
if (mShareType != ShareType.shareGh) {
|
||||
if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
Utils.toast(mContext, "复制成功");
|
||||
popupWindow.get().dismiss();
|
||||
} else {
|
||||
@ -598,7 +600,7 @@ public class ShareUtils {
|
||||
holder.shareLogo.setImageResource(arrLogo[position]);
|
||||
holder.shareLabel.setText(arrLabel[position]);
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
if (mShareType == ShareUtils.ShareType.shareGh) {
|
||||
if (mShareEntrance == ShareEntrance.shareGh) {
|
||||
MtaHelper.onEvent("我的光环_新", "分享光环", arrLabel[position]);
|
||||
}
|
||||
if (listener != null) {
|
||||
@ -606,28 +608,33 @@ public class ShareUtils {
|
||||
}
|
||||
switch (holder.getPosition()) {
|
||||
case 0:
|
||||
shareType = "wechat_friend";
|
||||
MtaHelper.onEvent("内容分享", "微信好友", mTitle);
|
||||
LogUtils.uploadShareType("wechat_friend", shareUrl, mTitle, mSummary, resourceId);
|
||||
LogUtils.uploadShareType(shareType, shareEntrance.getName(), shareUrl, mTitle, mSummary, resourceId);
|
||||
wechatShare();
|
||||
break;
|
||||
case 1:
|
||||
shareType = "wechat_moment";
|
||||
MtaHelper.onEvent("内容分享", "微信朋友圈", mTitle);
|
||||
LogUtils.uploadShareType("wechat_moment", shareUrl, mTitle, mSummary, resourceId);
|
||||
LogUtils.uploadShareType(shareType, shareEntrance.getName(), shareUrl, mTitle, mSummary, resourceId);
|
||||
wechatMomentsShare();
|
||||
break;
|
||||
case 2:
|
||||
shareType = "qq_friend";
|
||||
MtaHelper.onEvent("内容分享", "QQ好友", mTitle);
|
||||
LogUtils.uploadShareType("qq_friend", shareUrl, mTitle, mSummary, resourceId);
|
||||
LogUtils.uploadShareType(shareType, shareEntrance.getName(), shareUrl, mTitle, mSummary, resourceId);
|
||||
qqShare();
|
||||
break;
|
||||
case 3:
|
||||
shareType = "qq_zone";
|
||||
MtaHelper.onEvent("内容分享", "QQ空间", mTitle);
|
||||
LogUtils.uploadShareType("qq_zone", shareUrl, mTitle, mSummary, resourceId);
|
||||
LogUtils.uploadShareType(shareType, shareEntrance.getName(), shareUrl, mTitle, mSummary, resourceId);
|
||||
qZoneShare();
|
||||
break;
|
||||
case 4:
|
||||
shareType = "sina_weibo";
|
||||
MtaHelper.onEvent("内容分享", "新浪微博", mTitle);
|
||||
LogUtils.uploadShareType("sina_weibo", shareUrl, mTitle, mSummary, resourceId);
|
||||
LogUtils.uploadShareType(shareType, shareEntrance.getName(), shareUrl, mTitle, mSummary, resourceId);
|
||||
sinaWeiboShare();
|
||||
break;
|
||||
case 5:
|
||||
@ -636,11 +643,11 @@ public class ShareUtils {
|
||||
break;
|
||||
case 6:
|
||||
MtaHelper.onEvent("内容分享", "复制链接", mTitle);
|
||||
if (mShareType == ShareType.askInvite) {
|
||||
if (mShareEntrance == ShareEntrance.askInvite) {
|
||||
copyLink(mTitle + " - 光环助手" + shareUrl);
|
||||
} else if (mShareType == ShareType.askNormal || mShareType == ShareType.answerNormal) {
|
||||
} else if (mShareEntrance == ShareEntrance.askNormal || mShareEntrance == ShareEntrance.answerNormal) {
|
||||
copyLink(shareUrl);
|
||||
} else if (mShareType != ShareType.shareGh) {
|
||||
} else if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
copyLink(shareUrl);
|
||||
} else {
|
||||
try {
|
||||
@ -653,10 +660,11 @@ public class ShareUtils {
|
||||
}
|
||||
break;
|
||||
case 7:
|
||||
if (mShareType != ShareType.shareGh) {
|
||||
if (mShareEntrance != ShareEntrance.shareGh) {
|
||||
popupWindow.get().dismiss();
|
||||
} else {
|
||||
LogUtils.uploadShareType("copy_link", shareUrl, mTitle, mSummary, resourceId);
|
||||
shareType = "copy_link";
|
||||
LogUtils.uploadShareType(shareType, shareEntrance.getName(), shareUrl, mTitle, mSummary, resourceId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user