修改交友布局
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package com.xscm.moduleutil.widget.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
import androidx.databinding.ViewDataBinding;
|
||||
|
||||
import com.xscm.moduleutil.R;
|
||||
|
||||
|
||||
public abstract class BaseDialog<VDM extends ViewDataBinding> extends Dialog {
|
||||
|
||||
protected VDM mBinding;
|
||||
|
||||
public BaseDialog(@NonNull Context context) {
|
||||
this(context, R.style.BaseDialogStyle);
|
||||
}
|
||||
|
||||
public BaseDialog(@NonNull Context context, int themeResId) {
|
||||
super(context, themeResId);
|
||||
mBinding = DataBindingUtil.bind(LayoutInflater.from(context).inflate(getLayoutId(), null, false));
|
||||
if (mBinding != null) {
|
||||
setContentView(mBinding.getRoot());
|
||||
}
|
||||
getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dismiss() {
|
||||
super.dismiss();
|
||||
if (mBinding!=null){
|
||||
mBinding.unbind();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract int getLayoutId();
|
||||
|
||||
public abstract void initView();
|
||||
|
||||
public abstract void initData();
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package com.xscm.moduleutil.widget.dialog;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.adapter.LikeListAdapter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.databinding.FragmentCommentDialogBinding;
|
||||
import com.xscm.moduleutil.presenter.CommentContacts;
|
||||
import com.xscm.moduleutil.presenter.CommentPresenter;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/30
|
||||
*@description: 点赞列表弹窗
|
||||
*/
|
||||
public class CommentDialogFragment extends BaseMvpDialogFragment<CommentPresenter, FragmentCommentDialogBinding> implements
|
||||
CommentContacts.View {
|
||||
private int page;
|
||||
private LikeListAdapter likeListAdapter;
|
||||
@Override
|
||||
protected CommentPresenter bindPresenter() {
|
||||
return new CommentPresenter(this, getActivity());
|
||||
}
|
||||
public static void show(String id, FragmentManager fragmentManager) {
|
||||
CommentDialogFragment dialogFragment = new CommentDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("id", id); // 可选:传递参数
|
||||
dialogFragment.setArguments(args);
|
||||
dialogFragment.show(fragmentManager, "CommentDialogFragment");
|
||||
}
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getCommentList(getArguments().getString("id"));
|
||||
}
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
if (window != null) {
|
||||
// 设置固定高度为 500dp
|
||||
int heightInDp = 450;
|
||||
int heightInPx = (int) (heightInDp * getResources().getDisplayMetrics().density);
|
||||
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, heightInPx);
|
||||
|
||||
// 可选:设置动画样式(从底部弹出)
|
||||
window.setWindowAnimations(R.style.CommonShowDialogBottom);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
mBinding.srl.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getCommentList(getArguments().getString("id"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
// EventBus.getDefault().post(new BannerRefreshEvent());
|
||||
page = 1;
|
||||
MvpPre.getCommentList(getArguments().getString("id"));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mBinding.rvComment.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
likeListAdapter = new LikeListAdapter();
|
||||
mBinding.rvComment.setAdapter(likeListAdapter);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_comment_dialog;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void getCommentList(List<CircleListBean.LikeList> likeLists) {
|
||||
mBinding.tvNum.setText("已有"+likeLists.size()+"人点赞");
|
||||
likeListAdapter.setNewData(likeLists);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.xscm.moduleutil.widget.dialog;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
|
||||
public class CommonDialog extends BaseDialog {
|
||||
|
||||
TextView tvContent;
|
||||
TextView textViewLeft;
|
||||
TextView textViewRight;
|
||||
|
||||
private OnClickListener mOnClickListener;
|
||||
|
||||
|
||||
public CommonDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.dialog_common;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
getWindow().setLayout((int) (ScreenUtils.getScreenWidth() * 0.86), ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
tvContent = mBinding.getRoot().findViewById(R.id.tv_content);
|
||||
textViewLeft = mBinding.getRoot().findViewById(R.id.tv_left);
|
||||
textViewRight = mBinding.getRoot().findViewById(R.id.tv_right);
|
||||
textViewLeft.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
mOnClickListener.onLeftClick();
|
||||
}
|
||||
});
|
||||
textViewRight.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
mOnClickListener.onRightClick();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void setContent(String content) {
|
||||
tvContent.setText(content);
|
||||
}
|
||||
|
||||
public void setLeftText(String leftText) {
|
||||
textViewLeft.setText(leftText);
|
||||
}
|
||||
|
||||
public void setRightText(String rightText) {
|
||||
textViewRight.setText(rightText);
|
||||
}
|
||||
|
||||
public void setmOnClickListener(OnClickListener onClickListener) {
|
||||
this.mOnClickListener = onClickListener;
|
||||
}
|
||||
|
||||
|
||||
public interface OnClickListener {
|
||||
void onLeftClick();
|
||||
|
||||
void onRightClick();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,240 @@
|
||||
package com.xscm.moduleutil.widget.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
|
||||
import com.xscm.moduleutil.R;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 项目名称 qipao-android
|
||||
* 包名:com.qpyy.room.widget
|
||||
* 创建人 黄强
|
||||
* 创建时间 2020/8/6 16:55
|
||||
* 描述 自定义数字键盘
|
||||
*/
|
||||
|
||||
public class KeyboardPopupWindow extends PopupWindow {
|
||||
private static final String TAG = "KeyboardPopupWindow";
|
||||
private Context context;
|
||||
private View anchorView;
|
||||
private View parentView;
|
||||
private EditText editText;
|
||||
private boolean isRandomSort = false;//数字是否随机排序
|
||||
private List<Integer> list = new ArrayList<>();
|
||||
private int[] commonButtonIds = new int[]{R.id.bt_keyboard1, R.id.bt_keyboard2, R.id.bt_keyboard3, R.id.bt_keyboard4,
|
||||
R.id.bt_keyboard5, R.id.bt_keyboard6, R.id.bt_keyboard7, R.id.bt_keyboard8, R.id.bt_keyboard9, R.id.bt_keyboard0};
|
||||
|
||||
private KeyboardCompleteListener mListener;
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* @param anchorView
|
||||
* @param
|
||||
* @param
|
||||
*/
|
||||
public KeyboardPopupWindow(Context context, View anchorView) {
|
||||
this.context = context;
|
||||
this.anchorView = anchorView;
|
||||
this.isRandomSort = isRandomSort;
|
||||
if (context == null || anchorView == null) {
|
||||
return;
|
||||
}
|
||||
initConfig();
|
||||
initView();
|
||||
Log.d(TAG, "KeyboardPopupWindow: =====================打开了自定义键盘");
|
||||
}
|
||||
|
||||
|
||||
private void initConfig() {
|
||||
setOutsideTouchable(false);
|
||||
setFocusable(false);
|
||||
setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
forbidDefaultSoftKeyboard();
|
||||
}
|
||||
|
||||
/**
|
||||
* 禁止系统默认的软键盘弹出
|
||||
*/
|
||||
private void forbidDefaultSoftKeyboard() {
|
||||
if (editText == null) {
|
||||
return;
|
||||
}
|
||||
if (android.os.Build.VERSION.SDK_INT > 10) {//4.0以上,使用反射的方式禁止系统自带的软键盘弹出
|
||||
try {
|
||||
Class<EditText> cls = EditText.class;
|
||||
Method setShowSoftInputOnFocus;
|
||||
setShowSoftInputOnFocus = cls.getMethod("setShowSoftInputOnFocus", boolean.class);
|
||||
setShowSoftInputOnFocus.setAccessible(true);
|
||||
setShowSoftInputOnFocus.invoke(editText, false);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新自定义的popupwindow是否outside可触摸反应:如果是不可触摸的,则显示该软键盘view
|
||||
*
|
||||
* @param isTouchable
|
||||
*/
|
||||
public void refreshKeyboardOutSideTouchable(boolean isTouchable) {
|
||||
setOutsideTouchable(isTouchable);
|
||||
if (!isTouchable) {
|
||||
show();
|
||||
} else {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
parentView = LayoutInflater.from(context).inflate(R.layout.room_custom_num_keyboard, null);
|
||||
initKeyboardView(parentView);
|
||||
setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
setContentView(parentView);
|
||||
this.setBackgroundDrawable(new BitmapDrawable());
|
||||
this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
this.setFocusable(true);
|
||||
this.setOutsideTouchable(true);
|
||||
this.setTouchable(true);
|
||||
this.setAnimationStyle(R.style.mypopwindow_anim_style);
|
||||
}
|
||||
|
||||
private void initKeyboardView(View view) {
|
||||
//初始化编辑框
|
||||
editText = view.findViewById(R.id.et_keyboard_input);
|
||||
editText.setFocusable(false);//禁止编辑框获取焦点
|
||||
//①给数字键设置点击监听
|
||||
for (int i = 0; i < commonButtonIds.length; i++) {
|
||||
final Button button = view.findViewById(commonButtonIds[i]);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int curSelection = editText.getSelectionStart();
|
||||
int length = editText.getText().toString().length();
|
||||
if (curSelection < length) {
|
||||
String content = editText.getText().toString();
|
||||
editText.setText(content.substring(0, curSelection) + button.getText() + content.subSequence(curSelection, length));
|
||||
editText.setSelection(curSelection + 1);
|
||||
} else {
|
||||
if (length == 0 && button.getText().toString().equals("0") || equals("")) {
|
||||
return;
|
||||
}
|
||||
editText.setText(editText.getText().toString() + button.getText());
|
||||
editText.setSelection(editText.getText().toString().length());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//③给叉按键设置点击监听
|
||||
view.findViewById(R.id.rl_keyboard_cross).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int length = editText.getText().toString().length();
|
||||
int curSelection = editText.getSelectionStart();
|
||||
if (length > 0 && curSelection > 0 && curSelection <= length) {
|
||||
String content = editText.getText().toString();
|
||||
editText.setText(content.substring(0, curSelection - 1) + content.subSequence(curSelection, length));
|
||||
editText.setSelection(curSelection - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//③给叉按键设置点击监听
|
||||
view.findViewById(R.id.iv_keyboard_cross).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int length = editText.getText().toString().length();
|
||||
int curSelection = editText.getSelectionStart();
|
||||
if (length > 0 && curSelection > 0 && curSelection <= length) {
|
||||
String content = editText.getText().toString();
|
||||
editText.setText(content.substring(0, curSelection - 1) + content.subSequence(curSelection, length));
|
||||
editText.setSelection(curSelection - 1);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
//确定
|
||||
view.findViewById(R.id.bt_keyboard_ok).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Log.d(TAG, "onClick: 您输入的数量是:" + editText.getText().toString());
|
||||
mListener.inputComplete(editText.getText().toString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void show() {
|
||||
if (!isShowing() && anchorView != null) {
|
||||
// doRandomSortOp();
|
||||
this.showAtLocation(anchorView, Gravity.BOTTOM, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 随机分布数字
|
||||
*/
|
||||
private void doRandomSortOp() {
|
||||
if (parentView == null) {
|
||||
return;
|
||||
}
|
||||
if (!isRandomSort) {
|
||||
for (int i = 0; i < commonButtonIds.length; i++) {
|
||||
final Button button = parentView.findViewById(commonButtonIds[i]);
|
||||
button.setText("" + i);
|
||||
}
|
||||
} else {
|
||||
list.clear();
|
||||
Random ran = new Random();
|
||||
while (list.size() < commonButtonIds.length) {
|
||||
int n = ran.nextInt(commonButtonIds.length);
|
||||
if (!list.contains(n))
|
||||
list.add(n);
|
||||
}
|
||||
for (int i = 0; i < commonButtonIds.length; i++) {
|
||||
final Button button = parentView.findViewById(commonButtonIds[i]);
|
||||
button.setText("" + list.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void releaseResources() {
|
||||
this.dismiss();
|
||||
context = null;
|
||||
anchorView = null;
|
||||
if (list != null) {
|
||||
list.clear();
|
||||
list = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void addRoomPasswordListener(KeyboardCompleteListener listener) {
|
||||
mListener = listener;
|
||||
}
|
||||
|
||||
public interface KeyboardCompleteListener {
|
||||
|
||||
void inputComplete(String inputContent);//输入完成
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.xscm.moduleutil.widget.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomAuction;
|
||||
import com.xscm.moduleutil.databinding.DialogRewardFragmentBinding;
|
||||
import com.xscm.moduleutil.databinding.FragmentRewardGiftDialogBinding;
|
||||
import com.xscm.moduleutil.presenter.RewardGiftContacts;
|
||||
import com.xscm.moduleutil.presenter.RewardGiftPresenter;
|
||||
import com.xscm.moduleutil.utils.ChatLauncher;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/6/16
|
||||
* @description: 广场中所有的打赏榜单列表
|
||||
*/
|
||||
public class RewardDialogFragment extends BaseMvpDialogFragment<RewardGiftPresenter, DialogRewardFragmentBinding> implements RewardGiftContacts.View {
|
||||
private String circle_id;
|
||||
private BaseQuickAdapter<RewardUserBean, BaseViewHolder> adapter;
|
||||
private int page;
|
||||
|
||||
public static void show(String id, FragmentManager fragmentManager) {
|
||||
RewardDialogFragment dialogFragment = new RewardDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("circle_id", id); // 可选:传递参数
|
||||
dialogFragment.setArguments(args);
|
||||
dialogFragment.show(fragmentManager, "RewardDialogFragment");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
circle_id = getArguments().getString("circle_id");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
window = getDialog().getWindow();
|
||||
if (window != null) {
|
||||
// 设置固定高度为 500dp
|
||||
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
||||
int heightInDp = (int) (screenHeight * 0.8f);;
|
||||
int heightInPx = (int) heightInDp;
|
||||
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, heightInPx);
|
||||
|
||||
// 可选:设置动画样式(从底部弹出)
|
||||
window.setWindowAnimations(com.xscm.moduleutil.R.style.CommonShowDialogBottom);
|
||||
// 强制支持 adjustResize 行为
|
||||
// window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RewardGiftPresenter bindPresenter() {
|
||||
return new RewardGiftPresenter(this, getActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getRewardList(circle_id, 1, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.srl.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getRewardList(circle_id, page, 10);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
// EventBus.getDefault().post(new BannerRefreshEvent());
|
||||
page = 1;
|
||||
MvpPre.getRewardList(circle_id, page, 10);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mBinding.rvComment.setLayoutManager(new LinearLayoutManager(getActivity()));
|
||||
adapter = new BaseQuickAdapter<RewardUserBean, BaseViewHolder>(R.layout.item_dialog_reward, null) {
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, RewardUserBean item) {
|
||||
int position = helper.getLayoutPosition();
|
||||
|
||||
TextView tv_rank = helper.getView(R.id.rank_icon);
|
||||
|
||||
if (position < 3) {
|
||||
|
||||
switch (position) {
|
||||
case 0:
|
||||
|
||||
tv_rank.setBackground(getResources().getDrawable(R.mipmap.rewar_1));
|
||||
break;
|
||||
case 1:
|
||||
tv_rank.setBackground(getResources().getDrawable(R.mipmap.rewar_2));
|
||||
break;
|
||||
case 2:
|
||||
tv_rank.setBackground(getResources().getDrawable(R.mipmap.rewar_3));
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
tv_rank.setText(String.valueOf(position + 1)); // 显示从1开始的序号
|
||||
}
|
||||
|
||||
// 绑定用户信息
|
||||
helper.setText(R.id.tvName, item.getNickname());
|
||||
helper.setText(R.id.tvPic, item.getTotal_price());
|
||||
ImageUtils.loadHeadCC(item.getAvatar(), helper.getView(R.id.ivAvatar));
|
||||
helper.getView(R.id.tvScore).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ChatLauncher.getInstance().launchC2CChat(getActivity(), item.getUser_id());
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
mBinding.rvComment.setAdapter(adapter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.dialog_reward_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRewardList(List<RewardUserBean> rewardUserBeanList) {
|
||||
adapter.addData(rewardUserBeanList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftLabel(List<GiftLabelBean> giftLabelBeans) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGiftList(List<RoonGiftModel> roonGiftModels, int type) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveGift() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wallet(WalletBean walletBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reward_zone() {
|
||||
ToastUtils.showShort("打赏成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomAuctionJoin(RoomAuction.AuctionListBean auctionListBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giftPack(List<GiftPackBean> giftPackBean) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,321 @@
|
||||
package com.xscm.moduleutil.widget.dialog;
|
||||
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentStatePagerAdapter;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.hjq.toast.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.adapter.GiftTwoDetailsFragment;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftLabelBean;
|
||||
import com.xscm.moduleutil.bean.GiftNumBean;
|
||||
import com.xscm.moduleutil.bean.GiftPackBean;
|
||||
import com.xscm.moduleutil.bean.RewardUserBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.room.RoomAuction;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.databinding.FragmentRewardGiftDialogBinding;
|
||||
import com.xscm.moduleutil.dialog.RechargeDialogFragment;
|
||||
import com.xscm.moduleutil.event.GiftRewardEvent;
|
||||
import com.xscm.moduleutil.presenter.RewardGiftContacts;
|
||||
import com.xscm.moduleutil.presenter.RewardGiftPresenter;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
import com.xscm.moduleutil.widget.GifAvatarOvalView;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/5/29
|
||||
* @description: 打赏礼物的fragment
|
||||
*/
|
||||
public class RewardGiftDialogFragment extends BaseMvpDialogFragment<RewardGiftPresenter, FragmentRewardGiftDialogBinding> implements RewardGiftContacts.View {
|
||||
|
||||
private BaseQuickAdapter<RewardUserBean, BaseViewHolder> adapter;
|
||||
private SelectGiftNumPopupWindow mSelectGiftNumPopupWindow;
|
||||
private KeyboardPopupWindow mKeyboardPopupWindow;
|
||||
private List<GiftNumBean> mGiftNumList;
|
||||
private String circle_id;
|
||||
private RoonGiftModel roonGiftModel = null;
|
||||
private List<Fragment> fragmentList = new ArrayList<>();
|
||||
private String user_id;
|
||||
private String giftNumber = "";
|
||||
private int point;
|
||||
@Override
|
||||
protected RewardGiftPresenter bindPresenter() {
|
||||
return new RewardGiftPresenter(this, getActivity());
|
||||
}
|
||||
public static void show(String id,String userId,int point, FragmentManager fragmentManager) {
|
||||
RewardGiftDialogFragment dialogFragment = new RewardGiftDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("circle_id", id); // 可选:传递参数
|
||||
args.putString("user_id", userId);
|
||||
args.putInt("point",point);
|
||||
// 设置参数...
|
||||
dialogFragment.setArguments(args);
|
||||
dialogFragment.show(fragmentManager, "RewardGiftDialogFragment");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
circle_id=getArguments().getString("circle_id");
|
||||
user_id=getArguments().getString("user_id");
|
||||
point=getArguments().getInt("point");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getRewardList(circle_id, 1, 10);
|
||||
MvpPre.getGiftLabel("1");
|
||||
MvpPre.wallet();
|
||||
mGiftNumList=new ArrayList<>();
|
||||
mGiftNumList.add(new GiftNumBean("20", "x20"));
|
||||
mGiftNumList.add(new GiftNumBean("15", "x15"));
|
||||
mGiftNumList.add(new GiftNumBean("10", "x10"));
|
||||
mGiftNumList.add(new GiftNumBean("5", "x5"));
|
||||
mGiftNumList.add(new GiftNumBean("1", "x1"));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
adapter = new BaseQuickAdapter<RewardUserBean, BaseViewHolder>(com.xscm.moduleutil.R.layout.item_reward1, null) {
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, RewardUserBean item) {
|
||||
GifAvatarOvalView gifAvatarOvalView = helper.getView(com.xscm.moduleutil.R.id.im_reward1);
|
||||
if (item!=null ) {
|
||||
ImageUtils.loadHeadCC(item.getAvatar(), helper.getView(com.xscm.moduleutil.R.id.im_reward1));
|
||||
}
|
||||
}
|
||||
};
|
||||
mBinding.recycleView.setAdapter(adapter);
|
||||
mBinding.tvGiveCoinNum.setOnClickListener(this::onClisk);
|
||||
mBinding.tvRewardNum.setOnClickListener(this::onClisk);
|
||||
mBinding.cz.setOnClickListener(this::onClisk);
|
||||
mBinding.tvGive.setOnClickListener(this::onClisk);
|
||||
|
||||
float[] corners = {0f, 65f, 65f, 0f};
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground( mBinding.tvGive, ColorManager.getInstance().getPrimaryColorInt(), corners);
|
||||
mBinding.tvGive.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
mBinding.cz.setTextColor(ColorManager.getInstance().getPrimaryColorInt());
|
||||
}
|
||||
|
||||
private void onClisk(View view1) {
|
||||
if (view1.getId()==R.id.tv_give_coin_num){
|
||||
if (mSelectGiftNumPopupWindow == null) {
|
||||
|
||||
mSelectGiftNumPopupWindow = new SelectGiftNumPopupWindow(getSelfActivity(), (adapter, view, position) -> {
|
||||
GiftNumBean giftNumBean = (GiftNumBean) adapter.getItem(position);
|
||||
if ("0".equals(giftNumBean.getNumber())) {//自定义
|
||||
mKeyboardPopupWindow = new KeyboardPopupWindow(getSelfActivity(), getView());
|
||||
mKeyboardPopupWindow.refreshKeyboardOutSideTouchable(false);//false开启键盘 ,true关闭键盘
|
||||
mKeyboardPopupWindow.addRoomPasswordListener(new KeyboardPopupWindow.KeyboardCompleteListener() {//监听自定键盘的完成
|
||||
@Override
|
||||
public void inputComplete(String inputContent) {
|
||||
mBinding.tvGiveCoinNum.setText(inputContent);
|
||||
mKeyboardPopupWindow.releaseResources();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
mBinding.tvGiveCoinNum.setText(giftNumBean.getNumber());
|
||||
}
|
||||
mSelectGiftNumPopupWindow.dismiss();
|
||||
});
|
||||
}
|
||||
mSelectGiftNumPopupWindow.setData(mGiftNumList);
|
||||
mSelectGiftNumPopupWindow.showAtLocation(mBinding.tvGiveCoinNum, Gravity.BOTTOM | Gravity.RIGHT, 100, 230);
|
||||
|
||||
}else if (view1.getId()== com.xscm.moduleutil.R.id.tv_reward_num){
|
||||
RewardDialogFragment.show(circle_id,getChildFragmentManager());
|
||||
}else if (view1.getId()== R.id.cz){
|
||||
RechargeDialogFragment.show("",null, getActivity().getSupportFragmentManager());
|
||||
}else if (view1.getId()== R.id.tv_give){
|
||||
for (int i=0;i<mGiftNumList.size();i++) {
|
||||
if (mBinding.tvGiveCoinNum.getText().toString().equals(mGiftNumList.get(i).getText())) {
|
||||
giftNumber = mGiftNumList.get(i).getNumber();
|
||||
}
|
||||
}
|
||||
giveGift(giftNumber);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fragment_reward_gift_dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getRewardList(List<RewardUserBean> rewardUserBeanList) {
|
||||
if (rewardUserBeanList != null && !rewardUserBeanList.isEmpty()) {
|
||||
mBinding.recycleView.setVisibility(View.VISIBLE);
|
||||
mBinding.tvRewardNum.setVisibility(View.VISIBLE);
|
||||
mBinding.tvRewardTitle.setVisibility(View.INVISIBLE);
|
||||
mBinding.tvRewardNum.setText("已有" + String.valueOf(rewardUserBeanList.size()) + "个人打赏");
|
||||
int limit = Math.min(rewardUserBeanList.size(), 5);
|
||||
List<RewardUserBean> limitedList = rewardUserBeanList.subList(0, limit);
|
||||
adapter.setNewData(limitedList);
|
||||
} else {
|
||||
adapter.setNewData(null);
|
||||
mBinding.recycleView.setVisibility(View.INVISIBLE);
|
||||
mBinding.tvRewardNum.setVisibility(View.INVISIBLE);
|
||||
mBinding.tvRewardTitle.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftLabel(List<GiftLabelBean> giftLabelBeans) {
|
||||
mBinding.viewPager.setAdapter(new MyFragmentPagerAdapter(getChildFragmentManager(), giftLabelBeans,fragmentList));
|
||||
mBinding.slidingTabLayout.setViewPager(mBinding.viewPager);
|
||||
mBinding.slidingTabLayout.setCurrentTab(0);
|
||||
}
|
||||
private int getSelectedGift() {
|
||||
int currentItem = mBinding.viewPager.getCurrentItem();
|
||||
// if (currentItem < 1) { //比2小是才是礼物
|
||||
GiftTwoDetailsFragment fragment = (GiftTwoDetailsFragment) fragmentList.get(currentItem);
|
||||
roonGiftModel = fragment.getGiftList();
|
||||
// }
|
||||
// else {
|
||||
// GiftFragment fragment = (GiftFragment) fragmentList.get(currentItem);
|
||||
// giftModel = fragment.getmData();
|
||||
// }
|
||||
return currentItem;
|
||||
}
|
||||
|
||||
private void giveGift(String num) {
|
||||
getSelectedGift();
|
||||
int currentItem = mBinding.viewPager.getCurrentItem();
|
||||
String userId = user_id;
|
||||
if (currentItem < 1) {
|
||||
if (roonGiftModel == null) {
|
||||
ToastUtils.show("请选择礼物");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (TextUtils.isEmpty(num)) {
|
||||
ToastUtils.show("请选择打赏礼物数量");
|
||||
return;
|
||||
}
|
||||
if (Integer.valueOf(num) <= 0) {
|
||||
ToastUtils.show("请选择打赏礼物数量");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (roonGiftModel == null) {
|
||||
ToastUtils.show("请选择礼物");
|
||||
return;
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(num)) {
|
||||
ToastUtils.show("请选择打赏礼物数量");
|
||||
return;
|
||||
}
|
||||
if (Integer.valueOf(num) <= 0) {
|
||||
ToastUtils.show("请选择打赏礼物数量");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentItem == 0) {
|
||||
//礼物打赏
|
||||
giftNumber = num;
|
||||
MvpPre.reward_zone(circle_id, roonGiftModel.getGift_id(), num, "1");
|
||||
} else {
|
||||
//背包礼物打赏
|
||||
// giftNumber = num;
|
||||
// roomGiftGiveEvent = new RoomGiftGiveEvent(userId, roomId, pit, num, 1, giftModel, null);
|
||||
//
|
||||
// MvpPre.giveBackGift(userId, giftModel.getGift_id(), roomId, pit, num, giftModel, 1);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void setGiftList(List<RoonGiftModel> roonGiftModels,int type) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveGift() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wallet(WalletBean walletBean) {
|
||||
mBinding.tvRewardGift.setText(walletBean.getCoin());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reward_zone() {
|
||||
com.blankj.utilcode.util.ToastUtils.showShort("打赏成功");
|
||||
EventBus.getDefault().post(new GiftRewardEvent(point));
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void roomAuctionJoin(RoomAuction.AuctionListBean auctionListBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giftPack(List<GiftPackBean> giftPackBean) {
|
||||
|
||||
}
|
||||
|
||||
private static class MyFragmentPagerAdapter extends FragmentStatePagerAdapter {
|
||||
|
||||
private List<GiftLabelBean> list;
|
||||
private List<Fragment> fragmentList ;
|
||||
|
||||
public MyFragmentPagerAdapter(FragmentManager fm, List<GiftLabelBean> list,List<Fragment> fragmentList) {
|
||||
super(fm);
|
||||
this.list = list;
|
||||
this.fragmentList = fragmentList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(int position) {
|
||||
GiftLabelBean model = list.get(position);
|
||||
Fragment fragment = GiftTwoDetailsFragment.newInstance(model.getId(), 2);
|
||||
fragmentList.add(fragment); // 保存 Fragment 实例
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CharSequence getPageTitle(int position) {
|
||||
GiftLabelBean model = list.get(position);
|
||||
return model.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.xscm.moduleutil.widget.dialog;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.GiftNumBean;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/30
|
||||
*@description: 展示礼物打赏数量的适配器
|
||||
*/
|
||||
public class SelectGiftNumAdapter extends BaseQuickAdapter<GiftNumBean, BaseViewHolder> {
|
||||
|
||||
public SelectGiftNumAdapter() {
|
||||
super(R.layout.room_rv_item_gift_num_windows);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, GiftNumBean item) {
|
||||
// helper.setText(R.id.tv_gift_mum, item.getNumber())
|
||||
helper.setText(R.id.tv_gift_name, item.getText());
|
||||
if ("0".equals(item.getNumber())) {
|
||||
// helper.setText(R.id.tv_custom, item.getText());
|
||||
// helper.setVisible(R.id.tv_custom,true);
|
||||
// helper.setVisible(R.id.tv_gift_mum, false).
|
||||
helper.setVisible(R.id.tv_gift_name, false);
|
||||
}else {
|
||||
// helper.setVisible(R.id.tv_custom,false);
|
||||
// helper.setVisible(R.id.tv_gift_mum, false)
|
||||
helper.setVisible(R.id.tv_gift_name, true);
|
||||
}
|
||||
if("1".equals(item.getNumber())){
|
||||
helper.getView(R.id.iv_split).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.xscm.moduleutil.widget.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.PopupWindow;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.GiftNumBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/5/30
|
||||
*@description: 选择礼物数量窗口
|
||||
*/
|
||||
public class SelectGiftNumPopupWindow extends PopupWindow {
|
||||
private View rootView;
|
||||
private SelectGiftNumAdapter selectGiftNumAdapter;
|
||||
|
||||
public SelectGiftNumPopupWindow(Context context, BaseQuickAdapter.OnItemClickListener onItemClickListener) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
rootView = inflater.inflate(R.layout.room_window_pop_gift, null);
|
||||
RecyclerView recyclerView = rootView.findViewById(R.id.rv_gift_num_window);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
recyclerView.setAdapter(selectGiftNumAdapter = new SelectGiftNumAdapter());
|
||||
|
||||
selectGiftNumAdapter.setOnItemClickListener(onItemClickListener);
|
||||
setContentView(rootView);
|
||||
this.setBackgroundDrawable(new BitmapDrawable());
|
||||
this.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
this.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
this.setFocusable(true);
|
||||
this.setOutsideTouchable(true);
|
||||
this.setTouchable(true);
|
||||
this.setAnimationStyle(R.style.mypopwindow_anim_style);
|
||||
}
|
||||
|
||||
|
||||
public void setData(List<GiftNumBean> data) {
|
||||
if (selectGiftNumAdapter != null) {
|
||||
selectGiftNumAdapter.setNewData(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,217 @@
|
||||
package com.xscm.moduleutil.widget.dialog;
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static com.blankj.utilcode.util.ActivityUtils.startActivity;
|
||||
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.blankj.utilcode.util.ImageUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.activity.WebViewActivity;
|
||||
import com.xscm.moduleutil.bean.CircleListBean;
|
||||
import com.xscm.moduleutil.databinding.RoomDialogShareBinding;
|
||||
import com.xscm.moduleutil.utils.BaseBottomSheetDialog;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.utils.wx.WeChatShareUtils;
|
||||
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
|
||||
|
||||
|
||||
/**
|
||||
* 房间分享弹窗
|
||||
*/
|
||||
public class ShareDialog extends BaseBottomSheetDialog<RoomDialogShareBinding> {
|
||||
public WeChatShareUtils weChatShareUtils;
|
||||
private Context mContext;
|
||||
private String mcontent;
|
||||
private String murl;
|
||||
private String ids;
|
||||
private int types;//1:用户 2:房间;3:动态
|
||||
private String mUserId;
|
||||
private CircleListBean bean;
|
||||
|
||||
public interface OnShareDataListener {
|
||||
void onShareDataLoaded(String id);
|
||||
}
|
||||
|
||||
private OnShareDataListener listener;
|
||||
|
||||
public void setOnShareDataListener(OnShareDataListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
private static final String TAG = "ShareDialog";
|
||||
|
||||
public ShareDialog(Context context, String content, String url, String id, int type,String userId,CircleListBean bean) {
|
||||
super(context);
|
||||
this.mcontent = content;
|
||||
this.murl = url;
|
||||
this.mContext = getContext();
|
||||
this.ids = id;
|
||||
this.types = type;
|
||||
this.mUserId = userId;
|
||||
this.bean = bean;
|
||||
Log.i(TAG, "(Start)启动了===========================ShareDialog");
|
||||
iniv();
|
||||
}
|
||||
|
||||
private void iniv() {
|
||||
if (types == 1) {//1是分享动态
|
||||
|
||||
} else if (types == 2) {//分享相册
|
||||
mBinding.tvQq.setVisibility(GONE);
|
||||
mBinding.tvQqq.setVisibility(GONE);
|
||||
mBinding.rl.setVisibility(GONE);
|
||||
}
|
||||
if (mUserId.equals(SpUtil.getUserId()+"")){
|
||||
mBinding.shanc.setVisibility(VISIBLE);
|
||||
}else {
|
||||
mBinding.shanc.setVisibility(GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayout() {
|
||||
return R.layout.room_dialog_share;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
Window window = getWindow();
|
||||
WindowManager.LayoutParams lp = window.getAttributes();
|
||||
lp.dimAmount = 0.4f;
|
||||
window.setAttributes(lp);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
mBinding.tvQq.setOnClickListener(this::onClick);
|
||||
mBinding.tvWx.setOnClickListener(this::onClick);
|
||||
mBinding.tvWxq.setOnClickListener(this::onClick);
|
||||
mBinding.tvQqq.setOnClickListener(this::onClick);
|
||||
mBinding.tvClean.setOnClickListener(this::onClick);
|
||||
mBinding.tvCopy.setOnClickListener(this::onClick);
|
||||
mBinding.tvJub.setOnClickListener(this::onClick);
|
||||
mBinding.shanc.setOnClickListener(this::onClick);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
weChatShareUtils = WeChatShareUtils.getInstance(getContext());
|
||||
// if (mUserId.equals(SpUtil.getUserId()+"")){
|
||||
// mBinding.shanc.setVisibility(GONE);
|
||||
// }else {
|
||||
// mBinding.shanc.setVisibility(VISIBLE);
|
||||
// }
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
// String appName = CommonAppContext.getInstance().getResources().getString(R.string.app_name);
|
||||
|
||||
|
||||
if (R.id.tv_qq == id) {
|
||||
// AppLogUtil.reportAppLog(AppLogEvent.D0108, "share_way", "QQ分享");
|
||||
// ShareUtil.shareWeb((Activity) view.getContext(), URLConstants.SHARE, String.format("我在%s玩呢,大家都在玩,快来展示您的精彩", appName)
|
||||
// , appName, "", R.mipmap.ic_launcher_new, SHARE_MEDIA.QQ);
|
||||
} else if (R.id.tv_wx == id) {
|
||||
// AppLogUtil.reportAppLog(AppLogEvent.D0108, "share_way", "微信分享");
|
||||
// ShareUtil.shareWeb((Activity) view.getContext(), URLConstants.SHARE, String.format("我在%s玩呢,大家都在玩,快来展示您的精彩", appName)
|
||||
// , appName, "", R.mipmap.ic_launcher_new, SHARE_MEDIA.WEIXIN);
|
||||
fun_handleShare(SendMessageToWX.Req.WXSceneSession);
|
||||
} else if (R.id.tv_wxq == id) {
|
||||
fun_handleShare1(SendMessageToWX.Req.WXSceneTimeline);
|
||||
} else if (R.id.tv_qqq == id) {
|
||||
|
||||
} else if (R.id.shanc == id) {
|
||||
if (listener != null) {
|
||||
listener.onShareDataLoaded(ids);
|
||||
}
|
||||
} else if (R.id.tv_jub == id) {
|
||||
if (types == 3) {
|
||||
Intent intent = new Intent(getContext(), WebViewActivity.class);
|
||||
intent.putExtra("url", "https://vespa.qxmier.com/web/index.html#/pages/feedback/report?id=" + SpUtil.getToken() + "&fromType=" + types + "&fromId=" + bean.getId());
|
||||
intent.putExtra("title", "举报");
|
||||
startActivity(intent);
|
||||
}else if (types == 1){
|
||||
Intent intent = new Intent(getContext(), WebViewActivity.class);
|
||||
intent.putExtra("url", "https://vespa.qxmier.com/web/index.html#/pages/feedback/report?id=" + SpUtil.getToken() + "&fromType=" + types + "&fromId=" + bean.getUser_id());
|
||||
intent.putExtra("title", "举报");
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
} else if (R.id.tv_copy == id) {
|
||||
ClipboardManager clipboard = (ClipboardManager)mContext.getSystemService( Context.CLIPBOARD_SERVICE);
|
||||
ClipData clip = ClipData.newPlainText("链接",bean.getShare_url() );
|
||||
if (clipboard != null) {
|
||||
clipboard.setPrimaryClip(clip);
|
||||
com.hjq.toast.ToastUtils.show("复制成功");
|
||||
} else {
|
||||
com.hjq.toast.ToastUtils.show("复制失败");
|
||||
}
|
||||
}
|
||||
|
||||
dismiss();
|
||||
}
|
||||
|
||||
// todo fun_handleShare 分享小程序类型 (只支持分享给微信好友)
|
||||
private void fun_handleShare(int scene) {
|
||||
if (weChatShareUtils.isSupportWX()) {
|
||||
String appName = mContext.getPackageManager().getApplicationLabel(mContext.getApplicationInfo()).toString();
|
||||
if (types == 2){
|
||||
com.xscm.moduleutil.utils.ImageUtils.loadBitmap(murl, new com.xscm.moduleutil.utils.ImageUtils.onLoadBitmap() {
|
||||
@Override
|
||||
public void onReady(Bitmap resource) {
|
||||
weChatShareUtils.sharePic(resource, scene);
|
||||
}
|
||||
});
|
||||
}else {
|
||||
String shortContent = mcontent.length() > 20 ? mcontent.substring(0, 20) : mcontent;
|
||||
String desc = shortContent;
|
||||
String title = appName;
|
||||
String url = murl;
|
||||
Bitmap bitmap = ImageUtils.drawable2Bitmap(mContext.getResources().getDrawable(R.mipmap.ic_launcher));
|
||||
weChatShareUtils.shareUrl(url, title, bitmap, desc, scene);
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showShort("手机上微信版本不支持分享功能");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void fun_handleShare1(int scene) {
|
||||
if (weChatShareUtils.isSupportWX()) {
|
||||
String appName = mContext.getPackageManager().getApplicationLabel(mContext.getApplicationInfo()).toString();
|
||||
if (types == 2) {
|
||||
com.xscm.moduleutil.utils.ImageUtils.loadBitmap(murl, new com.xscm.moduleutil.utils.ImageUtils.onLoadBitmap() {
|
||||
@Override
|
||||
public void onReady(Bitmap resource) {
|
||||
weChatShareUtils.sharePic(resource, scene);
|
||||
}
|
||||
});
|
||||
}else {
|
||||
String shortContent = mcontent.length() > 20 ? mcontent.substring(0, 20) : mcontent;
|
||||
String desc = shortContent;
|
||||
String title = appName;
|
||||
String url = murl;
|
||||
// Bitmap bitmap = BitmapFactory.decodeResource(mContext.getResources(),R.mipmap.ic_launcher);
|
||||
Bitmap bitmap = ImageUtils.drawable2Bitmap(mContext.getResources().getDrawable(R.mipmap.ic_launcher));
|
||||
weChatShareUtils.shareUrl(url, title, bitmap, desc, scene);
|
||||
}
|
||||
} else {
|
||||
ToastUtils.showShort("手机上微信版本不支持分享功能");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user