Commit 48ef05e2 authored by jianglx's avatar jianglx

上传ShareChoiceDialog

parent d3a76bbb
package com.rv.share.view;
import android.content.Context;
import android.support.design.widget.BottomSheetDialog;
import android.view.View;
import android.widget.TextView;
import com.rv.share.R;
/*****
*
* 分享选择框
*/
public class ShareChoiceDialog implements View.OnClickListener {
private Context mContext;
private BottomSheetDialog dialog;
private TextView tvCopy;
private TextView tvWx;
private TextView tvWXC;
private TextView tvQQ;
private TextView tvBill;
private TextView tvCancle;
private ShareListener listener;
private boolean isShowCopy = false;
private boolean isShowBill = false;
private boolean isShowWx = false;
private boolean isShowWxC = false;
private boolean isShowQQ = false;
private ShareChoiceDialog(Context context) {
mContext = context;
dialog = new BottomSheetDialog(context);
}
private void create() {
View view = View.inflate(mContext, R.layout.dialog_share_choice, null);
tvCopy = view.findViewById(R.id.tv_copy);
tvWx = view.findViewById(R.id.tv_weixin);
tvWXC = view.findViewById(R.id.tv_weixin_circle);
tvQQ = view.findViewById(R.id.tv_qq);
tvBill = view.findViewById(R.id.tv_bill);
tvCancle = view.findViewById(R.id.tv_cancel);
if (isShowCopy) {
tvCopy.setVisibility(View.VISIBLE);
}
if (isShowWx) {
tvWx.setVisibility(View.VISIBLE);
}
if (isShowWxC) {
tvWXC.setVisibility(View.VISIBLE);
}
if (isShowQQ) {
tvQQ.setVisibility(View.VISIBLE);
}
if (isShowBill) {
tvBill.setVisibility(View.VISIBLE);
}
tvCopy.setOnClickListener(this);
tvWx.setOnClickListener(this);
tvWXC.setOnClickListener(this);
tvQQ.setOnClickListener(this);
tvBill.setOnClickListener(this);
tvCancle.setOnClickListener(this);
dialog.setContentView(view);
dialog.setCancelable(false);
}
public void show() {
dialog.show();
}
@Override
public void onClick(View view) {
int i = view.getId();
if (i == R.id.tv_copy) {
if (listener != null) {
listener.copyShare();
}
} else if (i == R.id.tv_weixin) {
if (listener != null) {
listener.wxShare();
}
} else if (i == R.id.tv_weixin_circle) {
if (listener != null) {
listener.wxCShare();
}
} else if (i == R.id.tv_qq) {
if (listener != null) {
listener.qqShare();
}
} else if (i == R.id.tv_bill) {
if (listener != null) {
listener.billShare();
}
} else if (i == R.id.tv_cancel) {
dialog.dismiss();
}
dialog.dismiss();
}
public static class Builder {
private ShareChoiceDialog dialog;
public Builder(Context context) {
dialog = new ShareChoiceDialog(context);
}
public Builder setShareListener(ShareListener listener) {
dialog.listener = listener;
return this;
}
public Builder setCopyVisiable(boolean b) {
dialog.isShowCopy = b;
return this;
}
public Builder setBillVisiable(boolean b) {
dialog.isShowBill = b;
return this;
}
public Builder setWxVisiable(boolean b) {
dialog.isShowWx = b;
return this;
}
public Builder setWxCVisiable(boolean b) {
dialog.isShowWxC = b;
return this;
}
public Builder setQQVisiable(boolean b) {
dialog.isShowQQ = b;
return this;
}
public ShareChoiceDialog create() {
dialog.create();
return dialog;
}
}
public interface ShareListener {
/****
* 复制链接
*/
void copyShare();
/****
* 微信分享
*/
void wxShare();
/*****
* 朋友圈分享
*/
void wxCShare();
/*****
* qq分享
*/
void qqShare();
/****
* 生成海报
*/
void billShare();
/*****
* 取消
*/
void close();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment