修改名称。

This commit is contained in:
2025-11-07 09:22:39 +08:00
parent d9cf55b053
commit a8dcfbb6a7
2203 changed files with 3 additions and 4 deletions

View File

@@ -0,0 +1,164 @@
package com.xscm.moduleutil.dialog;
import android.annotation.SuppressLint;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
import com.xscm.moduleutil.utils.ColorManager;
/**
*@author qx
*@data 2025/6/16
*@description: 确认弹框,使用在动态删除评论
*/
public class ConfirmDialog extends Dialog {
private String title;
private String message;
private String positiveButtonText;
private String negativeButtonText;
private View.OnClickListener positiveButtonClickListener;
private View.OnClickListener negativeButtonClickListener;
private boolean isCountdownEnabled = false; // 是否启用倒计时
private int countdownSeconds = 0; // 倒计时秒数
private CountDownTimer countDownTimer; // 倒计时对象
public ConfirmDialog(Context context, String title, String message,
String positiveButtonText, String negativeButtonText,
View.OnClickListener positiveButtonClickListener,
View.OnClickListener negativeButtonClickListener,
boolean isCountdownEnabled, int countdownSeconds) {
super(context);
this.title = title;
this.message = message;
this.positiveButtonText = positiveButtonText;
this.negativeButtonText = negativeButtonText;
this.positiveButtonClickListener = positiveButtonClickListener;
this.negativeButtonClickListener = negativeButtonClickListener;
this.isCountdownEnabled = isCountdownEnabled;
this.countdownSeconds = countdownSeconds;
}
private void init() {
Window window = getWindow();
if (window != null) {
window.setGravity(Gravity.CENTER); // 居中显示
window.setBackgroundDrawableResource(R.drawable.bg_r16_fff); // 透明背景
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_confirm);
init();
// 动态设置背景
// getWindow().setBackgroundDrawableResource(R.drawable.bg_r16_fff);
// 初始化视图
TextView tvTitle = findViewById(R.id.tv_title);
TextView tvMessage = findViewById(R.id.tv_message);
Button btnPositive = findViewById(R.id.btn_positive);
Button btnNegative = findViewById(R.id.btn_negative);
@SuppressLint({"MissingInflatedId", "LocalSuppress"})
ConstraintLayout rootView =(ConstraintLayout) findViewById(R.id.root_view);
// 设置文本
tvTitle.setText(title);
tvMessage.setText(message);
btnPositive.setText(positiveButtonText);
btnNegative.setText(negativeButtonText);
// 设置点击监听器
btnPositive.setOnClickListener(v -> {
isCountdownCancelled = true; // 标记倒计时被取消
if (countDownTimer != null) {
countDownTimer.cancel(); // 取消倒计时
countDownTimer = null;
}
if (positiveButtonClickListener != null) {
positiveButtonClickListener.onClick(v);
}
dismiss();
});
// 判断是否需要显示取消按钮
if (negativeButtonText != null && !negativeButtonText.isEmpty()) {
btnNegative.setText(negativeButtonText);
btnNegative.setVisibility(View.VISIBLE);
btnNegative.setOnClickListener(v -> {
if (negativeButtonClickListener != null) {
negativeButtonClickListener.onClick(v);
}
dismiss();
});
// 倒计时逻辑
if (isCountdownEnabled && countdownSeconds > 0) {
startCountdown(btnNegative);
}
} else {
// 隐藏取消按钮
btnNegative.setVisibility(View.GONE);
}
// 倒计时逻辑
if (isCountdownEnabled && countdownSeconds > 0) {
startCountdown(btnNegative);
}
ThemeableDrawableUtils.setThemeableRoundedBackground(btnPositive, ColorManager.getInstance().getPrimaryColorInt(), 53);
btnPositive.setTextColor(ColorManager.getInstance().getButtonColorInt());
// 找到根布局并应用动画
// if (rootView != null) {
// Animation slideDown = AnimationUtils.loadAnimation(context, R.anim.slide_down);
// Animation shake = AnimationUtils.loadAnimation(context, R.anim.shake);
//
// rootView.startAnimation(slideDown);
// rootView.startAnimation(shake);
// }
}
private boolean isCountdownCancelled = false; // 添加标志位
private void startCountdown(Button btnNegative) {
countDownTimer = new CountDownTimer(countdownSeconds * 1000L, 1000) {
@Override
public void onTick(long millisUntilFinished) {
int secondsLeft = (int) (millisUntilFinished / 1000);
btnNegative.setText(negativeButtonText + " (" + secondsLeft + "s)");
}
@Override
public void onFinish() {
// 检查是否被主动取消
if (!isCountdownCancelled) {
btnNegative.setText(negativeButtonText);
if (negativeButtonClickListener != null) {
negativeButtonClickListener.onClick(btnNegative); // 自动触发取消
}
dismiss();
}
}
}.start();
}
@Override
public void dismiss() {
if (countDownTimer != null) {
countDownTimer.cancel(); // 取消倒计时
countDownTimer = null;
}
super.dismiss();
}
}

View File

@@ -0,0 +1,240 @@
package com.xscm.moduleutil.dialog;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.DatePicker;
import com.xscm.moduleutil.R;
import java.lang.reflect.Field;
/**
* A simple dialog containing an {@link DatePicker}.
*
* <p>
* See the <a href="{@docRoot}guide/topics/ui/controls/pickers.html">Pickers</a>
* guide.
* </p>
*/
public class DoubleDatePickerDialog extends AlertDialog implements DialogInterface.OnClickListener, DatePicker.OnDateChangedListener {
private static final String START_YEAR = "start_year";
private static final String END_YEAR = "end_year";
private static final String START_MONTH = "start_month";
private static final String END_MONTH = "end_month";
private static final String START_DAY = "start_day";
private static final String END_DAY = "end_day";
private final DatePicker mDatePicker_start;
private final DatePicker mDatePicker_end;
private final OnDateSetListener mCallBack;
/**
* The callback used to indicate the user is done filling in the date.
*/
public interface OnDateSetListener {
void onDateSet(DatePicker startDatePicker, int startYear, int startMonthOfYear, int startDayOfMonth,
DatePicker endDatePicker, int endYear, int endMonthOfYear, int endDayOfMonth);
}
/**
* @param context
* The context the dialog is to run in.
* @param callBack
* How the parent is notified that the date is set.
* @param year
* The initial year of the dialog.
* @param monthOfYear
* The initial month of the dialog.
* @param dayOfMonth
* The initial day of the dialog.
*/
public DoubleDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) {
this(context, 0, callBack, year, monthOfYear, dayOfMonth);
}
public DoubleDatePickerDialog(Context context, int theme, OnDateSetListener callBack, int year, int monthOfYear,
int dayOfMonth) {
this(context, 0, callBack, year, monthOfYear, dayOfMonth, true);
}
/**
* @param context
* The context the dialog is to run in.
* @param theme
* the theme to apply to this dialog
* @param callBack
* How the parent is notified that the date is set.
* @param year
* The initial year of the dialog.
* @param monthOfYear
* The initial month of the dialog.
* @param dayOfMonth
* The initial day of the dialog.
*/
public DoubleDatePickerDialog(Context context, int theme, OnDateSetListener callBack, int year, int monthOfYear,
int dayOfMonth, boolean isDayVisible) {
super(context, theme);
mCallBack = callBack;
Context themeContext = getContext();
setButton(BUTTON_POSITIVE, "确 定", this);
setButton(BUTTON_NEGATIVE, "取 消", this);
// setButton(BUTTON_POSITIVE,
// themeContext.getText(android.R.string.date_time_done), this);
setIcon(0);
LayoutInflater inflater = (LayoutInflater) themeContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.date_picker_dialog, null);
setView(view);
mDatePicker_start = (DatePicker) view.findViewById(R.id.datePickerStart);
mDatePicker_end = (DatePicker) view.findViewById(R.id.datePickerEnd);
mDatePicker_start.init(year, monthOfYear, dayOfMonth, this);
mDatePicker_end.init(year, monthOfYear, dayOfMonth, this);
// updateTitle(year, monthOfYear, dayOfMonth);
// 如果要隐藏当前日期,则使用下面方法。
if (!isDayVisible) {
hidDay(mDatePicker_start);
hidDay(mDatePicker_end);
}
}
/**
* 隐藏DatePicker中的日期显示
*
* @param mDatePicker
*/
private void hidDay(DatePicker mDatePicker) {
Field[] datePickerfFields = mDatePicker.getClass().getDeclaredFields();
for (Field datePickerField : datePickerfFields) {
if ("mDaySpinner".equals(datePickerField.getName())) {
datePickerField.setAccessible(true);
Object dayPicker = new Object();
try {
dayPicker = datePickerField.get(mDatePicker);
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
}
// datePicker.getCalendarView().setVisibility(View.GONE);
((View) dayPicker).setVisibility(View.GONE);
}
}
}
public void onClick(DialogInterface dialog, int which) {
// Log.d(this.getClass().getSimpleName(), String.format("which:%d",
// which));
// 如果是“取 消”按钮,则返回,如果是“确 定”按钮,则往下执行
if (which == BUTTON_POSITIVE)
tryNotifyDateSet();
}
@Override
public void onDateChanged(DatePicker view, int year, int month, int day) {
if (view.getId() == R.id.datePickerStart)
mDatePicker_start.init(year, month, day, this);
if (view.getId() == R.id.datePickerEnd)
mDatePicker_end.init(year, month, day, this);
// updateTitle(year, month, day);
}
/**
* 获得开始日期的DatePicker
*
* @return The calendar view.
*/
public DatePicker getDatePickerStart() {
return mDatePicker_start;
}
/**
* 获得结束日期的DatePicker
*
* @return The calendar view.
*/
public DatePicker getDatePickerEnd() {
return mDatePicker_end;
}
/**
* Sets the start date.
*
* @param year
* The date year.
* @param monthOfYear
* The date month.
* @param dayOfMonth
* The date day of month.
*/
public void updateStartDate(int year, int monthOfYear, int dayOfMonth) {
mDatePicker_start.updateDate(year, monthOfYear, dayOfMonth);
}
/**
* Sets the end date.
*
* @param year
* The date year.
* @param monthOfYear
* The date month.
* @param dayOfMonth
* The date day of month.
*/
public void updateEndDate(int year, int monthOfYear, int dayOfMonth) {
mDatePicker_end.updateDate(year, monthOfYear, dayOfMonth);
}
private void tryNotifyDateSet() {
if (mCallBack != null) {
mDatePicker_start.clearFocus();
mDatePicker_end.clearFocus();
mCallBack.onDateSet(mDatePicker_start, mDatePicker_start.getYear(), mDatePicker_start.getMonth(),
mDatePicker_start.getDayOfMonth(), mDatePicker_end, mDatePicker_end.getYear(),
mDatePicker_end.getMonth(), mDatePicker_end.getDayOfMonth());
}
}
@Override
protected void onStop() {
// tryNotifyDateSet();
super.onStop();
}
@Override
public Bundle onSaveInstanceState() {
Bundle state = super.onSaveInstanceState();
state.putInt(START_YEAR, mDatePicker_start.getYear());
state.putInt(START_MONTH, mDatePicker_start.getMonth());
state.putInt(START_DAY, mDatePicker_start.getDayOfMonth());
state.putInt(END_YEAR, mDatePicker_end.getYear());
state.putInt(END_MONTH, mDatePicker_end.getMonth());
state.putInt(END_DAY, mDatePicker_end.getDayOfMonth());
return state;
}
@Override
public void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
int start_year = savedInstanceState.getInt(START_YEAR);
int start_month = savedInstanceState.getInt(START_MONTH);
int start_day = savedInstanceState.getInt(START_DAY);
mDatePicker_start.init(start_year, start_month, start_day, this);
int end_year = savedInstanceState.getInt(END_YEAR);
int end_month = savedInstanceState.getInt(END_MONTH);
int end_day = savedInstanceState.getInt(END_DAY);
mDatePicker_end.init(end_year, end_month, end_day, this);
}
}

View File

@@ -0,0 +1,212 @@
package com.xscm.moduleutil.dialog;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Paint;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.RadioGroup;
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.DialogFirstChargeBinding;
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 java.util.ArrayList;
import java.util.List;
import io.reactivex.disposables.Disposable;
/**
* @author
* @data
* @description: 首充好礼
*/
public class FirstChargeDialog extends BaseDialog<DialogFirstChargeBinding> {
HeavenGiftAdapter heavenGiftAdapter;
FirstChargeGiftBean firstChargeGiftBean;
private int type;
public FirstChargeDialog(@NonNull Context context) {
super(context, R.style.BaseDialogStyleH);
}
@Override
public int getLayoutId() {
return R.layout.dialog_first_charge;
}
@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());
mBinding.tvTitle2.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);
heavenGiftAdapter = new HeavenGiftAdapter();
mBinding.bannerViewPager
.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.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.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.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;
}
}
}
}
});
mBinding.tvInvite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// RechargeDialogFragment.show(roomId, getSupportFragmentManager());
if (listener != null) {
listener.onFirstChargeConfirmed(firstChargeGiftBean,type);
}
}
});
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvInvite, ColorManager.getInstance().getPrimaryColorInt(), 53);
mBinding.tvInvite.setTextColor(ColorManager.getInstance().getButtonColorInt());
}
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().firstChargeGift(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.tvTitle22.setText("充值"+firstChargeGiftBean.getGift_bag().get(0).getName()+"即可获得"+firstChargeGiftBean.getGift_bag().get(0).getTitle2()+"的道具或装扮");
mBinding.bannerViewPager.create(baseListData(list, 4));
// mBinding.btn1.setText(firstChargeGiftBean.getGift_bag().get(1).getName());
// mBinding.btn2.setText(firstChargeGiftBean.getGift_bag().get(2).getName());
} 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);
}
}
}

View File

@@ -0,0 +1,192 @@
package com.xscm.moduleutil.dialog;
import android.content.Context;
import android.content.res.Resources;
import android.os.CountDownTimer;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import com.blankj.utilcode.util.ScreenUtils;
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.HeavenGiftBean;
import com.xscm.moduleutil.bean.RoonGiftModel;
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
import com.xscm.moduleutil.databinding.DialogHeavenGiftBinding;
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.List;
/**
*@author
*@data
*@description: 天降好礼
*/
public class HeavenGiftDialog extends BaseDialog<DialogHeavenGiftBinding> {
HeavenGiftAdapter heavenGiftAdapter;
private CountDownTimer countDownTimer;
public HeavenGiftDialog(@NonNull Context context) {
super(context,R.style.BaseDialogStyleH);
}
HeavenGiftBean heavenGiftBea;
@Override
public int getLayoutId() {
return R.layout.dialog_heaven_gift;
}
private OnFirstChargeListener listener;
public interface OnFirstChargeListener {
void onFirstChargeConfirmed(HeavenGiftBean giftBean, int type);
void onFirstChargeCancelled();
}
// 设置监听器的方法
public void setOnFirstChargeListener(OnFirstChargeListener listener) {
this.listener = listener;
}
@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());
// giftAdapter=new GiftAdapter();
// LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
// linearLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
// mBinding.rvHead.setLayoutManager(linearLayoutManager);
// mBinding.rvHead.setAdapter(giftAdapter);
heavenGiftAdapter=new HeavenGiftAdapter();
mBinding.bannerViewPager
.setPageMargin(15)
.setAutoPlay(false)
.setRevealWidth(0, 0)
.setIndicatorVisibility(View.VISIBLE)
.setIndicatorView(getVectorDrawableIndicator())
.setIndicatorSlideMode(IndicatorSlideMode.NORMAL)
.setAdapter(heavenGiftAdapter)
.create();
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvInvite, ColorManager.getInstance().getPrimaryColorInt(), 53);
mBinding.tvInvite.setTextColor(ColorManager.getInstance().getButtonColorInt());
mBinding.tvInvite.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (listener != null) {
listener.onFirstChargeConfirmed(heavenGiftBea,2);
}
}
});
}
@Override
public void initData() {
RetrofitClient.getInstance().getDayDropGift(new BaseObserver<HeavenGiftBean>() {
@Override
public void onSubscribe(Disposable d) {
}
@Override
public void onNext(HeavenGiftBean heavenGiftBean) {
if (heavenGiftBean != null){
heavenGiftBea=heavenGiftBean;
mBinding.tvTitle.setText(heavenGiftBean.getCounter());
// 示例:假设从 HeavenGiftBean 中获取倒计时时间(单位:秒)
// long countdownTime =Integer.parseInt(heavenGiftBean.getEffective_time()) * 1000L; // 转换为毫秒
// startCountdown(countdownTime);
mBinding.tvSj.setText("截止时间:"+heavenGiftBean.getEffective_time());
mBinding.bannerViewPager.create(baseListData(heavenGiftBean.getGift_list(),4));
}
}
});
// List<HeavenGiftBean> list=new ArrayList<>();
// for (int i = 0; i < 7; i++){
// HeavenGiftBean bean=new HeavenGiftBean();
// bean.setTitle("礼物"+i);
// bean.setPicture("");
// bean.setQuantity("x"+i);
// bean.setGold(i+"");
// bean.setDays(i+"天");
// list.add(bean);
// }
//// giftAdapter.setNewData(list);
// mBinding.bannerViewPager.create(baseListData(list,4));
}
private void startCountdown(long millisInFuture) {
if (countDownTimer != null) {
countDownTimer.cancel();
}
countDownTimer = new CountDownTimer(millisInFuture, 1000) {
@Override
public void onTick(long millisUntilFinished) {
updateCountdownDisplay(millisUntilFinished);
}
@Override
public void onFinish() {
// 倒计时结束时的处理
mBinding.tvSj.setText("00:00:00");
}
}.start();
}
private void updateCountdownDisplay(long millisUntilFinished) {
long totalSeconds = millisUntilFinished / 1000;
long hours = totalSeconds / 3600;
long minutes = (totalSeconds % 3600) / 60;
long seconds = totalSeconds % 60;
String timeFormatted = String.format("%02d:%02d:%02d", hours, minutes, seconds);
mBinding.tvSj.setText(timeFormatted);
}
@Override
public void dismiss() {
super.dismiss();
if (countDownTimer != null) {
countDownTimer.cancel();
countDownTimer = null;
}
}
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();
}
}

View File

@@ -0,0 +1,42 @@
package com.xscm.moduleutil.dialog;
import android.content.Context;
import android.view.Window;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import com.blankj.utilcode.util.ScreenUtils;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.databinding.DialogInviteBinding;
import com.xscm.moduleutil.widget.dialog.BaseDialog;
/**
*@author lxj
*@data 2025年5月14日
*@description: 房间邀请弹窗
*/
public class InviteDialog extends BaseDialog<DialogInviteBinding> {
public InviteDialog(@NonNull Context context) {
super(context);
}
@Override
public int getLayoutId() {
return R.layout.dialog_invite;
}
@Override
public void initView() {
setCancelable(false);
setCanceledOnTouchOutside(false);
Window window = getWindow();
window.setLayout((int) (ScreenUtils.getScreenWidth() * 315.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
mBinding.ivClose.setOnClickListener(v -> dismiss());
}
@Override
public void initData() {
}
}

View File

@@ -0,0 +1,49 @@
package com.xscm.moduleutil.dialog;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;
import androidx.annotation.NonNull;
import com.xscm.moduleutil.R;
/**
* com.xscm.moduleutil.dialog
* qx
* 2025/10/27
*/
public class LoadingDialog extends Dialog {
public LoadingDialog(@NonNull Context context) {
super(context);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 设置布局这里假设你有一个R.layout.loading_dialog布局文件
setContentView(R.layout.loading_dialog);
// 设置不可取消
setCancelable(false);
}
/**
* 显示加载对话框
*/
public void showLoading() {
if (!isShowing()) {
show();
}
}
/**
* 隐藏加载对话框
*/
public void hideLoading() {
if (isShowing()) {
dismiss();
}
}
}

View File

@@ -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) {
}
}

View File

@@ -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));
}
}
}

View File

@@ -0,0 +1,75 @@
package com.xscm.moduleutil.dialog;
import android.content.Context;
import android.view.Window;
import android.view.WindowManager;
import androidx.annotation.NonNull;
import com.blankj.utilcode.util.ScreenUtils;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.bean.FirstChargeGiftBean;
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
import com.xscm.moduleutil.databinding.DialogRealNameBinding;
import com.xscm.moduleutil.databinding.IndexDialogYouthModelBinding;
import com.xscm.moduleutil.utils.ColorManager;
import com.xscm.moduleutil.widget.dialog.BaseDialog;
/**
*@author
*@data
*@description:实名认账弹窗
*/
public class RealNameDialog extends BaseDialog<DialogRealNameBinding> {
public interface OnFirstChargeListener {
void onFirstChargeConfirmed(String giftBean, int type);
void onFirstChargeCancelled();
}
private OnFirstChargeListener listener;
// 设置监听器的方法
public void setOnFirstChargeListener(OnFirstChargeListener listener) {
this.listener = listener;
}
public RealNameDialog(@NonNull Context context) {
super(context);
}
@Override
public int getLayoutId() {
return R.layout.dialog_real_name;
}
@Override
public void initView() {
setCancelable(false);
setCanceledOnTouchOutside(false);
Window window = getWindow();
window.setLayout((int) (ScreenUtils.getScreenWidth() * 315.f / 375), WindowManager.LayoutParams.WRAP_CONTENT);
// mBinding.tvIKnow.setOnClickListener(v -> dismiss());
// mBinding.ivClose.setOnClickListener(v -> dismiss());
mBinding.tvIKnow.setOnClickListener(v -> {
if (listener != null) {
listener.onFirstChargeConfirmed(null, 0);
}
});
mBinding.ivClose.setOnClickListener(v -> {
if (listener != null) {
listener.onFirstChargeCancelled();
}
});
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvIKnow, ColorManager.getInstance().getPrimaryColorInt(), 53);
mBinding.tvIKnow.setTextColor(ColorManager.getInstance().getButtonColorInt());
}
@Override
public void initData() {
}
}

View File

@@ -0,0 +1,267 @@
package com.xscm.moduleutil.dialog;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import com.alibaba.fastjson.JSON;
import com.blankj.utilcode.util.ToastUtils;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.adapter.BalanceRechargeAdapter;
import com.xscm.moduleutil.adapter.PayMethodAdapter;
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
import com.xscm.moduleutil.base.CommonAppContext;
import com.xscm.moduleutil.bean.AppPay;
import com.xscm.moduleutil.bean.BindType;
import com.xscm.moduleutil.bean.RechargeBean;
import com.xscm.moduleutil.databinding.FragmentRechargeDialogBinding;
import com.xscm.moduleutil.presenter.RechargeDialogContacts;
import com.xscm.moduleutil.presenter.RechargeDialogPresenter;
import com.xscm.moduleutil.utils.SpUtil;
import com.xscm.moduleutil.widget.PaymentUtil;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import java.lang.reflect.Field;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
*@author qx
*@data 2025/6/12
*@description: 充值弹框
*/
public class RechargeDialogFragment extends BaseMvpDialogFragment<RechargeDialogPresenter, FragmentRechargeDialogBinding> implements RechargeDialogContacts.View {
private BalanceRechargeAdapter rechargeAdapter;
private String money = "0";
private String type ;
private String coin;
private BindType.AllData selectedItem;
private PayMethodAdapter bindTypeAdapter;
private String roomId;
private String gift_bag_id="0";//默认0 类型id 传 gift_bag_id
private String type_params="0"; //默认0 类型参数 1首充 2天降好礼 3新人好礼
public static RechargeDialogFragment show(String id, String type, FragmentManager fragmentManager,String gift_bag_id,String type_params) {
RechargeDialogFragment dialogFragment = new RechargeDialogFragment();
Bundle args = new Bundle();
args.putString("roomId", id); //// 可选:传递参数
args.putString("type", type);
args.putString("gift_bag_id", gift_bag_id);
args.putString("type_params", type_params);
dialogFragment.setArguments(args);
dialogFragment.show(fragmentManager, "RoomOnlineDialogFragment");
return dialogFragment;
}
@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");
type = getArguments().getString("type");
gift_bag_id = getArguments().getString("gift_bag_id");
type_params = getArguments().getString("type_params");
if(type!=null){
money=type;
}
}
@Override
protected RechargeDialogPresenter bindPresenter() {
return new RechargeDialogPresenter(this, getContext());
}
@Override
protected void initData() {
if (roomId!=null) {
MvpPre.recharge();
}
MvpPre.bindType(SpUtil.getUserId() + "");
}
private void onClick(View view) {
if (view.getId() == R.id.tv_payment) {
if (money.equals("0")) {
money=mBinding.etCustomAmount.getText().toString().trim();
if (TextUtils.isEmpty(money)) {
ToastUtils.showShort("请选择充值金额");
return;
}
}
// if (Double.valueOf(money) < 6) {
// ToastUtils.showShort("最低充值6元以上");
// return;
// }
if (selectedItem == null) {
ToastUtils.showShort("请选择支付方式");
return;
}
MvpPre.appPay(SpUtil.getUserId() + "", money, coin, selectedItem.getType(),type_params,gift_bag_id);
}
}
@Override
protected void initView() {
mBinding.tvPayment.setOnClickListener(this::onClick);
mBinding.recycleView1.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
bindTypeAdapter = new PayMethodAdapter(R.layout.item_bind_type);
mBinding.recycleView1.setAdapter(bindTypeAdapter);
bindTypeAdapter.setOnItemClickListener((adapter, view, position) -> {
// 更新选中项
bindTypeAdapter.setSelectedPosition(position);
// 获取当前选中的数据
selectedItem = bindTypeAdapter.getItem(position);
// 可以在这里处理选中逻辑,比如保存到变量或触发支付
});
if (type!=null){
mBinding.r4.setVisibility(View.GONE);
}else{
mBinding.r4.setVisibility(View.GONE);
}
}
@Override
protected int getLayoutId() {
return R.layout.fragment_recharge_dialog;
}
@Override
public void setRechargeData(List<RechargeBean> rechargeData) {
// RechargeBean customItem = new RechargeBean();
// customItem.setCoins("自定义");
// customItem.setMoney("");
// customItem.setItemViewType(1);
// rechargeData.add(customItem);
rechargeAdapter = new BalanceRechargeAdapter(rechargeData);
rechargeAdapter.setNewData(rechargeData);
rechargeAdapter.setListener(new BalanceRechargeAdapter.OnRechargeItemClickListener() {
@Override
public void onClick(RechargeBean rechargeBean) {
money = rechargeBean.getMoney();
// mBinding.tvPayment.setText(String.format("立即支付(%s元)", money));
}
});
rechargeAdapter.setInputBoxVisibilityListener(new BalanceRechargeAdapter.InputBoxVisibilityListener() {
@Override
public void onInputBoxVisibilityChanged(boolean isVisible) {
// 根据 isVisible 的值来显示或隐藏输入框
mBinding.r4.setVisibility(isVisible ? View.VISIBLE : View.GONE);
if (isVisible){
money="0";
}
}
});
mBinding.rvComment.setLayoutManager(new GridLayoutManager(getContext(), 3));
mBinding.rvComment.setAdapter(rechargeAdapter);
mBinding.tvPayment.setText("立即支付");
}
@Override
public void bindType(BindType bindType) {
List<BindType.AllData> allData = new ArrayList<>();
if (bindType.getAli().getIs_pay_open().equals("1")) {
allData.add(bindType.getAli());
}
if (bindType.getWx().getIs_pay_open().equals("1")) {
allData.add(bindType.getWx());
}
if (bindType.getBank().getIs_pay_open().equals("1")) {
allData.add(bindType.getBank());
}
if (bindType.getAli_tl().getIs_pay_open().equals("1")) {
allData.add(bindType.getAli_tl());
}
if (bindType.getWx_tl().getIs_pay_open().equals("1")) {
allData.add(bindType.getWx_tl());
}
bindTypeAdapter.setNewData(allData);
}
@Override
public void appPay(AppPay appPay) {
if (appPay.getAli()!=null) {
PaymentUtil.payAlipay(getContext(), appPay.getAli());
}else if (appPay.getWx()!=null){
IWXAPI wxapi = WXAPIFactory.createWXAPI(getContext(), CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId());
PaymentUtil.payWxMiniProgram2(wxapi,appPay);
}else if (appPay.getTl()!=null){
if (appPay.getTl().getRemark().equals("5")) {//微信
IWXAPI wxapi = WXAPIFactory.createWXAPI(getContext(), CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId());
try {
String paramString = buildParamString(appPay.getTl());
PaymentUtil.payWxMiniProgramWx(wxapi,paramString);
android.util.Log.d("RequestParams", paramString); // 输出拼接后的参数
} catch (IllegalAccessException e) {
e.printStackTrace();
}
} else if (appPay.getTl().getRemark().equals("4")) {//支付宝
String s= JSON.toJSONString(appPay.getTl());
try {
String query = URLEncoder.encode("payinfo=" + URLEncoder.encode(s, "UTF-8"), "UTF-8");
String url = "alipays://platformapi/startapp?appId=2021001104615521&page=pages/orderDetail/orderDetail&thirdPartSchema="
+ URLEncoder.encode("myziroom://myziroom/", "UTF-8") + "&query=" + query;
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}
public static String buildParamString(Object obj) throws IllegalAccessException {
Class<?> clazz = obj.getClass();
Field[] fields = clazz.getDeclaredFields();
TreeMap<String, String> paramMap = new TreeMap<>();
// 遍历字段并填充 TreeMap
for (Field field : fields) {
field.setAccessible(true); // 允许访问私有字段
Object value = field.get(obj);
if (value != null && !String.valueOf(value).isEmpty()) {
paramMap.put(field.getName(), String.valueOf(value));
}
}
// 使用 StringBuilder 拼接参数字符串
StringBuilder builder = new StringBuilder();
for (Map.Entry<String, String> entry : paramMap.entrySet()) {
if (builder.length() > 0) {
builder.append("&");
}
builder.append(entry.getKey())
.append("=")
.append(entry.getValue());
}
return builder.toString();
}
}

View File

@@ -0,0 +1,91 @@
package com.xscm.moduleutil.dialog;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.DialogFragment;
import com.blankj.utilcode.util.ToastUtils;
import com.xscm.moduleutil.R;
public class ReplyDialogFragment extends DialogFragment {
private static final String TAG = "ReplyDialogFragment";
private int commentId;
private int position;
private OnCommentInteractionListener listener;
public interface OnCommentInteractionListener {
void onInputBoxShow(int id, String content, int position);
}
public static ReplyDialogFragment newInstance(int commentId, int position, OnCommentInteractionListener listener) {
ReplyDialogFragment fragment = new ReplyDialogFragment();
fragment.commentId = commentId;
fragment.position = position;
fragment.listener = listener;
return fragment;
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.dialog_reply, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
EditText etInput = view.findViewById(R.id.et_input);
TextView tvSend = view.findViewById(R.id.tv_send);
etInput.requestFocus();
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
tvSend.setOnClickListener(v -> {
String content = etInput.getText().toString().trim();
if (!TextUtils.isEmpty(content) && listener != null) {
listener.onInputBoxShow(commentId, content, position);
dismiss();
} else {
ToastUtils.showShort("请输入内容");
}
});
}
@Override
public void onStart() {
super.onStart();
Window window = getDialog().getWindow();
if (window != null) {
// 设置宽度为 match_parent
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
// 设置位置在底部(可选)
window.setGravity(Gravity.BOTTOM);
// 去除默认背景遮罩
window.setBackgroundDrawableResource(android.R.color.transparent);
window.getDecorView().setBackgroundColor(0x00000000); // 完全透明
}
}
@Override
public void onResume() {
super.onResume();
// 自动弹出软键盘
getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
}
}

View File

@@ -0,0 +1,72 @@
package com.xscm.moduleutil.dialog;
import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.blankj.utilcode.util.ConvertUtils;
import com.cpiz.android.bubbleview.BubbleFrameLayout;
import com.cpiz.android.bubbleview.BubblePopupWindow;
import com.cpiz.android.bubbleview.BubbleStyle;
import com.xscm.moduleutil.R;
/**
*@author qx
*@data 2025/6/10
*@description: 带有气泡的提示框
*/
public class RoomTipsView {
public static void show(Context context, View anchor, String title, String content) {
BubbleFrameLayout bubbleView = (BubbleFrameLayout) LayoutInflater.from(context).inflate(R.layout.room_view_room_tips, null);
TextView tvTitle = bubbleView.findViewById(R.id.tv_title);
TextView tvContent = bubbleView.findViewById(R.id.tv_content);
tvTitle.setText(title);
tvContent.setText(content);
bubbleView.setCornerRadius(ConvertUtils.dp2px(8));
bubbleView.setFillColor(Color.WHITE);
BubblePopupWindow window = new BubblePopupWindow(bubbleView, bubbleView);
window.setCancelOnTouch(true);
window.setCancelOnTouchOutside(true);
window.setPadding(ConvertUtils.dp2px(20));
anchor.post(new Runnable() {
@Override
public void run() {
if (window == null || anchor == null) {
return;
}
window.showArrowTo(anchor, BubbleStyle.ArrowDirection.Up);
}
});
}
public static void showWithDelay(Context context, View anchor, String title, String content) {
if (context == null || (context instanceof Activity && (((Activity) context).isDestroyed() || ((Activity) context).isFinishing()))) {
return;
}
BubbleFrameLayout bubbleView = (BubbleFrameLayout) LayoutInflater.from(context).inflate(R.layout.room_view_room_tips, null);
TextView tvTitle = bubbleView.findViewById(R.id.tv_title);
TextView tvContent = bubbleView.findViewById(R.id.tv_content);
tvTitle.setText(title);
tvContent.setText(content);
bubbleView.setCornerRadius(ConvertUtils.dp2px(8));
bubbleView.setFillColor(Color.WHITE);
BubblePopupWindow window = new BubblePopupWindow(bubbleView, bubbleView);
window.setCancelOnTouch(true);
window.setCancelOnTouchOutside(true);
window.setPadding(ConvertUtils.dp2px(20));
anchor.post(new Runnable() {
@Override
public void run() {
if (window == null || anchor == null) {
return;
}
window.showArrowTo(anchor, BubbleStyle.ArrowDirection.Up);
window.setCancelOnLater(2000);
}
});
}
}

View File

@@ -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());
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}
}
}

View File

@@ -0,0 +1,49 @@
package com.xscm.moduleutil.dialog.giftLottery;
import android.app.Activity;
import com.xscm.moduleutil.activity.IPresenter;
import com.xscm.moduleutil.activity.IView;
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 java.util.List;
public class GiftLotteryContacts {
public interface View extends IView<Activity> {
void getGiftListSuccess(BlindBoxBean blindBoxBean);
void drawGiftListSuccess(BlindReslutBean blindReslutBean);
void getMyRecordSuccess(List<GiftBean> data);
void getAllRecordSuccess(List<GiftBean> data);
void finishRefreshLoadMore();
void wallet(WalletBean walletBean);
void xlhChouSuccess(List<XlhDrawBean> data);
}
public interface IRoomPre extends IPresenter {
void getGiftList(String giftBagId,String roomId);
void drawGiftList(String giftBagId,String gift_user_ids,String roomId,String num,String heart_id,String auction_id);
void getMyRecord(String giftBagId,String page,String pageSize,int type);//我的抽奖记录 type: 1:我的抽奖 2全服抽奖
void giftSend(String send_id);
void wallet();
void xlh(String room_id);
void xlhChou(String room_id,String num);
void xlhAllRecord(String room_id,String page,String pageSize,int type);
void xlhMyRecord(String room_id,String page,String pageSize);
}
}

View File

@@ -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) {
}
}

View File

@@ -0,0 +1,217 @@
package com.xscm.moduleutil.dialog.giftLottery;
import android.content.Context;
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.http.BaseObserver;
import com.xscm.moduleutil.http.RetrofitClient;
import com.xscm.moduleutil.presenter.BasePresenter;
import java.lang.ref.WeakReference;
import java.util.List;
import io.reactivex.disposables.Disposable;
public class GiftLotteryPresenter extends BasePresenter<GiftLotteryContacts.View> implements GiftLotteryContacts.IRoomPre {
GiftLotteryContacts.View mView;
public GiftLotteryPresenter(GiftLotteryContacts.View view, Context context) {
super(view, context);
mView = view;
}
@Override
public void getGiftList(String giftBagId, String roomId) {
api.getBoxGiftList(giftBagId, roomId, new BaseObserver<BlindBoxBean>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable( d);
}
@Override
public void onNext(BlindBoxBean blindBoxBeans) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
}
MvpRef.get().getGiftListSuccess(blindBoxBeans);
}
});
}
@Override
public void drawGiftList(String giftBagId, String gift_user_ids, String roomId, String num,String heart_id,String auction_id) {
api.drawGiftList(giftBagId, gift_user_ids, roomId, num,heart_id,auction_id, new BaseObserver<BlindReslutBean>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
@Override
public void onNext(BlindReslutBean blindReslutBean) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
}
MvpRef.get().drawGiftListSuccess(blindReslutBean);
}
});
}
@Override
public void getMyRecord(String giftBagId, String page, String pageSize,int type) {
if (type==1) {
api.getMyRecord(giftBagId, page, pageSize, new BaseObserver<List<GiftBean>>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
@Override
public void onNext(List<GiftBean> giftBean) {
if (MvpRef == null) {
MvpRef = new WeakReference<>(mView);
}
MvpRef.get().getMyRecordSuccess(giftBean);
MvpRef.get().finishRefreshLoadMore();
}
});
}else {
api.getAllRecord(giftBagId,page,pageSize,new BaseObserver<List<GiftBean>>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
@Override
public void onNext(List<GiftBean> giftBean) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
}
MvpRef.get().getAllRecordSuccess(giftBean);
MvpRef.get().finishRefreshLoadMore();
}
});
}
}
@Override
public void giftSend(String send_id) {
api.giftSend(send_id, new BaseObserver<String>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
@Override
public void onNext(String s) {
}
});
}
@Override
public void wallet() {
api.wallet(new BaseObserver<WalletBean>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
@Override
public void onNext(WalletBean walletBean) {
if (MvpRef == null) {
MvpRef = new WeakReference<>(mView);
}
MvpRef.get().wallet(walletBean);
}
});
}
///巡乐会
@Override
public void xlh(String room_id) {
// api.xlh(room_id, new BaseObserver<String>() {)
api.getBoxGiftListXLH(room_id, new BaseObserver<BlindBoxBean>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable( d);
}
@Override
public void onNext(BlindBoxBean blindBoxBeans) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
}
MvpRef.get().getGiftListSuccess(blindBoxBeans);
}
});
}
@Override
public void xlhChou(String room_id, String num) {
if (api==null){
api= RetrofitClient.getInstance();
}
api.xlhChou(room_id,num, new BaseObserver<List<XlhDrawBean>>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
@Override
public void onNext(List<XlhDrawBean> xlhDrawBeans) {
if (MvpRef==null){
MvpRef=new WeakReference<>(mView);
}
MvpRef.get().xlhChouSuccess(xlhDrawBeans);
}
});
}
@Override
public void xlhAllRecord(String room_id, String page, String pageSize,int type) {
api.xlhAllRecord(room_id, page, pageSize,type, new BaseObserver<List<GiftBean>>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
@Override
public void onNext(List<GiftBean> giftBean) {
if (MvpRef == null) {
MvpRef = new WeakReference<>(mView);
}
MvpRef.get().getAllRecordSuccess(giftBean);
MvpRef.get().finishRefreshLoadMore();
}
});
}
@Override
public void xlhMyRecord(String room_id, String page, String pageSize) {
api.xlhMyRecord(room_id,page,pageSize,new BaseObserver<List<GiftBean>>() {
@Override
public void onSubscribe(Disposable d) {
addDisposable(d);
}
@Override
public void onNext(List<GiftBean> giftBeans) {
if (MvpRef == null) {
MvpRef = new WeakReference<>(mView);
}
MvpRef.get().getMyRecordSuccess(giftBeans);
MvpRef.get().finishRefreshLoadMore();
}
});
}
}

View File

@@ -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));
}
}

View File

@@ -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);
}
}
}

View File

@@ -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();
}
}

View File

@@ -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) {
}
}

View File

@@ -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));
}
}

View File

@@ -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) {
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}
}
}
}

View File

@@ -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() {
}
}

View File

@@ -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) {
}
}

View File

@@ -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) {
}
}