Files
yusheng-android/MainModule/src/main/java/com/xscm/modulemain/dialog/UserGiftWallRoomFragment.java

142 lines
5.2 KiB
Java
Raw Normal View History

2025-10-28 16:56:13 +08:00
package com.xscm.modulemain.dialog;
2025-10-20 10:16:44 +08:00
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import androidx.recyclerview.widget.GridLayoutManager;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
2025-10-28 16:56:13 +08:00
import com.xscm.modulemain.R;
import com.xscm.modulemain.activity.room.contacts.UserGiftWallConacts;
import com.xscm.modulemain.databinding.MeFagmentUserGiftWallBinding;
import com.xscm.modulemain.activity.room.presenter.UserGiftWallPresenter;
2025-10-20 10:16:44 +08:00
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
import com.xscm.moduleutil.bean.GiftUserWallBean;
import com.xscm.moduleutil.utils.ImageUtils;
import java.util.ArrayList;
import java.util.List;
/**
* 礼物墙
*/
public class UserGiftWallRoomFragment extends BaseMvpDialogFragment<UserGiftWallPresenter, MeFagmentUserGiftWallBinding> implements UserGiftWallConacts.View {
private int userId;
private BaseQuickAdapter<GiftUserWallBean.GiftWallBean, BaseViewHolder> mAdapter;
// TODO: Customize parameter initialization
@SuppressWarnings("unused")
public static UserGiftWallRoomFragment newInstance(int userId) {
UserGiftWallRoomFragment fragment = new UserGiftWallRoomFragment();
Bundle args = new Bundle();
args.putInt("userId", userId);
fragment.setArguments(args);
return fragment;
}
@Override
public void initArgs(Bundle arguments) {
super.initArgs(arguments);
userId = arguments.getInt("userId");
}
// 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 void initView() {
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 4);
mBinding.recyclerView.setLayoutManager(gridLayoutManager);
mAdapter = new BaseQuickAdapter<GiftUserWallBean.GiftWallBean, BaseViewHolder>(R.layout.me_item_user_gift_wall, null) {
@Override
protected void convert(BaseViewHolder helper, GiftUserWallBean.GiftWallBean item) {
helper.setText(R.id.tv_gift_name, item.getGift_name());
if (item.getBase_image() == null || item.getBase_image().isEmpty()) {
helper.setImageResource(R.id.image, com.xscm.moduleutil.R.mipmap.default_avatar);
} else {
ImageUtils.loadImageView(item.getBase_image(), helper.getView(R.id.image));
}
if (item.getBase_image() == null || item.getBase_image().isEmpty()) {
helper.setImageResource(R.id.iv_gift_pic, com.xscm.moduleutil.R.mipmap.default_avatar);
} else {
ImageUtils.loadImageView(item.getBase_image(), helper.getView(R.id.iv_gift_pic));
}
// helper.setText(R.id.tv_price, item.getGiftPrice());
helper.setText(R.id.tv_price33, item.getGift_price());
helper.setText(R.id.tv_gift_values, "x" + item.getTotal_count());
// if (item.getIs_show()==0){
// helper.getView(R.id.cl_gift_item).setAlpha(0.2f);
// }else {
// helper.getView(R.id.cl_gift_item).setAlpha(1f);
// }
if (item.getTop_users() != null && item.getTop_users().size() > 0) {
helper.getView(R.id.cl_gift_item).setBackgroundResource(com.xscm.moduleutil.R.mipmap.liang);
} else {
helper.getView(R.id.cl_gift_item).setBackgroundResource(com.xscm.moduleutil.R.mipmap.not_liang);
}
}
};
mBinding.recyclerView.setAdapter(mAdapter);
mAdapter.bindToRecyclerView(mBinding.recyclerView);
}
@Override
protected UserGiftWallPresenter bindPresenter() {
return new UserGiftWallPresenter(this, getContext());
}
@Override
protected void initData() {
MvpPre.giftWall(userId + "");
}
@Override
protected int getLayoutId() {
return R.layout.me_fagment_user_gift_wall;
}
@Override
public void setGiftWall(GiftUserWallBean data) {
// if (data != null && data.size() > 0) {
// if (homePageInfoActivity != null) {
// homePageInfoActivity.setTab(2);
// }
// mUserGiftWallAdapter.setNewData(data);
List<GiftUserWallBean.GiftWallBean> giftWallBeans = new ArrayList<>();
giftWallBeans.addAll(data.getLiang());
giftWallBeans.addAll(data.getNo_liang());
mBinding.slGiftWall.setVisibility(View.VISIBLE);
mAdapter.setNewData(giftWallBeans);
}
}