238 lines
8.0 KiB
Java
238 lines
8.0 KiB
Java
package com.xscm.modulemain.dialog;
|
|
|
|
import android.content.DialogInterface;
|
|
import android.os.Bundle;
|
|
import android.os.Handler;
|
|
import android.text.Editable;
|
|
import android.text.TextWatcher;
|
|
import android.view.Gravity;
|
|
import android.view.View;
|
|
import android.view.Window;
|
|
import android.view.WindowManager;
|
|
import android.widget.ImageView;
|
|
import android.widget.LinearLayout;
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
import com.blankj.utilcode.util.StringUtils;
|
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
import com.chad.library.adapter.base.BaseViewHolder;
|
|
import com.xscm.modulemain.R;
|
|
import com.xscm.modulemain.activity.room.contacts.RoomHostContacts;
|
|
import com.xscm.modulemain.databinding.RoomHostAddFragmentBinding;
|
|
import com.xscm.modulemain.activity.room.presenter.RoomHostPresenter;
|
|
import com.hjq.toast.ToastUtils;
|
|
import com.lihang.ShadowLayout;
|
|
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
|
import com.xscm.moduleutil.bean.HostBean;
|
|
import com.xscm.moduleutil.bean.RefreshEvent;
|
|
import com.xscm.moduleutil.bean.RoomSearchResp;
|
|
import com.xscm.moduleutil.utils.ImageUtils;
|
|
|
|
import org.greenrobot.eventbus.EventBus;
|
|
|
|
import java.util.List;
|
|
/**
|
|
*@author qx
|
|
*@data 2025/6/21
|
|
*@description: 设置主持人
|
|
*/
|
|
public class RoomHostAddFragment extends BaseMvpDialogFragment<RoomHostPresenter, RoomHostAddFragmentBinding> implements RoomHostContacts.View {
|
|
private String mRoomId ;
|
|
private BaseQuickAdapter<RoomSearchResp, BaseViewHolder> mAdapter;
|
|
|
|
// TODO: Customize parameter initialization
|
|
@SuppressWarnings("unused")
|
|
public static RoomHostAddFragment newInstance(String roomId) {
|
|
RoomHostAddFragment fragment = new RoomHostAddFragment();
|
|
Bundle args = new Bundle();
|
|
args.putString("roomId", roomId);
|
|
fragment.setArguments(args);
|
|
return fragment;
|
|
}
|
|
@Override
|
|
public void initArgs(Bundle arguments) {
|
|
super.initArgs(arguments);
|
|
mRoomId = arguments.getString("roomId");
|
|
}
|
|
// TODO: 2025/3/7 固定dialog显示的位置和大小
|
|
@Override
|
|
protected void initDialogStyle(Window window) {
|
|
super.initDialogStyle(window);
|
|
window.setGravity(Gravity.BOTTOM);
|
|
WindowManager.LayoutParams lp = window.getAttributes();
|
|
lp.dimAmount = 0.4f;
|
|
// 固定对话框的宽度和高度
|
|
lp.width = WindowManager.LayoutParams.MATCH_PARENT; // 宽度设置为屏幕宽度
|
|
lp.height = WindowManager.LayoutParams.WRAP_CONTENT; // 高度设置为内容高度
|
|
|
|
window.setAttributes(lp);
|
|
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
|
}
|
|
|
|
@Override
|
|
protected RoomHostPresenter bindPresenter() {
|
|
return new RoomHostPresenter(this, getContext());
|
|
}
|
|
|
|
|
|
@Override
|
|
protected void initData() {
|
|
|
|
mBinding.editQuery.addTextChangedListener(new TextWatcher() {
|
|
private Handler handler = new Handler();
|
|
private final long DELAY = 1500; // 1秒延迟
|
|
|
|
@Override
|
|
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
|
|
handler.removeCallbacksAndMessages(null);
|
|
}
|
|
|
|
@Override
|
|
public void afterTextChanged(Editable editable) {
|
|
handler.postDelayed(new Runnable() {
|
|
@Override
|
|
public void run() {
|
|
String keyWord = editable.toString();
|
|
if (!StringUtils.isEmpty(keyWord)) {
|
|
MvpPre.setUserHostList(keyWord,"1");
|
|
}
|
|
}
|
|
}, DELAY);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override
|
|
protected void initView() {
|
|
mBinding.rvHostAdd.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
mAdapter = new BaseQuickAdapter<RoomSearchResp, BaseViewHolder>(R.layout.room_host_add_item, null) {
|
|
@Override
|
|
protected void convert(BaseViewHolder helper, RoomSearchResp item) {
|
|
helper.setText(R.id.tv_name, item.getName());
|
|
ImageUtils.loadHeadCC(item.getPicture(), helper.getView(R.id.image));
|
|
helper.setText(R.id.tv_id, item.getCode());
|
|
// if (item.getSex().equals("1")){
|
|
// helper.setBackgroundRes(R.id.tv_gender, com.qxcm.moduleutil.R.mipmap.boyb);
|
|
// }else {
|
|
// helper.setBackgroundRes(R.id.tv_gender, com.qxcm.moduleutil.R.mipmap.girl);
|
|
// }
|
|
// helper.setText(R.id.tv_gender, item.getAge()+"");
|
|
// ImageUtils.loadImageView(item.getLevel_icon(), helper.getView(R.id.iv_rd));
|
|
LinearLayout llContainer = helper.getView(R.id.ll);
|
|
llContainer.removeAllViews(); // 清空旧的 ImageView
|
|
if (!item.getIcon().isEmpty()||item.getIcon().size()>0){
|
|
for (String url : item.getIcon()) {
|
|
if (url.contains("http")) {
|
|
ImageView imageView = new ImageView(getContext());
|
|
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
|
|
getContext().getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_57),
|
|
getContext().getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_15)
|
|
);
|
|
params.setMargins(0, 0, getContext().getResources().getDimensionPixelSize(com.xscm.moduleutil.R.dimen.dp_5), 0); // 右边距
|
|
imageView.setLayoutParams(params);
|
|
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
|
|
|
// 使用 Glide 加载图片
|
|
ImageUtils.loadHeadCC(url, imageView);
|
|
|
|
llContainer.addView(imageView);
|
|
}
|
|
}
|
|
}
|
|
ShadowLayout layout = helper.getView(R.id.shadow_layout);
|
|
// layout.setShadowColor(R.color.picture_color_fa632d);
|
|
layout.setShadowHiddenBottom(false);
|
|
layout.setShadowHidden(false);
|
|
layout.setShadowOffsetY(1);
|
|
layout.setShadowOffsetX(1);
|
|
|
|
|
|
|
|
helper.getView(R.id.iv_add).setOnClickListener(new View.OnClickListener() {
|
|
@Override
|
|
public void onClick(View v) {
|
|
// TODO: 2025/3/17 添加主持人
|
|
MvpPre.postHostAdd(mRoomId, item.getId(), "1", "1");
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
mBinding.rvHostAdd.setAdapter(mAdapter);
|
|
mAdapter.bindToRecyclerView(mBinding.rvHostAdd);
|
|
|
|
|
|
}
|
|
|
|
@Override
|
|
protected int getLayoutId() {
|
|
return R.layout.room_host_add_fragment;
|
|
}
|
|
|
|
|
|
@Override
|
|
public void setHostrList(List<HostBean> list) {
|
|
// mAdapter.setNewData(list);
|
|
}
|
|
|
|
@Override
|
|
public void getUserHostList(List<RoomSearchResp> list) {
|
|
mAdapter.setNewData(list);
|
|
}
|
|
|
|
@Override
|
|
public void postHostAdd(String s, String type, String is_add) {
|
|
ToastUtils.show("添加成功");
|
|
}
|
|
|
|
// @Override
|
|
// public void getUserHostList(List<RoomHostUserBean> list) {
|
|
// mAdapter.setNewData(list);
|
|
// }
|
|
|
|
// @Override
|
|
// public void postHostAdd(String s) {
|
|
// Logger.d("@@@@",s);
|
|
// ToastUtils.showShort("添加成功");
|
|
//
|
|
// }
|
|
|
|
// @Override
|
|
// public void setHostrList(List<HostBean> list) {
|
|
//
|
|
// }
|
|
|
|
@Override
|
|
public void postPresidedRatio(String s) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void postPresidedDel(String s) {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void doDismiss() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void onDismiss(@NonNull DialogInterface dialog) {
|
|
super.onDismiss(dialog);
|
|
EventBus.getDefault().post(new RefreshEvent(mRoomId)); // 发送刷新事件
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} |