1:羽声新版本
This commit is contained in:
@@ -0,0 +1,130 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.view.Choreographer;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.databinding.DialogNewRankingXlhFragmentBinding;
|
||||
import com.xscm.moduleutil.databinding.FframentDataBinding;
|
||||
import com.xscm.moduleutil.dialog.giftLottery.GiftLotteryContacts;
|
||||
import com.xscm.moduleutil.dialog.giftLottery.GiftLotteryPresenter;
|
||||
import com.xscm.moduleutil.dialog.giftLottery.GiftRecordAdapte;
|
||||
import com.xscm.moduleutil.dialog.giftLottery.NewGiftRecordAdapte;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LotteryFragment extends BaseMvpDialogFragment<GiftLotteryPresenter, FframentDataBinding> implements GiftLotteryContacts.View {
|
||||
private int page=1;
|
||||
private String roomId;
|
||||
private int type=-1;
|
||||
private GiftRecordAdapte giftRecordAdapte;
|
||||
|
||||
@Override
|
||||
protected GiftLotteryPresenter bindPresenter() {
|
||||
return new GiftLotteryPresenter(this,getSelfActivity());
|
||||
}
|
||||
public static LotteryFragment newInstance(String giftBagId,int type) {
|
||||
Bundle args = new Bundle();
|
||||
LotteryFragment fragment = new LotteryFragment();
|
||||
args.putString("roomId", giftBagId);
|
||||
args.putInt("type",type);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
roomId = getArguments().getString("roomId");
|
||||
type = getArguments().getInt("type");
|
||||
MvpPre.xlhAllRecord(roomId, "1", "20",type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
MvpPre.xlhAllRecord(roomId, page+"", "20",type);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.xlhAllRecord(roomId, page+"", "20",type);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
giftRecordAdapte=new GiftRecordAdapte();
|
||||
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
||||
mBinding.recyclerView.setAdapter(giftRecordAdapte);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fframent_data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftListSuccess(BlindBoxBean blindBoxBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGiftListSuccess(BlindReslutBean blindReslutBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyRecordSuccess(List<GiftBean> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllRecordSuccess(List<GiftBean> data) {
|
||||
|
||||
if (data != null){
|
||||
if (page==1){
|
||||
giftRecordAdapte.setNewData(data);
|
||||
}else {
|
||||
giftRecordAdapte.addData(data);
|
||||
}
|
||||
}else {
|
||||
if (page == 1) {
|
||||
giftRecordAdapte.setNewData(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wallet(WalletBean walletBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Paint;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.Button;
|
||||
import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.blankj.utilcode.util.ToastUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.adapter.HeavenGiftAdapter;
|
||||
import com.xscm.moduleutil.bean.BaseListData;
|
||||
import com.xscm.moduleutil.bean.FirstChargeGiftBean;
|
||||
import com.xscm.moduleutil.bean.RoonGiftModel;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.databinding.DialogNewPeopleBinding;
|
||||
import com.xscm.moduleutil.http.BaseObserver;
|
||||
import com.xscm.moduleutil.http.RetrofitClient;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
import com.zhpan.bannerview.indicator.DrawableIndicator;
|
||||
import com.zhpan.indicator.base.IIndicator;
|
||||
import com.zhpan.indicator.enums.IndicatorSlideMode;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @data
|
||||
* @description: 新人好礼
|
||||
*/
|
||||
public class NewPeopleDialog extends BaseDialog<DialogNewPeopleBinding> {
|
||||
|
||||
HeavenGiftAdapter heavenGiftAdapter;
|
||||
FirstChargeGiftBean firstChargeGiftBean;
|
||||
private int type;
|
||||
|
||||
public NewPeopleDialog(@NonNull Context context) {
|
||||
super(context, R.style.BaseDialogStyleH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.dialog_new_people;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
setCancelable(false);
|
||||
setCanceledOnTouchOutside(false);
|
||||
Window window = getWindow();
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 375.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
mBinding.ivClose.setOnClickListener(v -> dismiss());
|
||||
|
||||
heavenGiftAdapter = new HeavenGiftAdapter();
|
||||
mBinding.bannerViewPager
|
||||
.setPageMargin(15)
|
||||
.setAutoPlay(false)
|
||||
.setRevealWidth(0, 0)
|
||||
.setIndicatorVisibility(View.VISIBLE)
|
||||
.setIndicatorView(getVectorDrawableIndicator())
|
||||
.setIndicatorSlideMode(IndicatorSlideMode.NORMAL)
|
||||
.setAdapter(heavenGiftAdapter)
|
||||
.create();
|
||||
|
||||
mBinding.rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup radioGroup, int i) {
|
||||
if (firstChargeGiftBean == null || firstChargeGiftBean.getGift_bag().size() == 0) {
|
||||
ToastUtils.showShort("暂无礼包");
|
||||
return;
|
||||
}
|
||||
|
||||
if (i == R.id.btn_0) {
|
||||
List<RoonGiftModel> list = new ArrayList<>();
|
||||
if (firstChargeGiftBean.getGift_bag().size() > 1) {
|
||||
mBinding.tvTitle1.setText(firstChargeGiftBean.getGift_bag().get(0).getTitle1());
|
||||
mBinding.tvTitle2.setText(firstChargeGiftBean.getGift_bag().get(0).getTitle2());
|
||||
mBinding.tvTitle2.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
mBinding.btn0.setText(firstChargeGiftBean.getGift_bag().get(0).getName());
|
||||
list.addAll(firstChargeGiftBean.getGift_bag().get(0).getGift_list());
|
||||
mBinding.bannerViewPager.create(baseListData(list, 4));
|
||||
}
|
||||
type = 1;
|
||||
} else if (i == R.id.btn_1) {
|
||||
List<RoonGiftModel> list = new ArrayList<>();
|
||||
if (firstChargeGiftBean.getGift_bag().size() > 2) {
|
||||
mBinding.tvTitle1.setText(firstChargeGiftBean.getGift_bag().get(1).getTitle1());
|
||||
mBinding.tvTitle2.setText(firstChargeGiftBean.getGift_bag().get(1).getTitle2());
|
||||
mBinding.tvTitle2.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
mBinding.btn1.setText(firstChargeGiftBean.getGift_bag().get(1).getName());
|
||||
list.addAll(firstChargeGiftBean.getGift_bag().get(1).getGift_list());
|
||||
mBinding.bannerViewPager.create(baseListData(list, 4));
|
||||
}
|
||||
type = 2;
|
||||
} else if (i == R.id.btn_2) {
|
||||
List<RoonGiftModel> list = new ArrayList<>();
|
||||
if (firstChargeGiftBean.getGift_bag().size() > 3) {
|
||||
if (firstChargeGiftBean.getGift_bag().get(2) != null) {
|
||||
mBinding.tvTitle1.setText(firstChargeGiftBean.getGift_bag().get(2).getTitle1());
|
||||
mBinding.tvTitle2.setText(firstChargeGiftBean.getGift_bag().get(2).getTitle2());
|
||||
mBinding.tvTitle2.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
|
||||
mBinding.btn2.setText(firstChargeGiftBean.getGift_bag().get(2).getName());
|
||||
list.addAll(firstChargeGiftBean.getGift_bag().get(2).getGift_list());
|
||||
mBinding.bannerViewPager.create(baseListData(list, 4));
|
||||
type = 3;
|
||||
}
|
||||
}
|
||||
} else if (i == R.id.btn_3) {
|
||||
List<RoonGiftModel> list = new ArrayList<>();
|
||||
if (firstChargeGiftBean.getGift_bag().size() >= 4) {
|
||||
mBinding.tvTitle1.setText(firstChargeGiftBean.getGift_bag().get(3).getTitle1());
|
||||
mBinding.tvTitle2.setText(firstChargeGiftBean.getGift_bag().get(3).getTitle2());
|
||||
mBinding.btn3.setText(firstChargeGiftBean.getGift_bag().get(3).getName());
|
||||
mBinding.tvTitle2.setPaintFlags(0); // 清除所有绘制标志
|
||||
list.addAll(firstChargeGiftBean.getGift_bag().get(3).getGift_list());
|
||||
mBinding.bannerViewPager.create(baseListData(list, 4));
|
||||
type = 4;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
mBinding.rg.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.tvInvite.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
// RechargeDialogFragment.show(roomId, getSupportFragmentManager());
|
||||
if (listener != null) {
|
||||
listener.onFirstChargeConfirmed(firstChargeGiftBean, type);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public interface OnFirstChargeListener {
|
||||
void onFirstChargeConfirmed(FirstChargeGiftBean giftBean, int type);
|
||||
|
||||
void onFirstChargeCancelled();
|
||||
}
|
||||
|
||||
private OnFirstChargeListener listener;
|
||||
|
||||
// 设置监听器的方法
|
||||
public void setOnFirstChargeListener(OnFirstChargeListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
RetrofitClient.getInstance().getNewChargeGift(new BaseObserver<FirstChargeGiftBean>() {
|
||||
@Override
|
||||
public void onSubscribe(Disposable d) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(FirstChargeGiftBean firstChargeGiftBean) {
|
||||
if (firstChargeGiftBean != null) {
|
||||
showGift(firstChargeGiftBean);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private List<BaseListData<RoonGiftModel>> baseListData(List<RoonGiftModel> list, int chunkSize) {
|
||||
List<BaseListData<RoonGiftModel>> baseListData = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i += chunkSize) {
|
||||
BaseListData<RoonGiftModel> baseListData1 = new BaseListData<>();
|
||||
baseListData1.setData(list.subList(i, Math.min(i + chunkSize, list.size())));
|
||||
baseListData.add(baseListData1);
|
||||
}
|
||||
return baseListData;
|
||||
}
|
||||
|
||||
private IIndicator getVectorDrawableIndicator() {
|
||||
int dp6 = getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_6);
|
||||
return new DrawableIndicator(getContext())
|
||||
.setIndicatorGap(getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_2_5))
|
||||
.setIndicatorDrawable(com.xscm.moduleutil.R.drawable.banner_indicator_nornal, com.xscm.moduleutil.R.drawable.banner_indicator_focus)
|
||||
.setIndicatorSize(getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_13), dp6, getResources().getDimensionPixelOffset(com.xscm.moduleutil.R.dimen.dp_13), dp6);
|
||||
}
|
||||
|
||||
private Resources getResources() {
|
||||
return getContext().getResources();
|
||||
}
|
||||
|
||||
public void showGift(FirstChargeGiftBean firstChargeGiftBean) {
|
||||
this.firstChargeGiftBean = firstChargeGiftBean;
|
||||
mBinding.rg.check(R.id.btn_0);
|
||||
if (firstChargeGiftBean.getGift_bag() != null && firstChargeGiftBean.getGift_bag().size() > 0) {
|
||||
if (firstChargeGiftBean.getGift_bag().size() >= 0) {
|
||||
type = 1;
|
||||
List<RoonGiftModel> list = new ArrayList<>();
|
||||
mBinding.tvTitle1.setText(firstChargeGiftBean.getGift_bag().get(0).getTitle1());
|
||||
mBinding.tvTitle2.setText(firstChargeGiftBean.getGift_bag().get(0).getTitle2());
|
||||
mBinding.btn0.setText(firstChargeGiftBean.getGift_bag().get(0).getName());
|
||||
list.addAll(firstChargeGiftBean.getGift_bag().get(0).getGift_list());
|
||||
mBinding.bannerViewPager.create(baseListData(list, 4));
|
||||
|
||||
|
||||
mBinding.btn1.setText(firstChargeGiftBean.getGift_bag().get(1).getName());
|
||||
mBinding.btn2.setText(firstChargeGiftBean.getGift_bag().get(2).getName());
|
||||
mBinding.btn3.setText(firstChargeGiftBean.getGift_bag().get(3).getName());
|
||||
|
||||
initGiftBagButtonStatus(firstChargeGiftBean);
|
||||
} else if (firstChargeGiftBean.getGift_bag().size() == 2) {
|
||||
// mBinding.rg.check(R.id.btn_0);
|
||||
// mBinding.btn1.setVisibility(View.VISIBLE);
|
||||
// mBinding.btn2.setVisibility(View.INVISIBLE);
|
||||
} else if (firstChargeGiftBean.getGift_bag().size() == 3) {
|
||||
// mBinding.rg.check(R.id.btn_0);
|
||||
// mBinding.btn1.setVisibility(View.VISIBLE);
|
||||
// mBinding.btn2.setVisibility(View.VISIBLE);
|
||||
}
|
||||
// mBinding.rg.check(R.id.btn_0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isstatus = true;
|
||||
|
||||
private void initGiftBagButtonStatus(FirstChargeGiftBean firstChargeGiftBean) {
|
||||
// 1. 准备按钮列表:顺序与gift_bag中的元素顺序一一对应
|
||||
List<RadioButton> buttonList = Arrays.asList(
|
||||
mBinding.btn0,
|
||||
mBinding.btn1,
|
||||
mBinding.btn2
|
||||
// 未来加按钮:mBinding.btn3, mBinding.btn4...
|
||||
);
|
||||
|
||||
// 2. 空安全检查:先判断核心对象/列表非空
|
||||
if (firstChargeGiftBean != null && firstChargeGiftBean.getGift_bag() != null) {
|
||||
List<FirstChargeGiftBean.GiftBag> giftBagList = firstChargeGiftBean.getGift_bag();
|
||||
|
||||
// 3. 循环处理每个按钮
|
||||
for (int i = 0; i < buttonList.size(); i++) {
|
||||
RadioButton currentBtn = buttonList.get(i);
|
||||
// 4. 索引防护:若gift_bag列表长度不足,默认按status=0处理
|
||||
int status = (i < giftBagList.size()) ? giftBagList.get(i).getStatus() : 0;
|
||||
// 检查是否有status=0的情况,如果有则将isStatus设为false
|
||||
if (status == 0) {
|
||||
isstatus = false;
|
||||
}
|
||||
setButtonStatus(currentBtn, status, i); // 增加索引参数
|
||||
}
|
||||
updateRechargeTextViewStatus(isstatus, 0);
|
||||
|
||||
|
||||
} else {
|
||||
// 5. 兜底逻辑:数据为空时,所有按钮按status=0处理
|
||||
for (int i = 0; i < buttonList.size(); i++) {
|
||||
setButtonStatus(buttonList.get(i), 0, i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 工具方法:统一设置单个按钮的状态
|
||||
*
|
||||
* @param button 要设置的RadioButton
|
||||
* @param status 状态值
|
||||
* @param index 按钮索引,用于标识不同按钮
|
||||
*/
|
||||
private void setButtonStatus(RadioButton button, int status, int index) {
|
||||
if (button == null) return;
|
||||
|
||||
// 移除之前的点击监听器,避免重复设置
|
||||
button.setOnClickListener(null);
|
||||
|
||||
if (status == 1) {
|
||||
// 可用状态
|
||||
button.setEnabled(true);
|
||||
// button.setChecked(true);
|
||||
|
||||
// 恢复充值按钮状态
|
||||
updateRechargeTextViewStatus(true, index);
|
||||
button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
updateRechargeTextViewStatus(true, index);
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
// status=0和其他状态:特殊处理
|
||||
button.setEnabled(true); // 保持可点击以响应交互
|
||||
// button.setChecked(false);
|
||||
// 设置特殊背景(根据需求修改为你的资源)
|
||||
button.setBackground(getResources().getDrawable(R.drawable.bf_e9));
|
||||
button.setTextColor(getResources().getColor(R.color.colorBlack65));
|
||||
updateRechargeTextViewStatus(false, index);
|
||||
// 添加点击事件
|
||||
button.setOnClickListener(v -> {
|
||||
// 点击时再次确认是status=0状态才处理
|
||||
button.setBackground(getResources().getDrawable(R.drawable.banner_indicator_focus));
|
||||
// 更新充值按钮状态为不可点击
|
||||
updateRechargeTextViewStatus(false, index);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 检查是否至少有一个元素达标(status == 1)
|
||||
*/
|
||||
public static boolean hasAnyQualified(List<FirstChargeGiftBean.GiftBag> giftBagList) {
|
||||
// 空列表处理 + 任意匹配检查
|
||||
return giftBagList != null && !giftBagList.isEmpty()
|
||||
&& giftBagList.stream()
|
||||
.anyMatch(gift -> gift.getStatus() == 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新充值TextView的状态
|
||||
*
|
||||
* @param enabled 是否可点击
|
||||
* @param index 关联的按钮索引
|
||||
*/
|
||||
private void updateRechargeTextViewStatus(boolean enabled, int index) {
|
||||
TextView rechargeTv = mBinding.tvInvite; // 假设充值按钮的id是tvRecharge
|
||||
if (rechargeTv == null) return;
|
||||
|
||||
// 设置是否可点击
|
||||
rechargeTv.setEnabled(enabled);
|
||||
|
||||
// 根据状态和索引设置不同背景
|
||||
if (enabled) {
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvInvite, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
||||
mBinding.tvInvite.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
|
||||
} else {
|
||||
|
||||
|
||||
// 不可点击状态的背景
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvInvite, ColorManager.getInstance().getButtonColorInt(), 53);
|
||||
mBinding.tvInvite.setTextColor(getResources().getColor(R.color.colorBlack65));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,228 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
import com.tencent.mm.opensdk.modelbiz.WXOpenCustomerServiceChat;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIC2CChatActivity;
|
||||
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIGroupChatActivity;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.base.RoomManager;
|
||||
import com.xscm.moduleutil.databinding.DialogRoomAuctionWebviewBinding;
|
||||
import com.xscm.moduleutil.databinding.WebViewDialogBinding;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/9/24
|
||||
*@description: 这是拍卖房的规则界面
|
||||
*/
|
||||
public class RoomAuctionWebViewDialog extends BaseDialog<DialogRoomAuctionWebviewBinding> {
|
||||
|
||||
String mUrl;
|
||||
int type;//10:天空之境 11:岁月之城 12:时空之巅
|
||||
|
||||
public RoomAuctionWebViewDialog(@NonNull Context context, Bundle args) {
|
||||
super(context, R.style.BaseDialogStyleH);
|
||||
this.mUrl = args.getString("url");
|
||||
this.type = args.getInt("type");
|
||||
initData1();
|
||||
}
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (getWindow() != null) {
|
||||
// 获取屏幕尺寸
|
||||
android.util.DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
|
||||
// 设置高度为屏幕高度的80%
|
||||
android.view.WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||
params.height = (int) (displayMetrics.heightPixels * 0.9);
|
||||
params.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
getWindow().setAttributes(params);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.dialog_room_auction_webview;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
setCancelable(true);
|
||||
setCanceledOnTouchOutside(true);
|
||||
Window window = getWindow();
|
||||
assert window != null;
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 320.f / 375), WindowManager.LayoutParams.MATCH_PARENT);
|
||||
mBinding.topBar.setTitle("规则");
|
||||
mBinding.topBar.getIvBack().setOnClickListener(v -> dismiss());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void initData1() {
|
||||
// WebSettings webSettings = mBinding.webView.getSettings();
|
||||
// webSettings.setUseWideViewPort(true);
|
||||
// webSettings.setLoadWithOverviewMode(true);
|
||||
// webSettings.setJavaScriptEnabled(true);
|
||||
// webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
||||
// //增加JSBridge
|
||||
// mBinding.webView.addJavascriptInterface(new WebAppInterface(getContext()), "Android");
|
||||
//// mBinding.webView.addJavascriptInterface(new WebViewBridgeConfig(title), WebViewBridgeConfig.NAME);
|
||||
// webSettings.setBuiltInZoomControls(false);
|
||||
// webSettings.setSupportZoom(false);
|
||||
// webSettings.setDomStorageEnabled(true);
|
||||
// webSettings.setBlockNetworkImage(false);//解决图片不显示
|
||||
// // 启用 WebView 内容的滚动
|
||||
// mBinding.webView.setVerticalScrollBarEnabled(true);
|
||||
// mBinding.webView.setScrollbarFadingEnabled(true);
|
||||
// webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
// webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
// mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
|
||||
// mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示
|
||||
// mBinding.webView.setWebViewClient(new WebViewClient());
|
||||
// mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
// mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
//
|
||||
// mBinding.webView.requestFocus();
|
||||
// mBinding.webView.loadUrl(mUrl);
|
||||
|
||||
WebSettings webSettings = mBinding.webView.getSettings();
|
||||
webSettings.setUseWideViewPort(true);
|
||||
webSettings.setLoadWithOverviewMode(true);
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
||||
//增加JSBridge
|
||||
mBinding.webView.addJavascriptInterface(new WebAppInterface(getContext()), "Android");
|
||||
// mBinding.webView.addJavascriptInterface(new WebViewBridgeConfig(title), WebViewBridgeConfig.NAME);
|
||||
webSettings.setBuiltInZoomControls(false);
|
||||
webSettings.setSupportZoom(false);
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setBlockNetworkImage(false);//解决图片不显示
|
||||
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
// 启用 WebView 内容的滚动,但隐藏滚动条
|
||||
mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
|
||||
mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示滚动条
|
||||
mBinding.webView.setWebViewClient(new WebViewClient());
|
||||
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
|
||||
// 确保内容可以滚动
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
|
||||
mBinding.webView.requestFocus();
|
||||
mBinding.webView.loadUrl(mUrl);
|
||||
}
|
||||
|
||||
private Resources getResources() {
|
||||
return getContext().getResources();
|
||||
}
|
||||
|
||||
public class WebAppInterface {
|
||||
Context mContext;
|
||||
|
||||
WebAppInterface(Context c) {
|
||||
mContext = c;
|
||||
}
|
||||
|
||||
// 被 H5 调用的方法
|
||||
@JavascriptInterface
|
||||
public void showToast(String toast) {
|
||||
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void closeWeb() {
|
||||
LogUtils.e("value: ");
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void customerService() {
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId(); // 填移动应用(App)的 AppId
|
||||
IWXAPI api = WXAPIFactory.createWXAPI(mContext, appId);
|
||||
|
||||
// 判断当前版本是否支持拉起客服会话
|
||||
WXOpenCustomerServiceChat.Req req = new WXOpenCustomerServiceChat.Req();
|
||||
req.corpId = "ww1de4300858c0b461"; // 企业ID
|
||||
req.url = "https://work.weixin.qq.com/kfid/kfcb3d23a59c188a0e7"; // 客服URL
|
||||
api.sendReq(req);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void jumpRoomPage(String room_id) {
|
||||
RoomManager.getInstance().fetchRoomDataAndEnter(getContext(), room_id,"");
|
||||
|
||||
// ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void jumpWebPage(String objects) {
|
||||
// ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).navigation();
|
||||
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", objects).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void enterGroupChat(String group_id,String cover,String guild_name) {
|
||||
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, group_id);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_GROUP);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void chatWithUser(String user_id,String nickname) {
|
||||
Intent intent = new Intent(mContext, TUIC2CChatActivity.class);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, user_id);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void exchange(){
|
||||
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
||||
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void Withdrawal() {
|
||||
ARouter.getInstance().build(ARouteConstants.WITHDRAWAL_ACTIVITY).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void enterAuthent() {//实名认证
|
||||
ARouter.getInstance().build(ARouteConstants.REAL_NAME_ACTIVITY2).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void Recharge(){
|
||||
ARouter.getInstance().build(ARouteConstants.RECHARGE_ACTIVITY).navigation();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
public class GiftItemAdapter extends BaseQuickAdapter<XlhDrawBean, BaseViewHolder> {
|
||||
public GiftItemAdapter() {
|
||||
super(R.layout.item_xlh_gift);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, XlhDrawBean item) {
|
||||
|
||||
helper.setText(R.id.tv_gift_name, item.getGift_name()+"x"+item.getCount());
|
||||
ImageUtils.loadHeadCC(item.getBase_image(),helper.getView(R.id.gift_img));
|
||||
helper.setText(R.id.tv_gift_num, item.getGift_price());
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/8/25
|
||||
*@description: 盲盒抽奖的实体类
|
||||
*/
|
||||
@Data
|
||||
public class GiftLottery {
|
||||
private String id;
|
||||
private String icon;
|
||||
private String number;
|
||||
private String name;
|
||||
private String price;
|
||||
private boolean isSelected;
|
||||
|
||||
public GiftLottery(String id, String icon, String number, String name, String price, boolean isSelected) {
|
||||
this.id = id;
|
||||
this.icon = icon;
|
||||
this.number = number;
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
this.isSelected = isSelected;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.animation.AccelerateDecelerateInterpolator;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.ScaleAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.GiftBoxBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/8/25
|
||||
* @description: 盲盒抽奖展示的视图
|
||||
*/
|
||||
// GiftLotteryAdapter.java
|
||||
public class GiftLotteryAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolder> {
|
||||
|
||||
|
||||
public GiftLotteryAdapter() {
|
||||
super(R.layout.item_gift_lottery);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, GiftBean item) {
|
||||
helper.setText(R.id.tv_gift_time, item.getCreatetime());
|
||||
ImageUtils.loadHeadCC(item.getBase_image(),helper.getView(R.id.iv_gift_image));
|
||||
// 使用 SpannableString 给 "x4" 设置不同颜色
|
||||
TextView giftNameTextView = helper.getView(R.id.gift_name);
|
||||
TextView nickNameTextView = helper.getView(R.id.tv_user_name);
|
||||
if (giftNameTextView != null) {
|
||||
String baseName = item.getGift_name();
|
||||
String countText = "x"+item.getCount();
|
||||
String fullText = baseName + countText;
|
||||
|
||||
SpannableStringBuilder spannable = new SpannableStringBuilder(fullText);
|
||||
|
||||
// 给 "x4" 部分设置颜色
|
||||
spannable.setSpan(
|
||||
new ForegroundColorSpan(mContext.getResources().getColor(R.color.color_C7BF62)), // 替换为实际颜色
|
||||
baseName.length(),
|
||||
fullText.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
|
||||
giftNameTextView.setText(spannable);
|
||||
}
|
||||
|
||||
if (nickNameTextView!=null){
|
||||
nickNameTextView.setText(item.getNickname());
|
||||
String nickName = "赠予";
|
||||
String fullText = nickName + " " + item.getNickname();
|
||||
SpannableStringBuilder spannable = new SpannableStringBuilder(fullText);
|
||||
|
||||
// 给 "x4" 部分设置颜色
|
||||
spannable.setSpan(
|
||||
new ForegroundColorSpan(mContext.getResources().getColor(R.color.color_C7BF62)), // 替换为实际颜色
|
||||
0,
|
||||
nickName.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
|
||||
nickNameTextView.setText(spannable);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,253 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.databinding.DialogGiftLotteryFragmentBinding;
|
||||
import com.xscm.moduleutil.widget.pagerecyclerview.PagerGridSnapHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/8/28
|
||||
*@description: 盲盒转盘中奖记录
|
||||
*/
|
||||
public class GiftLotteryDialogFragment extends BaseMvpDialogFragment<GiftLotteryPresenter, DialogGiftLotteryFragmentBinding> implements GiftLotteryContacts.View{
|
||||
|
||||
private int page=1;
|
||||
private String giftBagId;
|
||||
private int type=1;
|
||||
private GiftLotteryAdapter adapter;
|
||||
private GiftRecordAdapte giftRecordAdapte;
|
||||
private List<GiftBean> data=new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected GiftLotteryPresenter bindPresenter() {
|
||||
return new GiftLotteryPresenter(this,getSelfActivity());
|
||||
}
|
||||
|
||||
public static GiftLotteryDialogFragment newInstance(String giftBagId) {
|
||||
Bundle args = new Bundle();
|
||||
GiftLotteryDialogFragment fragment = new GiftLotteryDialogFragment();
|
||||
args.putString("giftBagId", giftBagId);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setCancelable(true);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
if (window != null) {
|
||||
// 获取屏幕高度
|
||||
android.util.DisplayMetrics displayMetrics = new android.util.DisplayMetrics();
|
||||
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
// 设置高度为屏幕高度的100%(全屏)
|
||||
int heightInPx = (int) (screenHeight * 0.8);;
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, heightInPx);
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
// 可选:设置动画样式(从底部弹出)
|
||||
window.setWindowAnimations(R.style.CommonShowDialogBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
giftBagId = getArguments().getString("giftBagId");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.getMyRecord(giftBagId, "1", "20",type);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
if (giftBagId.equals("10")){
|
||||
mBinding.clRoot.setBackgroundResource(R.mipmap.tkzj);
|
||||
mBinding.imJc.setImageResource(R.mipmap.jilu);
|
||||
}else if (giftBagId.equals("11")){
|
||||
mBinding.clRoot.setBackgroundResource(R.mipmap.syzc);
|
||||
mBinding.imJc.setImageResource(R.mipmap.syzc_jl);
|
||||
}else if (giftBagId.equals("12")){
|
||||
mBinding.clRoot.setBackgroundResource(R.mipmap.skzj);
|
||||
mBinding.imJc.setImageResource(R.mipmap.skzl_jl);
|
||||
}
|
||||
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
MvpPre.getMyRecord(giftBagId, page+"", "20",type);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.getMyRecord(giftBagId, page+"", "20",type);
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.textView1.setOnClickListener(this::onClick);
|
||||
mBinding.textView2.setOnClickListener(this::onClick);
|
||||
|
||||
adapter=new GiftLotteryAdapter();
|
||||
giftRecordAdapte=new GiftRecordAdapte();
|
||||
|
||||
// PagerGridLayoutManager layoutManager = new PagerGridLayoutManager(rows, columns, PagerGridLayoutManager.VERTICAL);
|
||||
|
||||
dianj(1);
|
||||
}
|
||||
|
||||
private void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id==R.id.textView1){
|
||||
dianj(1);
|
||||
}else if (id==R.id.textView2){
|
||||
dianj(2);
|
||||
}
|
||||
}
|
||||
public void dianj(int type1){
|
||||
if (type1==1) {
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 3);
|
||||
|
||||
mBinding.recyclerView.setLayoutManager(layoutManager);
|
||||
mBinding.recyclerView.setOnFlingListener(null);
|
||||
// 设置滚动辅助工具
|
||||
PagerGridSnapHelper pageSnapHelper = new PagerGridSnapHelper();
|
||||
pageSnapHelper.attachToRecyclerView(mBinding.recyclerView);
|
||||
mBinding.recyclerView.setAdapter(adapter);
|
||||
type=1;
|
||||
setTextViewStyle(mBinding.textView2, false);
|
||||
setTextViewStyle(mBinding.textView1, true);
|
||||
}else if (type1==2){
|
||||
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
||||
mBinding.recyclerView.setAdapter(giftRecordAdapte);
|
||||
type=2;
|
||||
setTextViewStyle(mBinding.textView2, true);
|
||||
setTextViewStyle(mBinding.textView1, false);
|
||||
}
|
||||
page=1;
|
||||
data.clear();
|
||||
MvpPre.getMyRecord(giftBagId, page+"", "20",type);
|
||||
}
|
||||
|
||||
private void setTextViewStyle(TextView textView, boolean isSelected) {
|
||||
if (isSelected) {
|
||||
textView.setTextColor(getResources().getColor(R.color.white));
|
||||
textView.setTextSize(16);
|
||||
textView.setBackground(getResources().getDrawable(R.mipmap.tab_dy));
|
||||
} else {
|
||||
textView.setTextColor(getResources().getColor(R.color.color_5B5B5B));
|
||||
textView.setTextSize(14);
|
||||
textView.setBackgroundColor(getResources().getColor(R.color.transparent));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.dialog_gift_lottery_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftListSuccess(BlindBoxBean blindBoxBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGiftListSuccess(BlindReslutBean blindReslutBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyRecordSuccess(List<GiftBean> data) {
|
||||
if (data != null){
|
||||
if (page==1){
|
||||
adapter.setNewData(data);
|
||||
}else {
|
||||
adapter.addData(data);
|
||||
}
|
||||
}else {
|
||||
if (page == 1) {
|
||||
adapter.setNewData(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllRecordSuccess(List<GiftBean> data) {
|
||||
|
||||
if (data != null){
|
||||
if (page==1){
|
||||
giftRecordAdapte.setNewData(data);
|
||||
}else {
|
||||
giftRecordAdapte.addData(data);
|
||||
}
|
||||
}else {
|
||||
if (page == 1) {
|
||||
giftRecordAdapte.setNewData(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wallet(WalletBean walletBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
public class GiftRecordAdapte extends BaseQuickAdapter<GiftBean, BaseViewHolder> {
|
||||
public GiftRecordAdapte() {
|
||||
super(R.layout.item_gift_record);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, GiftBean item) {
|
||||
|
||||
helper.setText(R.id.tv_user_name, item.getNickname());
|
||||
helper.setText(R.id.tv_gift_count_name,"x"+item.getCount()+" "+ item.getGift_name());
|
||||
helper.setText(R.id.tv_time, item.getCreatetime());
|
||||
ImageUtils.loadHeadCC(item.getBase_image(),helper.getView(R.id.iv_gift_icon));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
public class GiftRecordAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolder> {
|
||||
|
||||
|
||||
public GiftRecordAdapter() {
|
||||
super(R.layout.item_my_record);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, GiftBean item) {
|
||||
helper.setText(R.id.tv_gift_time, item.getCreatetime());
|
||||
ImageUtils.loadHeadCC(item.getBase_image(),helper.getView(R.id.iv_gift_image));
|
||||
// 使用 SpannableString 给 "x4" 设置不同颜色
|
||||
TextView giftNameTextView = helper.getView(R.id.tv_gift_name);
|
||||
if (giftNameTextView != null) {
|
||||
String baseName = item.getGift_name();
|
||||
String countText = "x"+item.getCount();
|
||||
String fullText = baseName + countText;
|
||||
|
||||
SpannableStringBuilder spannable = new SpannableStringBuilder(fullText);
|
||||
|
||||
// 给 "x4" 部分设置颜色
|
||||
spannable.setSpan(
|
||||
new ForegroundColorSpan(mContext.getResources().getColor(R.color.color_C7BF62)), // 替换为实际颜色
|
||||
baseName.length(),
|
||||
fullText.length(),
|
||||
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE
|
||||
);
|
||||
|
||||
giftNameTextView.setText(spannable);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
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.GiftBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class GiftXlhChouAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolder> {
|
||||
private List<GiftBean> giftLists = new ArrayList<>();
|
||||
private int selectedPosition = -1;
|
||||
private static final int LOOP_COUNT = 8; // 循环倍数
|
||||
|
||||
|
||||
public GiftXlhChouAdapter() {
|
||||
super(R.layout.item_xlh);
|
||||
}
|
||||
// 设置数据时创建循环数据
|
||||
@Override
|
||||
public void setNewData(List<GiftBean> data) {
|
||||
this.giftLists = data != null ? data : new ArrayList<>();
|
||||
super.setNewData(createLoopData());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建循环数据
|
||||
* @return 循环数据列表
|
||||
*/
|
||||
private List<GiftBean> createLoopData() {
|
||||
List<GiftBean> loopData = new ArrayList<>();
|
||||
if (giftLists.isEmpty()) {
|
||||
return loopData;
|
||||
}
|
||||
|
||||
// 创建足够多的循环数据以实现循环效果
|
||||
for (int i = 0; i < LOOP_COUNT; i++) {
|
||||
loopData.addAll(giftLists);
|
||||
}
|
||||
return loopData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
// 如果原始数据为空,返回0
|
||||
if (giftLists.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
// 返回循环数据的数量
|
||||
return super.getItemCount();
|
||||
}
|
||||
/**
|
||||
* 获取实际位置(将循环位置映射到原始数据位置)
|
||||
* @param position 循环列表中的位置
|
||||
* @return 原始数据中的实际位置
|
||||
*/
|
||||
private int getActualPosition(int position) {
|
||||
if (giftLists.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return position % giftLists.size();
|
||||
}
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, GiftBean item) {
|
||||
// 获取实际位置
|
||||
int actualPosition = getActualPosition(helper.getAdapterPosition());
|
||||
GiftBean actualItem = giftLists.get(actualPosition);
|
||||
|
||||
helper.setText(R.id.tv_gift_name, actualItem.getGift_name());
|
||||
helper.setText(R.id.tv_gift_pic, actualItem.getGift_price());
|
||||
ImageUtils.loadHeadCC(actualItem.getBase_image(), helper.getView(R.id.iv_gift_image));
|
||||
// 处理选中状态
|
||||
View selectedIcon = helper.getView(R.id.selected_icon);
|
||||
// 处理选中状态
|
||||
if (selectedIcon != null) {
|
||||
// 检查当前item是否为选中位置
|
||||
if (actualPosition == selectedPosition) {
|
||||
selectedIcon.setVisibility(View.GONE);
|
||||
helper.setBackgroundRes(R.id.ll_bg,R.mipmap.ke_bg);
|
||||
|
||||
} else {
|
||||
helper.setBackgroundRes(R.id.ll_bg,R.mipmap.xlh_cj_item);
|
||||
selectedIcon.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 设置选中位置并更新UI
|
||||
* @param position 选中的位置
|
||||
*/
|
||||
public void setSelectedPosition(int position) {
|
||||
int previousPosition = selectedPosition;
|
||||
selectedPosition = position;
|
||||
|
||||
if (previousPosition >= 0) {
|
||||
notifyItemsByActualPosition(previousPosition, false);
|
||||
}
|
||||
|
||||
if (selectedPosition >= 0) {
|
||||
notifyItemsByActualPosition(selectedPosition, true);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 根据实际位置通知所有匹配的item更新
|
||||
* @param actualPosition 原始数据中的位置
|
||||
* @param isSelected 是否选中
|
||||
*/
|
||||
private void notifyItemsByActualPosition(int actualPosition, boolean isSelected) {
|
||||
if (giftLists.isEmpty() || actualPosition >= giftLists.size()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 通知所有匹配该实际位置的item更新
|
||||
for (int i = 0; i < getItemCount(); i++) {
|
||||
if (getActualPosition(i) == actualPosition) {
|
||||
notifyItemChanged(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 清除选中状态
|
||||
*/
|
||||
public void clearSelection() {
|
||||
int previousPosition = selectedPosition;
|
||||
selectedPosition = -1;
|
||||
|
||||
if (previousPosition >= 0) {
|
||||
notifyItemsByActualPosition(previousPosition, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取原始数据大小
|
||||
* @return 原始数据大小
|
||||
*/
|
||||
public int getOriginalDataSize() {
|
||||
List<GiftBean> loopData = new ArrayList<>();
|
||||
for (int i = 0; i < LOOP_COUNT; i++) {
|
||||
loopData.addAll(giftLists);
|
||||
}
|
||||
return loopData.size();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.databinding.FframentDataBinding;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LuckyFragment extends BaseMvpDialogFragment<GiftLotteryPresenter, FframentDataBinding> implements GiftLotteryContacts.View {
|
||||
private int page=1;
|
||||
private String roomId;
|
||||
private int type=-1;
|
||||
private NewGiftRecordAdapte giftRecordAdapte;
|
||||
|
||||
@Override
|
||||
protected GiftLotteryPresenter bindPresenter() {
|
||||
return new GiftLotteryPresenter(this,getSelfActivity());
|
||||
}
|
||||
public static LuckyFragment newInstance(String giftBagId, int type) {
|
||||
Bundle args = new Bundle();
|
||||
LuckyFragment fragment = new LuckyFragment();
|
||||
args.putString("roomId", giftBagId);
|
||||
args.putInt("type",type);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
roomId = getArguments().getString("roomId");
|
||||
type = getArguments().getInt("type");
|
||||
MvpPre.xlhAllRecord(roomId, "1", "20",type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
MvpPre.xlhAllRecord(roomId, page+"", "20",type);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.xlhAllRecord(roomId, page+"", "20",type);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
giftRecordAdapte=new NewGiftRecordAdapte();
|
||||
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
||||
mBinding.recyclerView.setAdapter(giftRecordAdapte);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.fframent_data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftListSuccess(BlindBoxBean blindBoxBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGiftListSuccess(BlindReslutBean blindReslutBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyRecordSuccess(List<GiftBean> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllRecordSuccess(List<GiftBean> data) {
|
||||
|
||||
if (data != null){
|
||||
if (page==1){
|
||||
giftRecordAdapte.setNewData(data);
|
||||
}else {
|
||||
giftRecordAdapte.addData(data);
|
||||
}
|
||||
}else {
|
||||
if (page == 1) {
|
||||
giftRecordAdapte.setNewData(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wallet(WalletBean walletBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
|
||||
public class NewGiftRecordAdapte extends BaseQuickAdapter<GiftBean, BaseViewHolder> {
|
||||
public NewGiftRecordAdapte() {
|
||||
super(R.layout.item_gift_record_new);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, GiftBean item) {
|
||||
helper.setText(R.id.tv_issue,item.getPeriods());
|
||||
helper.setText(R.id.tv_user_name, item.getNickname());
|
||||
helper.setText(R.id.tv_gift_count_name, item.getGift_name());
|
||||
helper.setText(R.id.tv_time, item.getCreatetime());
|
||||
ImageUtils.loadHeadCC(item.getBase_image(),helper.getView(R.id.iv_gift_icon));
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.adapter.MyPagerAdapter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.databinding.DialogNewRankingXlhFragmentBinding;
|
||||
import com.xscm.moduleutil.dialog.LotteryFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/9/4
|
||||
*@description:巡乐会榜单
|
||||
*/
|
||||
public class NewXlhRankingDialog extends BaseMvpDialogFragment<GiftLotteryPresenter, DialogNewRankingXlhFragmentBinding> implements GiftLotteryContacts.View{
|
||||
private String roomId;
|
||||
|
||||
private MyPagerAdapter pagerAdapter;
|
||||
private List<Fragment> fragmentList;
|
||||
private List<String> titleList = new ArrayList();
|
||||
|
||||
@Override
|
||||
protected GiftLotteryPresenter bindPresenter() {
|
||||
return new GiftLotteryPresenter(this,getSelfActivity());
|
||||
}
|
||||
|
||||
public static NewXlhRankingDialog newInstance(String giftBagId) {
|
||||
Bundle args = new Bundle();
|
||||
NewXlhRankingDialog fragment = new NewXlhRankingDialog();
|
||||
args.putString("roomId", giftBagId);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setCancelable(true);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
if (window != null) {
|
||||
// 获取屏幕高度
|
||||
android.util.DisplayMetrics displayMetrics = new android.util.DisplayMetrics();
|
||||
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
// 设置高度为屏幕高度的100%(全屏)
|
||||
int heightInPx = (int) (screenHeight * 0.8);;
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, heightInPx);
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
// 可选:设置动画样式(从底部弹出)
|
||||
window.setWindowAnimations(R.style.CommonShowDialogBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
roomId = getArguments().getString("roomId");
|
||||
// MvpPre.xlhAllRecord(roomId, "1", "20");
|
||||
// 初始化Fragment列表
|
||||
initFragments();
|
||||
initViewPager();
|
||||
}
|
||||
|
||||
// 初始化Fragment列表
|
||||
private void initFragments() {
|
||||
fragmentList = new ArrayList<>();
|
||||
fragmentList.add(new LotteryFragment().newInstance(roomId,1)); // 第1页:抽奖榜单
|
||||
fragmentList.add(new LuckyFragment().newInstance(roomId,2)); // 第1页:抽奖榜单
|
||||
|
||||
}
|
||||
|
||||
// 初始化ViewPager
|
||||
private void initViewPager() {
|
||||
titleList.add("");
|
||||
titleList.add("");
|
||||
FragmentManager childFragmentManager = getChildFragmentManager();
|
||||
pagerAdapter = new MyPagerAdapter(childFragmentManager, fragmentList,titleList );
|
||||
mBinding.ivViewPager.setAdapter(pagerAdapter);
|
||||
mBinding.ivViewPager.setCurrentItem(0); // 默认显示第1页
|
||||
}
|
||||
@Override
|
||||
protected void initView() {
|
||||
mBinding.rbBtn.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
if (checkedId==R.id.radio_all){
|
||||
mBinding.ivViewPager.setCurrentItem(0);
|
||||
}else {
|
||||
mBinding.ivViewPager.setCurrentItem(1);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.dialog_new_ranking_xlh_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftListSuccess(BlindBoxBean blindBoxBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGiftListSuccess(BlindReslutBean blindReslutBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyRecordSuccess(List<GiftBean> data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllRecordSuccess(List<GiftBean> data) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wallet(WalletBean walletBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.adapter.MyBaseAdapter;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.utils.ImageUtils;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/8/28
|
||||
*@description: 盲盒转盘的奖池适配器
|
||||
*/
|
||||
public class PrizePoolAdapter extends BaseQuickAdapter<GiftBean, BaseViewHolder> {
|
||||
private Context context;
|
||||
private int type;
|
||||
|
||||
public PrizePoolAdapter(int type) {
|
||||
super(R.layout.item_prize_pool);
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void convert(BaseViewHolder helper, GiftBean item) {
|
||||
|
||||
if (type == 10 || type == 12){
|
||||
helper.setImageResource(R.id.iv_prize_pool,R.mipmap.tkzj_z);
|
||||
}else {
|
||||
helper.setImageResource(R.id.iv_prize_pool,R.mipmap.xlh_hd);
|
||||
}
|
||||
|
||||
helper.setText(R.id.tv_gift_name, item.getGift_name());
|
||||
helper.setText(R.id.tv_gift_pic, item.getGift_price());
|
||||
ImageUtils.loadHeadCC(item.getBase_image(),helper.getView(R.id.iv_gift_image));
|
||||
}
|
||||
|
||||
|
||||
public static class ViewHolder {
|
||||
private ImageView imGiftImage;
|
||||
private TextView tv_gift_name;
|
||||
private TextView tv_gift_price;
|
||||
|
||||
public ViewHolder(View convertView) {
|
||||
imGiftImage = convertView.findViewById(R.id.iv_gift_image);
|
||||
tv_gift_name = convertView.findViewById(R.id.tv_gift_name);
|
||||
tv_gift_price = convertView.findViewById(R.id.tv_gift_pic);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.databinding.DialogPrizePoolBinding;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/8/28
|
||||
* @description: 盲盒转盘奖池弹窗
|
||||
*/
|
||||
public class PrizePoolDialog extends BaseDialog<DialogPrizePoolBinding> {
|
||||
private Context mContext;
|
||||
private List<GiftBean> gift_list;
|
||||
private int type;
|
||||
|
||||
public PrizePoolDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
this.mContext = context;
|
||||
// 设置对话框从底部弹出并紧贴底部
|
||||
if (getWindow() != null) {
|
||||
getWindow().setGravity(android.view.Gravity.BOTTOM);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
if (getWindow() != null) {
|
||||
// 获取屏幕尺寸
|
||||
android.util.DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
|
||||
// 设置高度为屏幕高度的80%
|
||||
android.view.WindowManager.LayoutParams params = getWindow().getAttributes();
|
||||
params.height = (int) (displayMetrics.heightPixels * 0.7);
|
||||
params.width = android.view.ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
getWindow().setAttributes(params);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.dialog_prize_pool;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
private void showEmptyState() {
|
||||
// 显示空状态或加载中提示
|
||||
// mBinding.tvEmpty.setVisibility(View.VISIBLE);
|
||||
// mBinding.tvEmpty.setText("暂无奖池数据");
|
||||
}
|
||||
|
||||
// 提供更新数据的方法
|
||||
public void updateData(List<GiftBean> newData, int type) {
|
||||
if (type == 10) {
|
||||
mBinding.clPrize.setBackgroundResource(R.mipmap.tkzj);
|
||||
mBinding.imJc.setImageResource(R.mipmap.jiangc);
|
||||
} else if (type == 11) {
|
||||
mBinding.clPrize.setBackgroundResource(R.mipmap.syzc);
|
||||
mBinding.imJc.setImageResource(R.mipmap.syzc_jc);
|
||||
} else if (type == 12) {
|
||||
mBinding.clPrize.setBackgroundResource(R.mipmap.skzj);
|
||||
mBinding.imJc.setImageResource(R.mipmap.skzl_jc);
|
||||
}else if (type == 13){
|
||||
mBinding.clPrize.setBackgroundResource(R.mipmap.xlh);
|
||||
mBinding.imJc.setImageResource(R.mipmap.xlh_jc);
|
||||
}
|
||||
|
||||
// 根据屏幕密度调整行数和列数
|
||||
int rows, columns;
|
||||
float density = mContext.getResources().getDisplayMetrics().density;
|
||||
|
||||
if (density <= 2.0) { // 低密度屏幕(如mdpi, hdpi)
|
||||
rows = 4;
|
||||
columns = 3;
|
||||
} else if (density <= 3.0) { // 中密度屏幕(如xhdpi)
|
||||
rows = 4;
|
||||
columns = 3;
|
||||
} else { // 高密度屏幕(如xxhdpi, xxxhdpi)
|
||||
rows = 4;
|
||||
columns = 3;
|
||||
}
|
||||
|
||||
if (newData != null && !newData.isEmpty()) {
|
||||
this.gift_list = newData;
|
||||
if (mBinding != null && mContext != null) {
|
||||
PrizePoolAdapter prizePoolAdapter = new PrizePoolAdapter(type);
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(getContext(), 3);
|
||||
// PagerGridLayoutManager layoutManager = new PagerGridLayoutManager(rows, columns, PagerGridLayoutManager.VERTICAL);
|
||||
mBinding.gvGift.setLayoutManager(layoutManager);
|
||||
// mBinding.gvGift.setOnFlingListener(null);
|
||||
// 设置滚动辅助工具
|
||||
// PagerGridSnapHelper pageSnapHelper = new PagerGridSnapHelper();
|
||||
// pageSnapHelper.attachToRecyclerView(mBinding.gvGift);
|
||||
mBinding.gvGift.setAdapter(prizePoolAdapter);
|
||||
prizePoolAdapter.setNewData(gift_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,109 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Gravity;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.databinding.DialogHeavenGiftBinding;
|
||||
import com.xscm.moduleutil.databinding.DialogXlhObtainBinding;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/9/2
|
||||
* @description: 巡乐会恭喜或得礼弹窗
|
||||
*/
|
||||
public class XlhObtainDialog extends BaseDialog<DialogXlhObtainBinding> {
|
||||
|
||||
public interface OnGiftItemClickListener {
|
||||
|
||||
void onPlayAgainClick();
|
||||
|
||||
void onCloseClick();
|
||||
}
|
||||
|
||||
private GiftItemAdapter mAdapter;
|
||||
private OnGiftItemClickListener mListener;
|
||||
private List<XlhDrawBean> mGiftList;
|
||||
|
||||
public XlhObtainDialog(@NonNull Context context) {
|
||||
super(context, R.style.BaseDialogStyleH);
|
||||
}
|
||||
|
||||
public XlhObtainDialog(@NonNull Context context, List<XlhDrawBean> giftList) {
|
||||
super(context, R.style.BaseDialogStyleH);
|
||||
this.mGiftList = giftList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.dialog_xlh_obtain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
setCancelable(false);
|
||||
setCanceledOnTouchOutside(false);
|
||||
Window window = getWindow();
|
||||
// 设置对话框在屏幕中央显示
|
||||
window.setGravity(Gravity.CENTER);
|
||||
// 去掉背景阴影
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
|
||||
|
||||
// 设置窗口背景为透明
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 375.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
|
||||
// 设置点击事件
|
||||
mBinding.xlhClose.setOnClickListener(v -> {
|
||||
if (mListener != null) {
|
||||
mListener.onCloseClick();
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
|
||||
mBinding.ivAgain.setOnClickListener(v -> {
|
||||
if (mListener != null) {
|
||||
mListener.onPlayAgainClick();
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
initRecyclerView();
|
||||
}
|
||||
private void initRecyclerView() {
|
||||
mAdapter = new GiftItemAdapter();
|
||||
mBinding.rvHead.setLayoutManager(new GridLayoutManager(getContext(), 3));
|
||||
mBinding.rvHead.setAdapter(mAdapter);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置礼物数据
|
||||
*/
|
||||
public void setGiftList(List<XlhDrawBean> giftList) {
|
||||
this.mGiftList = giftList;
|
||||
if (mAdapter != null) {
|
||||
mAdapter.setNewData(giftList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置点击回调监听器
|
||||
*/
|
||||
public void setOnGiftItemClickListener(OnGiftItemClickListener listener) {
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.databinding.DialogGiftLotteryFragmentBinding;
|
||||
import com.xscm.moduleutil.databinding.DialogRankingXlhFragmentBinding;
|
||||
import com.xscm.moduleutil.widget.pagerecyclerview.PagerGridSnapHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/9/4
|
||||
*@description:巡乐会榜单
|
||||
*/
|
||||
public class XlhRankingDialog extends BaseMvpDialogFragment<GiftLotteryPresenter, DialogRankingXlhFragmentBinding> implements GiftLotteryContacts.View{
|
||||
private int page=1;
|
||||
private String roomId;
|
||||
private GiftRecordAdapte giftRecordAdapte;
|
||||
|
||||
@Override
|
||||
protected GiftLotteryPresenter bindPresenter() {
|
||||
return new GiftLotteryPresenter(this,getSelfActivity());
|
||||
}
|
||||
|
||||
public static XlhRankingDialog newInstance(String giftBagId,int type) {
|
||||
Bundle args = new Bundle();
|
||||
XlhRankingDialog fragment = new XlhRankingDialog();
|
||||
args.putString("roomId", giftBagId);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setCancelable(true);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
if (window != null) {
|
||||
// 获取屏幕高度
|
||||
android.util.DisplayMetrics displayMetrics = new android.util.DisplayMetrics();
|
||||
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
// 设置高度为屏幕高度的100%(全屏)
|
||||
int heightInPx = (int) (screenHeight * 0.8);;
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, heightInPx);
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
// 可选:设置动画样式(从底部弹出)
|
||||
window.setWindowAnimations(R.style.CommonShowDialogBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
roomId = getArguments().getString("roomId");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.xlhAllRecord(roomId, "1", "20",1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
MvpPre.xlhAllRecord(roomId, page+"", "20",1);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.xlhAllRecord(roomId, page+"", "20",1);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
giftRecordAdapte=new GiftRecordAdapte();
|
||||
mBinding.recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
|
||||
mBinding.recyclerView.setAdapter(giftRecordAdapte);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.dialog_ranking_xlh_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftListSuccess(BlindBoxBean blindBoxBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGiftListSuccess(BlindReslutBean blindReslutBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyRecordSuccess(List<GiftBean> data) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllRecordSuccess(List<GiftBean> data) {
|
||||
|
||||
if (data != null){
|
||||
if (page==1){
|
||||
giftRecordAdapte.setNewData(data);
|
||||
}else {
|
||||
giftRecordAdapte.addData(data);
|
||||
}
|
||||
}else {
|
||||
if (page == 1) {
|
||||
giftRecordAdapte.setNewData(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wallet(WalletBean walletBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,182 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.scwang.smartrefresh.layout.api.RefreshLayout;
|
||||
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.bean.GiftBean;
|
||||
import com.xscm.moduleutil.bean.WalletBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean;
|
||||
import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
|
||||
import com.xscm.moduleutil.databinding.DialogGiftLotteryFragmentBinding;
|
||||
import com.xscm.moduleutil.databinding.DialogXlhRecordFragmentBinding;
|
||||
import com.xscm.moduleutil.widget.pagerecyclerview.PagerGridSnapHelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/9/4
|
||||
*@description:巡乐会记录
|
||||
*/
|
||||
public class XlhRecordDialog extends BaseMvpDialogFragment<GiftLotteryPresenter, DialogXlhRecordFragmentBinding> implements GiftLotteryContacts.View{
|
||||
|
||||
private int page=1;
|
||||
private String roomId;
|
||||
private GiftRecordAdapter adapter;
|
||||
|
||||
@Override
|
||||
protected GiftLotteryPresenter bindPresenter() {
|
||||
return new GiftLotteryPresenter(this,getSelfActivity());
|
||||
}
|
||||
|
||||
public static XlhRecordDialog newInstance(String roomId) {
|
||||
Bundle args = new Bundle();
|
||||
XlhRecordDialog fragment = new XlhRecordDialog();
|
||||
args.putString("roomId", roomId);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
@Nullable
|
||||
@Override
|
||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) {
|
||||
Dialog dialog = super.onCreateDialog(savedInstanceState);
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setCancelable(true);
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
Window window = getDialog().getWindow();
|
||||
if (window != null) {
|
||||
// 获取屏幕高度
|
||||
android.util.DisplayMetrics displayMetrics = new android.util.DisplayMetrics();
|
||||
requireActivity().getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
|
||||
int screenHeight = displayMetrics.heightPixels;
|
||||
// 设置高度为屏幕高度的100%(全屏)
|
||||
int heightInPx = (int) (screenHeight * 0.8);;
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, heightInPx);
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
|
||||
// 可选:设置动画样式(从底部弹出)
|
||||
window.setWindowAnimations(R.style.CommonShowDialogBottom);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initDialogStyle(Window window) {
|
||||
super.initDialogStyle(window);
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
}
|
||||
@Override
|
||||
public void onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
roomId = getArguments().getString("roomId");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
MvpPre.xlhMyRecord(roomId, "1", "20");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
|
||||
mBinding.smartRefreshLayout.setOnRefreshLoadMoreListener(new OnRefreshLoadMoreListener() {
|
||||
@Override
|
||||
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
||||
page = 1;
|
||||
MvpPre.xlhMyRecord(roomId, page+"", "20");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
||||
page++;
|
||||
MvpPre.xlhMyRecord(roomId, page+"", "20");
|
||||
}
|
||||
});
|
||||
adapter=new GiftRecordAdapter();
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(getActivity(), 3);
|
||||
|
||||
mBinding.recyclerView.setLayoutManager(layoutManager);
|
||||
mBinding.recyclerView.setOnFlingListener(null);
|
||||
// 设置滚动辅助工具
|
||||
PagerGridSnapHelper pageSnapHelper = new PagerGridSnapHelper();
|
||||
pageSnapHelper.attachToRecyclerView(mBinding.recyclerView);
|
||||
mBinding.recyclerView.setAdapter(adapter);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.dialog_xlh_record_fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getGiftListSuccess(BlindBoxBean blindBoxBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawGiftListSuccess(BlindReslutBean blindReslutBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getMyRecordSuccess(List<GiftBean> data) {
|
||||
if (data != null){
|
||||
if (page==1){
|
||||
adapter.setNewData(data);
|
||||
}else {
|
||||
adapter.addData(data);
|
||||
}
|
||||
}else {
|
||||
if (page == 1) {
|
||||
adapter.setNewData(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getAllRecordSuccess(List<GiftBean> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRefreshLoadMore() {
|
||||
mBinding.smartRefreshLayout.finishRefresh();
|
||||
mBinding.smartRefreshLayout.finishLoadMore();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void wallet(WalletBean walletBean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void xlhChouSuccess(List<XlhDrawBean> data) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user