修改交友布局
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
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 -> {
|
||||
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 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() {
|
||||
btnNegative.setText(negativeButtonText);
|
||||
if (negativeButtonClickListener != null) {
|
||||
negativeButtonClickListener.onClick(btnNegative); // 自动触发取消
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
@Override
|
||||
public void dismiss() {
|
||||
if (countDownTimer != null) {
|
||||
countDownTimer.cancel(); // 取消倒计时
|
||||
countDownTimer = null;
|
||||
}
|
||||
super.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
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.GiftAdapter;
|
||||
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.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 java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.disposables.Disposable;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @data
|
||||
* @description: 首充好礼
|
||||
*/
|
||||
public class FirstChargeDialog extends BaseDialog<DialogFirstChargeBinding> {
|
||||
|
||||
GiftAdapter giftAdapter;
|
||||
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
|
||||
.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.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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// List<HeavenGiftBean> list = new ArrayList<>();
|
||||
// for (int i = 0; i < 7; i++) {
|
||||
// HeavenGiftBean bean = new HeavenGiftBean();
|
||||
// bean.setTitle("礼物" + i);
|
||||
// bean.setPicture("");
|
||||
// bean.setType(1);
|
||||
// bean.setQuantity("x" + i);
|
||||
// bean.setGold(i + "");
|
||||
// bean.setDays(i + "天");
|
||||
// list.add(bean);
|
||||
// }
|
||||
// mBinding.bannerViewPager.create(baseListData(list, 4));
|
||||
}
|
||||
|
||||
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());
|
||||
} 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
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.GiftAdapter;
|
||||
import com.xscm.moduleutil.adapter.HeavenGiftAdapter;
|
||||
import com.xscm.moduleutil.bean.BaseListData;
|
||||
import com.xscm.moduleutil.bean.HeavenGiftBean;
|
||||
import com.xscm.moduleutil.databinding.DialogHeavenGiftBinding;
|
||||
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;
|
||||
/**
|
||||
*@author
|
||||
*@data
|
||||
*@description: 天降好礼
|
||||
*/
|
||||
public class HeavenGiftDialog extends BaseDialog<DialogHeavenGiftBinding> {
|
||||
|
||||
GiftAdapter giftAdapter;
|
||||
HeavenGiftAdapter heavenGiftAdapter;
|
||||
public HeavenGiftDialog(@NonNull Context context) {
|
||||
super(context,R.style.BaseDialogStyleH);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.dialog_heaven_gift;
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
List<HeavenGiftBean> list=new ArrayList<>();
|
||||
for (int i = 0; i < 7; i++){
|
||||
HeavenGiftBean bean=new HeavenGiftBean();
|
||||
bean.setTitle("礼物"+i);
|
||||
bean.setPicture("");
|
||||
bean.setType(1);
|
||||
bean.setQuantity("x"+i);
|
||||
bean.setGold(i+"");
|
||||
bean.setDays(i+"天");
|
||||
list.add(bean);
|
||||
}
|
||||
// giftAdapter.setNewData(list);
|
||||
mBinding.bannerViewPager.create(baseListData(list,4));
|
||||
}
|
||||
|
||||
private List<BaseListData<HeavenGiftBean>> baseListData(List<HeavenGiftBean> list, int chunkSize){
|
||||
List<BaseListData<HeavenGiftBean>> baseListData = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i += chunkSize) {
|
||||
BaseListData<HeavenGiftBean> 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();
|
||||
}
|
||||
}
|
||||
@@ -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() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.text.TextPaint;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.style.ClickableSpan;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.databinding.DataBindingUtil;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.SpanUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.databinding.DialogPolicBinding;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
|
||||
/**
|
||||
* 隐私协议
|
||||
*/
|
||||
public class PolicyDialog extends Dialog {
|
||||
private final DialogPolicBinding policBinding;
|
||||
private PolicyClickListener mPolicyClickListener;
|
||||
|
||||
public PolicyDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
policBinding = DataBindingUtil.inflate(LayoutInflater.from(context), R.layout.dialog_polic, null, false);
|
||||
policBinding.setClick(new PolicyClickProxy());
|
||||
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
setContentView(policBinding.getRoot());
|
||||
setCanceledOnTouchOutside(false);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
SpanUtils spanUtils = new SpanUtils();
|
||||
ClickableSpan clickSpan = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=6" ).withString("title", "用户协议").navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
ds.setColor(Color.parseColor("#FFFFD6A2"));
|
||||
ds.setUnderlineText(true);
|
||||
}
|
||||
};
|
||||
ClickableSpan ysClickSpan = new ClickableSpan() {
|
||||
@Override
|
||||
public void onClick(@NonNull View widget) {
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getServerUrl()+"/api/Page/page_show?id=4").withString("title", "隐私协议").navigation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDrawState(@NonNull TextPaint ds) {
|
||||
ds.setColor(Color.parseColor("#FFFFD6A2"));
|
||||
ds.setUnderlineText(true);
|
||||
}
|
||||
};
|
||||
spanUtils.append("欢迎使用羽声!\n").append("在使用我们的产品和服务之前,请您先阅读并了解").append("《用户协议》").setClickSpan(clickSpan).append("和").append("《隐私协议》").setClickSpan(ysClickSpan).append("。我们将严格按照上述协议为" +
|
||||
"您提供服务,保护您的信息安全,点" +
|
||||
"击“同意”即表示您已阅读并同意全部" +
|
||||
"条款,可以继续使用我们的产品和服" +
|
||||
"务。");
|
||||
policBinding.tvText.setText(spanUtils.create());
|
||||
policBinding.tvText.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
}
|
||||
|
||||
public void setPolicyClickListener(PolicyClickListener policyClickListener) {
|
||||
this.mPolicyClickListener = policyClickListener;
|
||||
}
|
||||
|
||||
public class PolicyClickProxy {
|
||||
public void onAgreeClick() {
|
||||
if (mPolicyClickListener != null) {
|
||||
mPolicyClickListener.policyAgree();
|
||||
}
|
||||
}
|
||||
|
||||
public void onExit() {
|
||||
if (mPolicyClickListener != null) {
|
||||
mPolicyClickListener.policyExit();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public interface PolicyClickListener {
|
||||
void policyAgree();
|
||||
|
||||
void policyExit();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
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.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 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());
|
||||
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvIKnow, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
||||
mBinding.tvIKnow.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
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.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.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*@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;
|
||||
|
||||
public static void show(String id, String type,FragmentManager fragmentManager) {
|
||||
RechargeDialogFragment dialogFragment = new RechargeDialogFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putString("roomId", id); //// 可选:传递参数
|
||||
args.putString("type", type);
|
||||
dialogFragment.setArguments(args);
|
||||
dialogFragment.show(fragmentManager, "RoomOnlineDialogFragment");
|
||||
}
|
||||
@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");
|
||||
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());
|
||||
}
|
||||
}
|
||||
@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.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
});
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.webkit.JavascriptInterface;
|
||||
import android.webkit.WebSettings;
|
||||
import android.webkit.WebViewClient;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.LogUtils;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.databinding.WebViewDialogBinding;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
import com.tencent.imsdk.v2.V2TIMConversation;
|
||||
import com.tencent.mm.opensdk.modelbiz.WXOpenCustomerServiceChat;
|
||||
import com.tencent.mm.opensdk.openapi.IWXAPI;
|
||||
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
|
||||
import com.tencent.qcloud.tuicore.TUIConstants;
|
||||
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIC2CChatActivity;
|
||||
import com.tencent.qcloud.tuikit.tuichat.classicui.page.TUIGroupChatActivity;
|
||||
|
||||
/**
|
||||
* @Author lxj$
|
||||
* @Time 2025-8-8 09:20:18$ $
|
||||
* @Description 弹窗webview$
|
||||
*/
|
||||
public class WebViewDialog extends BaseDialog<WebViewDialogBinding> {
|
||||
|
||||
String mUrl;
|
||||
|
||||
public WebViewDialog(@NonNull Context context,String url) {
|
||||
super(context, R.style.BaseDialogStyleH);
|
||||
this.mUrl=url;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.web_view_dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView() {
|
||||
setCancelable(false);
|
||||
setCanceledOnTouchOutside(false);
|
||||
Window window = getWindow();
|
||||
assert window != null;
|
||||
window.setGravity(Gravity.BOTTOM);
|
||||
window.setLayout((int) (ScreenUtils.getScreenWidth() * 320.f / 375), WindowManager.LayoutParams.MATCH_PARENT);
|
||||
mBinding.ivClose.setOnClickListener(v -> dismiss());
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
WebSettings webSettings = mBinding.webView.getSettings();
|
||||
webSettings.setUseWideViewPort(true);
|
||||
webSettings.setLoadWithOverviewMode(true);
|
||||
webSettings.setJavaScriptEnabled(true);
|
||||
webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); //关闭webview中缓存
|
||||
//增加JSBridge
|
||||
mBinding.webView.addJavascriptInterface(new WebAppInterface(getContext()), "Android");
|
||||
// mBinding.webView.addJavascriptInterface(new WebViewBridgeConfig(title), WebViewBridgeConfig.NAME);
|
||||
webSettings.setBuiltInZoomControls(false);
|
||||
webSettings.setSupportZoom(false);
|
||||
webSettings.setDomStorageEnabled(true);
|
||||
webSettings.setBlockNetworkImage(false);//解决图片不显示
|
||||
webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
|
||||
webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
|
||||
mBinding.webView.setHorizontalScrollBarEnabled(false);//水平不显示
|
||||
mBinding.webView.setVerticalScrollBarEnabled(false); //垂直不显示
|
||||
mBinding.webView.setWebViewClient(new WebViewClient());
|
||||
mBinding.webView.setBackgroundColor(Color.TRANSPARENT);
|
||||
mBinding.webView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
|
||||
mBinding.webView.requestFocus();
|
||||
mBinding.webView.loadUrl("https://vespa.qxmier.com/web/index.html#/pages/other/taskDesc");
|
||||
}
|
||||
|
||||
private Resources getResources() {
|
||||
return getContext().getResources();
|
||||
}
|
||||
|
||||
public class WebAppInterface {
|
||||
Context mContext;
|
||||
|
||||
WebAppInterface(Context c) {
|
||||
mContext = c;
|
||||
}
|
||||
|
||||
// 被 H5 调用的方法
|
||||
@JavascriptInterface
|
||||
public void showToast(String toast) {
|
||||
Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void closeWeb() {
|
||||
LogUtils.e("value: ");
|
||||
dismiss();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void customerService() {
|
||||
String appId = CommonAppContext.getInstance().getCurrentEnvironment().getWxAppId(); // 填移动应用(App)的 AppId
|
||||
IWXAPI api = WXAPIFactory.createWXAPI(mContext, appId);
|
||||
|
||||
// 判断当前版本是否支持拉起客服会话
|
||||
WXOpenCustomerServiceChat.Req req = new WXOpenCustomerServiceChat.Req();
|
||||
req.corpId = "ww1de4300858c0b461"; // 企业ID
|
||||
req.url = "https://work.weixin.qq.com/kfid/kfcb3d23a59c188a0e7"; // 客服URL
|
||||
api.sendReq(req);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void jumpRoomPage(String room_id) {
|
||||
ARouter.getInstance().build(ARouteConstants.ROOM_DETAILS).withString("form", "首页").withString("roomId", room_id).navigation();
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void jumpWebPage(String objects) {
|
||||
// ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).navigation();
|
||||
ARouter.getInstance().build(ARouteConstants.USER_HOME_PAGE).withString("userId", objects).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void enterGroupChat(String group_id,String cover,String guild_name) {
|
||||
Intent intent = new Intent(mContext, TUIGroupChatActivity.class);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, group_id);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_GROUP);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void chatWithUser(String user_id,String nickname) {
|
||||
Intent intent = new Intent(mContext, TUIC2CChatActivity.class);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_ID, user_id);
|
||||
intent.putExtra(TUIConstants.TUIChat.CHAT_TYPE, V2TIMConversation.V2TIM_C2C);
|
||||
mContext.startActivity(intent);
|
||||
}
|
||||
@JavascriptInterface
|
||||
public void exchange(){
|
||||
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
|
||||
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void Withdrawal() {
|
||||
ARouter.getInstance().build(ARouteConstants.WITHDRAWAL_ACTIVITY).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void enterAuthent() {//实名认证
|
||||
ARouter.getInstance().build(ARouteConstants.REAL_NAME_ACTIVITY2).navigation();
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void Recharge(){
|
||||
ARouter.getInstance().build(ARouteConstants.RECHARGE_ACTIVITY).navigation();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.xscm.moduleutil.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.ScreenUtils;
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.base.CommonAppContext;
|
||||
import com.xscm.moduleutil.bean.TeenagerInfo;
|
||||
import com.xscm.moduleutil.color.ThemeableDrawableUtils;
|
||||
import com.xscm.moduleutil.databinding.IndexDialogYouthModelBinding;
|
||||
import com.xscm.moduleutil.utils.ARouteConstants;
|
||||
import com.xscm.moduleutil.utils.ColorManager;
|
||||
import com.xscm.moduleutil.utils.SpUtil;
|
||||
import com.xscm.moduleutil.widget.dialog.BaseDialog;
|
||||
|
||||
/**
|
||||
* 描述 describe 青少年模式弹窗
|
||||
*/
|
||||
public class YouthModelDialog extends BaseDialog<IndexDialogYouthModelBinding> {
|
||||
private TeenagerInfo teenagerInfo;
|
||||
|
||||
public YouthModelDialog(@NonNull Context context, TeenagerInfo teenagerInfo) {
|
||||
super(context);
|
||||
this.teenagerInfo = teenagerInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLayoutId() {
|
||||
return R.layout.index_dialog_youth_model;
|
||||
}
|
||||
|
||||
@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());
|
||||
mBinding.tvIKnow.setOnClickListener(v -> dismiss());
|
||||
mBinding.tvOpen.setOnClickListener(v -> {
|
||||
// if (teenagerInfo.getHad_password() == 1) {
|
||||
|
||||
// ARouter.getInstance().build(ARouteConstants.SET_YOUTH_PWD_ACTIVITY).withInt("type", SetYouthPasswordActivity.TYPE_OPEN).navigation();
|
||||
// } else {
|
||||
// ARouter.getInstance().build(ARouteConstants.SET_YOUTH_PWD_ACTIVITY).withInt("type", SetYouthPasswordActivity.SET_TYPE).navigation();
|
||||
// }
|
||||
ARouter.getInstance().build(ARouteConstants.H5).withString("url", CommonAppContext.getInstance().getCurrentEnvironment().getH5Url()+ "/web/index.html#/pages/feedback/teenage?id="+ SpUtil.getToken()).navigation();
|
||||
dismiss();
|
||||
});
|
||||
|
||||
ThemeableDrawableUtils.setThemeableRoundedBackground(mBinding.tvIKnow, ColorManager.getInstance().getPrimaryColorInt(), 53);
|
||||
mBinding.tvIKnow.setTextColor(ColorManager.getInstance().getButtonColorInt());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initData() {
|
||||
|
||||
}
|
||||
|
||||
public void setTeenagerInfo(TeenagerInfo teenagerInfo) {
|
||||
this.teenagerInfo = teenagerInfo;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*@author qx
|
||||
*@data 2025/8/25
|
||||
*@description: 盲盒抽奖的实体类
|
||||
*/
|
||||
@Data
|
||||
public class GiftLottery {
|
||||
private String id;
|
||||
private String icon;
|
||||
private String number;
|
||||
private String name;
|
||||
private String price;
|
||||
private boolean isSelected;
|
||||
|
||||
public GiftLottery(String id, String icon, String number, String name, String price, boolean isSelected) {
|
||||
this.id = id;
|
||||
this.icon = icon;
|
||||
this.number = number;
|
||||
this.name = name;
|
||||
this.price = price;
|
||||
this.isSelected = isSelected;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,200 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.animation.AnimatorSet;
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
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.xscm.moduleutil.R;
|
||||
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 RecyclerView.Adapter<GiftLotteryAdapter.ViewHolder> {
|
||||
|
||||
private List<GiftLottery> giftList;
|
||||
private OnGiftClickListener listener;
|
||||
private int currentPos = -1; // 当前正在动画的位置
|
||||
private boolean isForward = true; // 是否正向扫描
|
||||
private int totalItems;
|
||||
|
||||
public GiftLotteryAdapter() {
|
||||
|
||||
}
|
||||
|
||||
public interface OnGiftClickListener {
|
||||
void onGiftClick(GiftLottery item);
|
||||
}
|
||||
|
||||
private RecyclerView recyclerView;
|
||||
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
this.recyclerView = recyclerView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onDetachedFromRecyclerView(recyclerView);
|
||||
this.recyclerView = null;
|
||||
}
|
||||
|
||||
public GiftLotteryAdapter(List<GiftLottery> list, OnGiftClickListener listener) {
|
||||
this.giftList = list;
|
||||
this.listener = listener;
|
||||
this.totalItems = list.size();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.item_gift_lottery, parent, false);
|
||||
return new ViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
|
||||
GiftLottery item = giftList.get(position);
|
||||
holder.bind(item);
|
||||
|
||||
// 设置是否选中(仅用于视觉反馈)
|
||||
if (item.isSelected()) {
|
||||
holder.itemView.setSelected(true);
|
||||
holder.itemView.setBackgroundResource(R.mipmap.ic_auction);
|
||||
} else {
|
||||
holder.itemView.setSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return giftList.size();
|
||||
}
|
||||
|
||||
// 开始扫描动画
|
||||
public void startScanAnimation() {
|
||||
if (totalItems == 0) return;
|
||||
|
||||
currentPos = -1;
|
||||
isForward = true;
|
||||
scanNext();
|
||||
}
|
||||
|
||||
private void scanNext() {
|
||||
if (currentPos >= totalItems) {
|
||||
// 正向结束,开始反向
|
||||
isForward = false;
|
||||
currentPos = totalItems - 1;
|
||||
scanNext();
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentPos < 0) {
|
||||
// 初始状态,开始正向
|
||||
currentPos = 0;
|
||||
animateItem(currentPos);
|
||||
return;
|
||||
}
|
||||
|
||||
// 移动到下一个位置
|
||||
if (isForward) {
|
||||
currentPos++;
|
||||
if (currentPos >= totalItems) {
|
||||
// 正向结束,准备反向
|
||||
isForward = false;
|
||||
currentPos = totalItems - 1;
|
||||
scanNext();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
currentPos--;
|
||||
if (currentPos < 0) {
|
||||
// 反向结束,停止动画
|
||||
finishScan();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 执行动画
|
||||
animateItem(currentPos);
|
||||
}
|
||||
|
||||
private void animateItem(int pos) {
|
||||
View itemView = getViewAtPosition(pos);
|
||||
if (itemView == null) return;
|
||||
|
||||
// 缩放动画
|
||||
AnimatorSet animatorSet = new AnimatorSet();
|
||||
animatorSet.playTogether(
|
||||
ObjectAnimator.ofFloat(itemView, "scaleX", 1f, 1.2f),
|
||||
ObjectAnimator.ofFloat(itemView, "scaleY", 1f, 1.2f)
|
||||
);
|
||||
animatorSet.setDuration(200);
|
||||
animatorSet.setInterpolator(new AccelerateDecelerateInterpolator());
|
||||
animatorSet.start();
|
||||
|
||||
// 延迟下一次动画
|
||||
Handler handler = new Handler(Looper.getMainLooper());
|
||||
handler.postDelayed(() -> {
|
||||
scanNext();
|
||||
}, 300); // 每个 item 动画间隔 300ms
|
||||
}
|
||||
|
||||
private View getViewAtPosition(int position) {
|
||||
if (recyclerView == null || recyclerView.getLayoutManager() == null) {
|
||||
return null;
|
||||
}
|
||||
return recyclerView.getLayoutManager().findViewByPosition(position);
|
||||
}
|
||||
|
||||
private int getBindingAdapterPositionForView(View view) {
|
||||
RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams();
|
||||
return params.getViewLayoutPosition();
|
||||
}
|
||||
|
||||
private void finishScan() {
|
||||
// 扫描完成,随机选择一个中奖项
|
||||
Random random = new Random();
|
||||
int winnerIndex = random.nextInt(totalItems);
|
||||
giftList.get(winnerIndex).setSelected(true);
|
||||
notifyItemChanged(winnerIndex);
|
||||
}
|
||||
|
||||
static class ViewHolder extends RecyclerView.ViewHolder {
|
||||
ImageView imgIcon;
|
||||
TextView tvName, tvCount;
|
||||
|
||||
ViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
imgIcon = itemView.findViewById(R.id.img_gift_icon);
|
||||
tvName = itemView.findViewById(R.id.tv_gift_name);
|
||||
tvCount = itemView.findViewById(R.id.tv_gift_count);
|
||||
}
|
||||
|
||||
void bind(GiftLottery item) {
|
||||
imgIcon.setImageResource(Integer.parseInt(item.getIcon()));
|
||||
tvName.setText(item.getName());
|
||||
tvCount.setText(item.getNumber());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.activity.IView;
|
||||
|
||||
public class GiftLotteryContacts {
|
||||
public interface View extends IView<Activity> {
|
||||
|
||||
}
|
||||
|
||||
public interface IRoomPre extends IPresenter {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.xscm.moduleutil.R;
|
||||
import com.xscm.moduleutil.activity.IPresenter;
|
||||
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
|
||||
import com.xscm.moduleutil.databinding.DialogGiftLotteryBinding;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author qx
|
||||
* @data 2025/8/18
|
||||
* @description: 礼物抽奖
|
||||
*/
|
||||
|
||||
public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresenter, DialogGiftLotteryBinding> implements GiftLotteryContacts.View {
|
||||
|
||||
private int topCount = 4;
|
||||
private int bottomCount = 4;
|
||||
|
||||
@Override
|
||||
protected GiftLotteryPresenter bindPresenter() {
|
||||
return new GiftLotteryPresenter(this, getActivity());
|
||||
}
|
||||
public static GiftLotteryDialog newInstance(int top, int bottom) {
|
||||
GiftLotteryDialog dialog = new GiftLotteryDialog();
|
||||
Bundle args = new Bundle();
|
||||
args.putInt("top", top);
|
||||
args.putInt("bottom", bottom);
|
||||
dialog.setArguments(args);
|
||||
return dialog;
|
||||
}
|
||||
@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 onAttach(@NonNull Context context) {
|
||||
super.onAttach(context);
|
||||
topCount = getArguments().getInt("top");
|
||||
bottomCount = getArguments().getInt("bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initData() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView() {
|
||||
|
||||
mBinding.recyclerGifts.setLayoutManager(new GridLayoutManager(requireContext(), 4));
|
||||
List<GiftLottery> gifts = new ArrayList<>();
|
||||
for (int i = 0; i < topCount + bottomCount; i++) {
|
||||
gifts.add(new GiftLottery(
|
||||
String.valueOf(i),
|
||||
"R.mipmap.ic_launcher",
|
||||
"66666",
|
||||
"柔情似水",
|
||||
"66666",
|
||||
false
|
||||
));
|
||||
} GiftLotteryAdapter adapter = new GiftLotteryAdapter(gifts, new GiftLotteryAdapter.OnGiftClickListener() {
|
||||
|
||||
@Override
|
||||
public void onGiftClick(GiftLottery item) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mBinding.recyclerGifts.setAdapter(adapter);
|
||||
|
||||
// 绑定按钮点击事件
|
||||
mBinding.btnLotteryOnce.setOnClickListener(v -> {
|
||||
adapter.startScanAnimation(); // 启动扫描动画
|
||||
});
|
||||
|
||||
mBinding.btnLotteryTen.setOnClickListener(v -> {
|
||||
// 抽奖10次,每次启动一次扫描
|
||||
for (int i = 0; i < 10; i++) {
|
||||
adapter.startScanAnimation();
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.dialog_gift_lottery;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.xscm.moduleutil.dialog.giftLottery;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.xscm.moduleutil.presenter.BasePresenter;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user