小程序
小游戏
企业微信
微信支付
扫描小程序码分享
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
微信号:helaoshi8786,时间2020.10.20 09:33或09:34
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
你好,麻烦复现问题的时候在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点(具体到分钟)。
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
微信号:helaoshi8786,时间2020.10.20 09:33或09:34
你好,麻烦复现问题的时候在手机微信那里上传下日志: 我->设置->帮助与反馈右上角有个上报日志的入口,麻烦提供一下微信号,时间点(具体到分钟)。
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.haoniu.schoolZT.R;
import com.haoniu.schoolZT.interfaces.OnCallBackListener;
import com.haoniu.schoolZT.util.ShareUtil;
import com.zds.base.Toast.ToastUtil;
import cn.sharesdk.wechat.friends.Wechat;
import cn.sharesdk.wechat.moments.WechatMoments;
public class ShareDialog<T> implements View.OnClickListener {
private T data;
private Context context;
private boolean shareCallback = false;
private BaseDialog mBaseDialog;
private String id;
private ClipboardManager mClipboard;
private String url;
private OnCallBackListener mOnCallBackListener;
private String title;
private String content;
private String imgUrl;
public ShareDialog(Builder tBuilder) {
this.context = tBuilder.context;
this.data = (T) tBuilder.data;
this.shareCallback = tBuilder.shareCallback;
this.id = tBuilder.id;
this.url = tBuilder.url;
this.mOnCallBackListener = tBuilder.mOnCallBackListener;
this.content = tBuilder.content;
this.imgUrl = tBuilder.imgUrl;
this.title = tBuilder.title;
mBaseDialog = BaseDialog.getUnInstance();
}
public static class Builder<T> {
private T data;
private Context context;
private boolean shareCallback = false;
private String id;
private String url;
private OnCallBackListener mOnCallBackListener;
private String title;
private String content;
private String imgUrl;
public Builder setTitle(String title) {
this.title = title;
return this;
}
public Builder setContent(String content) {
this.content = content;
return this;
}
public Builder setImgUrl(String imgUrl) {
this.imgUrl = imgUrl;
return this;
}
public Builder setOnCallBackListener(OnCallBackListener onCallBackListener) {
mOnCallBackListener = onCallBackListener;
return this;
}
public Builder setUrl(String url) {
this.url = url;
return this;
}
public Builder setId(String id) {
this.id = id;
return this;
}
public Builder setShareCallback(boolean shareCallback) {
this.shareCallback = shareCallback;
return this;
}
public Builder setData(T data) {
this.data = data;
return this;
}
public Builder setContext(Context context) {
this.context = context;
return this;
}
public ShareDialog build() {
return new ShareDialog(this);
}
}
public ShareDialog show() {
View view = LayoutInflater.from(context).inflate(R.layout.dialog_share, null);
RelativeLayout mRlWechat = view.findViewById(R.id.rllayour_wechat);
RelativeLayout mRlWeFriend = view.findViewById(R.id.rllayour_friend);
RelativeLayout mRlWeibo = view.findViewById(R.id.rllayour_weibo);
RelativeLayout mRlQQ = view.findViewById(R.id.rllayour_qq);
RelativeLayout mRlQQzone = view.findViewById(R.id.rllayour_qq_zone);
RelativeLayout mRlCopy = view.findViewById(R.id.rllayout_copy);
TextView mTvCancel = view.findViewById(R.id.tv_cancel);
mRlWechat.setOnClickListener(this);
mRlWeFriend.setOnClickListener(this);
mRlWeibo.setOnClickListener(this);
mRlQQ.setOnClickListener(this);
mRlQQzone.setOnClickListener(this);
mRlCopy.setOnClickListener(this);
mTvCancel.setOnClickListener(this);
mBaseDialog
.setLayoutView(view, context)
.setOnCancelClickListener(mTvCancel)
.isCancelable(true)
.bottomShow();
return this;
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.rllayour_wechat:
share(Wechat.NAME);
break;
case R.id.rllayour_friend:
share(WechatMoments.NAME);
break;
case R.id.rllayour_weibo:
break;
case R.id.rllayour_qq:
break;
case R.id.rllayour_qq_zone:
break;
case R.id.rllayout_copy:
if (null == mClipboard) {
mClipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
}
ClipData clip = ClipData.newPlainText("simple text",
"");
mClipboard.setPrimaryClip(clip);
ToastUtil.toast("复制成功");
break;
case R.id.tv_cancel:
break;
}
mBaseDialog.dissmissDialog();
}
private void share(String share_media) {
ShareUtil.Builder builder = new ShareUtil.Builder<>()
.setContext(context)
.setSHARE_media(share_media)
.setUrl(url)
.setTitle(title)
.setContent(content)
.setImgUrl(imgUrl)
.setOnCallBackListener(new OnCallBackListener() {
@Override
public void callBack(Object o) {//分享成功回调
if (shareCallback && mOnCallBackListener != null) {//true 回调
mOnCallBackListener.callBack(id);
}
}
});
builder.build().shareWeb();
}
}