2025-10-28 16:56:13 +08:00
|
|
|
|
package com.xscm.modulemain.dialog;
|
2025-10-20 10:16:44 +08:00
|
|
|
|
|
|
|
|
|
|
import static android.view.View.GONE;
|
|
|
|
|
|
import static android.view.View.VISIBLE;
|
|
|
|
|
|
|
|
|
|
|
|
import android.os.Bundle;
|
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
import android.util.Log;
|
|
|
|
|
|
import android.view.Gravity;
|
|
|
|
|
|
import android.view.View;
|
|
|
|
|
|
import android.view.Window;
|
|
|
|
|
|
import android.view.WindowManager;
|
|
|
|
|
|
|
|
|
|
|
|
import androidx.fragment.app.FragmentManager;
|
|
|
|
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
|
|
|
|
|
|
|
|
import com.blankj.utilcode.util.ToastUtils;
|
2025-10-28 16:56:13 +08:00
|
|
|
|
import com.xscm.modulemain.R;
|
|
|
|
|
|
import com.xscm.modulemain.activity.room.contacts.WheatContacts;
|
|
|
|
|
|
import com.xscm.modulemain.activity.room.presenter.WheatPresenter;
|
|
|
|
|
|
import com.xscm.modulemain.adapter.WheatFeedingSelectAdapter;
|
|
|
|
|
|
import com.xscm.modulemain.databinding.FragmentWheatFeedingDialogBinding;
|
2025-10-20 10:16:44 +08:00
|
|
|
|
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
|
|
|
|
|
import com.xscm.moduleutil.bean.RoomWheatEvent;
|
|
|
|
|
|
import com.xscm.moduleutil.bean.room.RoomApplyListBean;
|
|
|
|
|
|
import com.xscm.moduleutil.bean.room.RoomInfoResp;
|
|
|
|
|
|
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
|
|
|
|
|
import com.xscm.moduleutil.utils.ColorManager;
|
|
|
|
|
|
import com.xscm.moduleutil.utils.ImageUtils;
|
|
|
|
|
|
|
|
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
|
|
import org.greenrobot.eventbus.Subscribe;
|
|
|
|
|
|
import org.greenrobot.eventbus.ThreadMode;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @author qx
|
|
|
|
|
|
* @data 2025/6/10
|
|
|
|
|
|
* @description: 上麦申请dialog弹框,等待申请
|
|
|
|
|
|
*/
|
|
|
|
|
|
public class WheatFeedingDialogFragment extends BaseMvpDialogFragment<WheatPresenter, FragmentWheatFeedingDialogBinding> implements
|
|
|
|
|
|
WheatContacts.View {
|
|
|
|
|
|
private int page;
|
|
|
|
|
|
private int displayMode; // 用于决定显示模式的参数
|
|
|
|
|
|
WheatFeedingSelectAdapter mSpecialAdapter;
|
|
|
|
|
|
WheatFeedingSelectAdapter mRegularAdapter;
|
|
|
|
|
|
private String roomId;
|
|
|
|
|
|
private RoomInfoResp roomInfoResp;
|
|
|
|
|
|
private RoomApplyListBean roomApplyListBeans;
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected WheatPresenter bindPresenter() {
|
|
|
|
|
|
return new WheatPresenter(this, getActivity());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void show(String id, int displayMode, RoomInfoResp roomInfoResp, FragmentManager fragmentManager) {
|
|
|
|
|
|
WheatFeedingDialogFragment dialogFragment = new WheatFeedingDialogFragment();
|
|
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
|
|
args.putString("roomId", id); // 可选:传递参数
|
|
|
|
|
|
args.putInt("displayMode", displayMode);
|
|
|
|
|
|
args.putSerializable("roomInfoResp", roomInfoResp);
|
|
|
|
|
|
dialogFragment.setArguments(args);
|
|
|
|
|
|
dialogFragment.show(fragmentManager, "WheatFeedingDialogFragment");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void initData() {
|
|
|
|
|
|
// 从 Bundle 中获取 displayMode 参数
|
|
|
|
|
|
displayMode = getArguments().getInt("displayMode", 2); // 默认值为 0
|
|
|
|
|
|
roomInfoResp = (RoomInfoResp) getArguments().getSerializable("roomInfoResp");
|
|
|
|
|
|
// 根据 displayMode 显示不同的控件
|
|
|
|
|
|
updateViewBasedOnDisplayMode();
|
|
|
|
|
|
roomId = getArguments().getString("roomId");
|
|
|
|
|
|
MvpPre.roomApplyListBean(roomId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
|
|
|
|
public void onRoomApplyListEvent(RoomWheatEvent event) {
|
|
|
|
|
|
MvpPre.roomApplyListBean(roomId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void updateViewBasedOnDisplayMode() {
|
|
|
|
|
|
switch (displayMode) {
|
|
|
|
|
|
case 1: // 模式房主或者主持模式
|
|
|
|
|
|
mBinding.tvLjsq.setVisibility(GONE);
|
|
|
|
|
|
mBinding.tvQk.setVisibility(VISIBLE);
|
|
|
|
|
|
mBinding.tvWheatRefuse.setVisibility(VISIBLE);
|
|
|
|
|
|
mBinding.tvWheatAccept.setVisibility(VISIBLE);
|
2025-10-24 17:52:11 +08:00
|
|
|
|
mBinding.tvWheatSq.setVisibility(GONE);
|
2025-10-20 10:16:44 +08:00
|
|
|
|
mBinding.tv3.setVisibility(VISIBLE);
|
|
|
|
|
|
mBinding.tv3.setText("设置");
|
|
|
|
|
|
// ... 设置其他控件的可见性
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2: // 模式 2//观众模式
|
|
|
|
|
|
mBinding.tvQk.setVisibility(GONE);
|
|
|
|
|
|
mBinding.tvWheatRefuse.setVisibility(GONE);
|
|
|
|
|
|
mBinding.tvWheatAccept.setVisibility(GONE);
|
|
|
|
|
|
mBinding.tvWheatSq.setVisibility(GONE);
|
|
|
|
|
|
mBinding.tvLjsq.setVisibility(VISIBLE);
|
|
|
|
|
|
mBinding.tv3.setVisibility(GONE);
|
|
|
|
|
|
break;
|
|
|
|
|
|
// ... 其他模式
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void updateDisplayMode(int newDisplayMode) {
|
|
|
|
|
|
if (newDisplayMode == displayMode) {
|
|
|
|
|
|
return; // 如果新旧模式相同,直接返回
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
displayMode = newDisplayMode;
|
|
|
|
|
|
updateViewBasedOnDisplayMode();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onStart() {
|
|
|
|
|
|
super.onStart();
|
|
|
|
|
|
Window window = getDialog().getWindow();
|
|
|
|
|
|
if (window != null) {
|
|
|
|
|
|
// 设置固定高度为 500dp
|
|
|
|
|
|
int screenHeight = getResources().getDisplayMetrics().heightPixels;
|
|
|
|
|
|
int heightInDp = (int) (screenHeight * 0.6f);
|
|
|
|
|
|
;
|
|
|
|
|
|
// int heightInPx = (int) (heightInDp * getResources().getDisplayMetrics().density);
|
|
|
|
|
|
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, heightInDp);
|
|
|
|
|
|
|
|
|
|
|
|
// 可选:设置动画样式(从底部弹出)
|
|
|
|
|
|
window.setWindowAnimations(com.xscm.moduleutil.R.style.CommonShowDialogBottom);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void initView() {
|
|
|
|
|
|
mBinding.tv3.setOnClickListener(this::onClick);
|
|
|
|
|
|
mBinding.tvWheatAccept.setOnClickListener(this::onClick);
|
|
|
|
|
|
mBinding.tvWheatRefuse.setOnClickListener(this::onClick);
|
|
|
|
|
|
mBinding.tvWheatSq.setOnClickListener(this::onClick);
|
|
|
|
|
|
mBinding.tvLjsq.setOnClickListener(this::onClick);
|
|
|
|
|
|
mBinding.tvQk.setOnClickListener(this::onClick);
|
|
|
|
|
|
|
|
|
|
|
|
mBinding.recycleView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
|
|
|
|
|
|
mBinding.recycleView2.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.HORIZONTAL, false));
|
|
|
|
|
|
|
|
|
|
|
|
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tv3, ColorManager.getInstance().getPrimaryColorInt(), 65);
|
|
|
|
|
|
mBinding.tv3.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
|
|
|
|
|
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvQk, ColorManager.getInstance().getPrimaryColorInt(), 65);
|
|
|
|
|
|
mBinding.tvQk.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
|
|
|
|
|
|
|
|
|
|
|
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvWheatAccept, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
|
|
|
|
|
mBinding.tvWheatAccept.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onDestroy() {
|
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
|
if (EventBus.getDefault().isRegistered(this)) {
|
|
|
|
|
|
EventBus.getDefault().unregister(this);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void onClick(View view) {
|
|
|
|
|
|
int id = view.getId();
|
|
|
|
|
|
if (id == R.id.tv_3) {
|
|
|
|
|
|
if (mBinding.tv3.getText().equals("设置")) {
|
|
|
|
|
|
RoomWheatGiftSettingFragment.show(roomId, getChildFragmentManager());
|
|
|
|
|
|
}
|
|
|
|
|
|
// else {
|
|
|
|
|
|
// if (roomApplyListBeans!=null) {
|
|
|
|
|
|
// MvpPre.roomGift(roomId, roomApplyListBeans.getGift_info().getGift_id(), "1", roomInfoResp.getRoom_info().getPit_list().get(8).getUser_id(), "1", "");
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
} else if (id == R.id.tv_wheat_accept) {
|
|
|
|
|
|
// MvpPre.agreePit(roomId,);
|
|
|
|
|
|
up(1);
|
|
|
|
|
|
} else if (id == R.id.tv_wheat_refuse) {
|
|
|
|
|
|
// MvpPre.refusePit(roomId,);
|
|
|
|
|
|
up(2);
|
|
|
|
|
|
} else if (id == R.id.tv_wheat_sq) {
|
|
|
|
|
|
ToastUtils.showShort("点击了申请");
|
|
|
|
|
|
} else if (id == R.id.tv_ljsq) {
|
|
|
|
|
|
MvpPre.applyPit(roomId, "");
|
|
|
|
|
|
} else if (id == R.id.tv_qk) {
|
|
|
|
|
|
MvpPre.clearApply(roomId);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @param type 1:同意上麦 2:拒绝上麦
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void up(int type) {
|
|
|
|
|
|
List<String> stringList = new ArrayList<>();
|
|
|
|
|
|
List<String> selectedTopics = mSpecialAdapter.getSelectedItems();
|
|
|
|
|
|
List<String> selectedRegular = mRegularAdapter.getSelectedItems();
|
|
|
|
|
|
// 返回结果给调用页面(可使用接口或 onActivityResult 等方式)
|
|
|
|
|
|
Log.d("Selected Topics", selectedTopics.toString());
|
|
|
|
|
|
if (selectedTopics.size() > 0) {
|
|
|
|
|
|
stringList.addAll(selectedTopics);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (selectedRegular.size() > 0) {
|
|
|
|
|
|
stringList.addAll(selectedRegular);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (selectedTopics.size() == 0 && selectedRegular.size() == 0) {
|
|
|
|
|
|
ToastUtils.showShort("未选择需要上麦人员");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
String string = TextUtils.join(",", stringList);
|
|
|
|
|
|
if (type == 1) {
|
|
|
|
|
|
MvpPre.agreePit(roomId, string);
|
|
|
|
|
|
} else if (type == 2) {
|
|
|
|
|
|
MvpPre.refusePit(roomId, string);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected void initDialogStyle(Window window) {
|
|
|
|
|
|
super.initDialogStyle(window);
|
|
|
|
|
|
window.setGravity(Gravity.BOTTOM);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
protected int getLayoutId() {
|
|
|
|
|
|
return R.layout.fragment_wheat_feeding_dialog;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void roomApplyListBean(RoomApplyListBean roomApplyListBeans) {
|
|
|
|
|
|
if (roomApplyListBeans.getSpecial() != null || !roomApplyListBeans.getSpecial().isEmpty()) {
|
|
|
|
|
|
mBinding.tv1.setText("优先通道(" + roomApplyListBeans.getSpecial().size() + "/20)");
|
|
|
|
|
|
mSpecialAdapter = new WheatFeedingSelectAdapter(roomApplyListBeans.getSpecial());
|
|
|
|
|
|
mBinding.recycleView.setAdapter(mSpecialAdapter);
|
|
|
|
|
|
mSpecialAdapter.setOnItemClickListener(new WheatFeedingSelectAdapter.OnItemClickListener() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onTvBmClick(RoomApplyListBean.Special item, int position) {
|
|
|
|
|
|
MvpPre.helpApply(roomId, item.getUser_id());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
if (roomApplyListBeans.getRegular() != null || !roomApplyListBeans.getRegular().isEmpty()) {
|
|
|
|
|
|
mBinding.tv4.setText("普通通道(" + roomApplyListBeans.getRegular().size() + "/20)");
|
|
|
|
|
|
mRegularAdapter = new WheatFeedingSelectAdapter(roomApplyListBeans.getRegular());
|
|
|
|
|
|
mBinding.recycleView2.setAdapter(mRegularAdapter);
|
|
|
|
|
|
mRegularAdapter.setOnItemClickListener(new WheatFeedingSelectAdapter.OnItemClickListener() {
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void onTvBmClick(RoomApplyListBean.Special item, int position) {
|
|
|
|
|
|
MvpPre.helpApply(roomId, item.getUser_id());
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
if (roomApplyListBeans.getGift_info() != null) {
|
|
|
|
|
|
mBinding.tv2.setText("赠" + roomApplyListBeans.getGift_info().getGift_name() + "礼物插队");
|
|
|
|
|
|
ImageUtils.loadHeadCC(roomApplyListBeans.getGift_info().getBase_image(), mBinding.im1);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
this.roomApplyListBeans=roomApplyListBeans;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void clearApply() {
|
|
|
|
|
|
MvpPre.roomApplyListBean(roomId);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void agreePit() {
|
2025-10-24 17:52:11 +08:00
|
|
|
|
// MvpPre.roomApplyListBean(roomId);
|
|
|
|
|
|
dismiss();
|
2025-10-20 10:16:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void applyPit() {
|
2025-10-24 17:52:11 +08:00
|
|
|
|
//
|
|
|
|
|
|
// if (roomApplyListBeans!=null){
|
|
|
|
|
|
// if ((roomApplyListBeans.getSpecial() != null && !roomApplyListBeans.getSpecial().isEmpty())
|
|
|
|
|
|
// ||(roomApplyListBeans.getRegular() != null && !roomApplyListBeans.getRegular().isEmpty())){
|
|
|
|
|
|
// MvpPre.roomApplyListBean(roomId);
|
|
|
|
|
|
// }else {
|
|
|
|
|
|
// dismiss();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }else {
|
|
|
|
|
|
dismiss();
|
|
|
|
|
|
// }
|
2025-10-20 10:16:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
public void giveGift() {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|