分享文案修改
This commit is contained in:
@ -36,8 +36,11 @@ public class ShareUtils {
|
||||
private static ShareUtils instance;
|
||||
|
||||
private String shareUrl;
|
||||
private String shareTitle;
|
||||
private String shareGameName;
|
||||
private String shareIcon;
|
||||
private String shareNewsTitle; // shareNewsTitle不为空就是新闻分享,否则是游戏分享
|
||||
|
||||
private boolean isPlugin = false;
|
||||
|
||||
private int maxHeight;
|
||||
private int[] arrLogo = {R.drawable.share_wechat_logo, R.drawable.share_wechatmoments_logo, R.drawable.share_qq_logo
|
||||
@ -57,10 +60,12 @@ public class ShareUtils {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void showShareWindows(View view, String url, String title, String icon){
|
||||
public void showShareWindows(View view, String url, String gameName, String icon ,String newsTitle, boolean isPlugin){
|
||||
this.shareIcon = icon;
|
||||
this.shareTitle = title;
|
||||
this.shareGameName = gameName;
|
||||
this.shareUrl = url;
|
||||
this.shareNewsTitle = newsTitle;
|
||||
this.isPlugin = isPlugin;
|
||||
|
||||
maxHeight = context.getResources().getDisplayMetrics().heightPixels;
|
||||
|
||||
@ -151,25 +156,25 @@ public class ShareUtils {
|
||||
public void onClick(View v) {
|
||||
switch (position){
|
||||
case 0:
|
||||
wechatSahre(shareUrl, shareTitle, shareIcon);
|
||||
wechatSahre();
|
||||
break;
|
||||
case 1:
|
||||
wechatMomentsSahre(shareUrl, shareTitle, shareIcon);
|
||||
wechatMomentsSahre();
|
||||
break;
|
||||
case 2:
|
||||
qqSahre(shareUrl, shareTitle, shareIcon);
|
||||
qqSahre();
|
||||
break;
|
||||
case 3:
|
||||
qZoneSahre(shareUrl, shareTitle, shareIcon);
|
||||
qZoneSahre();
|
||||
break;
|
||||
case 4:
|
||||
sinaWeiboSahre(shareUrl, shareTitle, shareIcon);
|
||||
sinaWeiboSahre();
|
||||
break;
|
||||
case 5:
|
||||
shortMessageSahre(shareUrl, shareTitle, shareIcon);
|
||||
shortMessageSahre();
|
||||
break;
|
||||
case 6:
|
||||
copyFont(shareUrl);
|
||||
copyLink(shareUrl);
|
||||
break;
|
||||
case 7:
|
||||
popupWindow.dismiss();
|
||||
@ -199,70 +204,127 @@ public class ShareUtils {
|
||||
}
|
||||
|
||||
//QQ分享
|
||||
private void qqSahre(String url, String title, String icon){
|
||||
private void qqSahre(){
|
||||
QQ.ShareParams qqParams = new QQ.ShareParams();
|
||||
qqParams.setTitle(title);
|
||||
qqParams.setText(title + " " + url);
|
||||
qqParams.setImageUrl(icon);
|
||||
qqParams.setTitleUrl(url);
|
||||
|
||||
if (shareNewsTitle != null){
|
||||
qqParams.setTitle(shareGameName);
|
||||
qqParams.setText(shareNewsTitle);
|
||||
}else {
|
||||
qqParams.setTitle("向你推荐:");
|
||||
if (isPlugin){
|
||||
qqParams.setText(shareGameName + "(光环加速版)");
|
||||
}else {
|
||||
qqParams.setText(shareGameName);
|
||||
}
|
||||
}
|
||||
qqParams.setImageUrl(shareIcon);
|
||||
qqParams.setTitleUrl(shareUrl);
|
||||
qqParams.setSite("光环助手");
|
||||
|
||||
sharePlatform(qqParams,QQ.NAME);
|
||||
}
|
||||
|
||||
//微信好友分享
|
||||
private void wechatSahre(String url, String title, String icon){
|
||||
private void wechatSahre(){
|
||||
Wechat.ShareParams wechatParams = new Wechat.ShareParams();
|
||||
wechatParams.setText(title + " " + url);
|
||||
wechatParams.setImageUrl(icon);
|
||||
wechatParams.setTitle(title);
|
||||
wechatParams.setUrl(url);
|
||||
|
||||
if (shareNewsTitle != null){
|
||||
wechatParams.setText(shareNewsTitle);
|
||||
}else {
|
||||
if (isPlugin){
|
||||
wechatParams.setText("向你推荐:" + shareGameName + "(光环加速版)");
|
||||
}else {
|
||||
wechatParams.setText("向你推荐:" + shareGameName);
|
||||
}
|
||||
}
|
||||
wechatParams.setImageUrl(shareIcon);
|
||||
wechatParams.setUrl(shareUrl);
|
||||
|
||||
sharePlatform(wechatParams,Wechat.NAME);
|
||||
}
|
||||
|
||||
//QQ空间分享
|
||||
private void qZoneSahre(String url, String title, String icon){
|
||||
private void qZoneSahre(){
|
||||
QZone.ShareParams qZoneParams = new QZone.ShareParams();
|
||||
qZoneParams.setTitle(title);
|
||||
qZoneParams.setText(title + " " + url);
|
||||
qZoneParams.setImageUrl(icon);
|
||||
qZoneParams.setTitleUrl(url);
|
||||
qZoneParams.setComment("精彩尽在" + url);
|
||||
qZoneParams.setSite(context.getString(R.string.app_name));
|
||||
qZoneParams.setSiteUrl(url);
|
||||
|
||||
if (shareNewsTitle != null){
|
||||
qZoneParams.setTitle(shareGameName);
|
||||
qZoneParams.setText(shareNewsTitle);
|
||||
}else {
|
||||
qZoneParams.setTitle("向你推荐:");
|
||||
if (isPlugin){
|
||||
qZoneParams.setText("向你推荐:" + shareGameName + "(光环加速版)");
|
||||
}else {
|
||||
qZoneParams.setText("向你推荐:" + shareGameName);
|
||||
}
|
||||
}
|
||||
qZoneParams.setImageUrl(shareIcon);
|
||||
qZoneParams.setTitleUrl(shareUrl);
|
||||
qZoneParams.setSite("光环助手");
|
||||
|
||||
sharePlatform(qZoneParams,QZone.NAME);
|
||||
}
|
||||
|
||||
//微信朋友圈分享
|
||||
private void wechatMomentsSahre(String url, String title, String icon){
|
||||
private void wechatMomentsSahre(){
|
||||
WechatMoments.ShareParams wechatMomentsParams = new WechatMoments.ShareParams();
|
||||
wechatMomentsParams.setText(title + " " + url);
|
||||
wechatMomentsParams.setTitle(title);
|
||||
wechatMomentsParams.setImageUrl(icon);
|
||||
wechatMomentsParams.setUrl(url);
|
||||
|
||||
if (shareNewsTitle != null){
|
||||
wechatMomentsParams.setText(shareNewsTitle);
|
||||
}else {
|
||||
if (isPlugin){
|
||||
wechatMomentsParams.setText("向你推荐:" + shareGameName + "(光环加速版)");
|
||||
}else {
|
||||
wechatMomentsParams.setText("向你推荐:" + shareGameName);
|
||||
}
|
||||
}
|
||||
wechatMomentsParams.setImageUrl(shareIcon);
|
||||
wechatMomentsParams.setUrl(shareUrl);
|
||||
|
||||
sharePlatform(wechatMomentsParams, WechatMoments.NAME);
|
||||
}
|
||||
|
||||
//新浪微博分享
|
||||
private void sinaWeiboSahre(String url, String title, String icon){
|
||||
private void sinaWeiboSahre(){
|
||||
SinaWeibo.ShareParams sinaWeiboParams = new SinaWeibo.ShareParams();
|
||||
sinaWeiboParams.setTitle(title);
|
||||
sinaWeiboParams.setImageUrl(icon);
|
||||
sinaWeiboParams.setUrl(url);
|
||||
sinaWeiboParams.setText(title + " " + url);
|
||||
|
||||
if (shareNewsTitle != null){
|
||||
sinaWeiboParams.setText(shareNewsTitle);
|
||||
}else {
|
||||
if (isPlugin){
|
||||
sinaWeiboParams.setText("向你推荐:" + shareGameName + "(光环加速版)");
|
||||
}else {
|
||||
sinaWeiboParams.setText("向你推荐:" + shareGameName);
|
||||
}
|
||||
}
|
||||
|
||||
sharePlatform(sinaWeiboParams, SinaWeibo.NAME);
|
||||
}
|
||||
|
||||
//短信分享
|
||||
private void shortMessageSahre(String url, String title, String icon){
|
||||
private void shortMessageSahre(){
|
||||
ShortMessage.ShareParams shortMessageParams = new ShortMessage.ShareParams();
|
||||
shortMessageParams.setText(title + " " + url);
|
||||
shortMessageParams.setUrl(url);
|
||||
shortMessageParams.setImageUrl(icon);
|
||||
|
||||
if (shareNewsTitle != null){
|
||||
shortMessageParams.setText(shareNewsTitle);
|
||||
}else {
|
||||
if (isPlugin){
|
||||
shortMessageParams.setText("向你推荐:" + shareGameName + "(光环加速版)");
|
||||
}else {
|
||||
shortMessageParams.setText("向你推荐:" + shareGameName);
|
||||
}
|
||||
}
|
||||
shortMessageParams.setUrl(shareUrl);
|
||||
shortMessageParams.setTitleUrl(shareUrl);
|
||||
|
||||
sharePlatform(shortMessageParams, ShortMessage.NAME);
|
||||
}
|
||||
|
||||
//分享平台回调
|
||||
private void sharePlatform(Platform.ShareParams params, String name) {
|
||||
Utils.toast(context,"分享跳转中...");
|
||||
|
||||
Platform platform = ShareSDK.getPlatform(name);
|
||||
platform.setPlatformActionListener(new PlatformActionListener() {
|
||||
@Override
|
||||
@ -281,11 +343,15 @@ public class ShareUtils {
|
||||
}
|
||||
});
|
||||
platform.share(params);
|
||||
popupWindow.dismiss();
|
||||
}
|
||||
|
||||
//复制文字链接
|
||||
private void copyFont(String copyContent) {
|
||||
private void copyLink(String copyContent) {
|
||||
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setText(copyContent);
|
||||
popupWindow.dismiss();
|
||||
|
||||
Utils.toast(context,"复制成功");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user