1.修改BUG

2.礼物添加一键全送功能
3.转盘修改底部按钮展示、音效和特效功能
This commit is contained in:
2025-09-09 19:18:06 +08:00
parent 6d3f67e53c
commit c54cc692e0
36 changed files with 917 additions and 528 deletions

View File

@@ -4,27 +4,23 @@ import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.AssetFileDescriptor;
import android.graphics.drawable.Drawable;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.GridView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentManager;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.ToastUtils;
import com.xscm.moduleutil.R;
import com.xscm.moduleutil.activity.IPresenter;
import com.xscm.moduleutil.base.BaseMvpDialogFragment;
import com.xscm.moduleutil.bean.GiftBean;
import com.xscm.moduleutil.bean.RoomMessageEvent;
@@ -35,7 +31,6 @@ import com.xscm.moduleutil.bean.blindboxwheel.XlhDrawBean;
import com.xscm.moduleutil.databinding.DialogGiftLotteryBinding;
import com.xscm.moduleutil.dialog.WebViewDialog;
import com.xscm.moduleutil.event.LotteryEvent;
import com.xscm.moduleutil.http.RetrofitClient;
import com.xscm.moduleutil.utils.ARouteConstants;
import com.xscm.moduleutil.widget.CircularProgressView;
import com.xscm.moduleutil.widget.GiftCardView;
@@ -94,6 +89,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
private GiftLotteryDialogFragment giftLotteryDialogFragment;
private String blind_box_turntable_id = "";//本次抽奖标识id
private BlindBoxBean.XlhData xlhData;
private int icon;//金币金额
@Override
protected GiftLotteryPresenter bindPresenter() {
@@ -310,8 +306,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
int id = view.getId();
if (id == R.id.ll_one) {
if (!isDrawing) {
isDrawing=true;
init(1);
isDrawing = true;
// init(1);
startType = 1;
MvpPre.drawGiftList(giftBagId, userIds, roomId, "1");
} else {
@@ -320,8 +316,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
}
} else if (id == R.id.ll_ten) {
if (!isDrawing) {
isDrawing=true;
init(2);
isDrawing = true;
// init(2);
startType = 2;
MvpPre.drawGiftList(giftBagId, userIds, roomId, "10");
@@ -330,8 +326,8 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
}
} else if (id == R.id.ll_hundred) {//抽奖100次
if (!isDrawing) {
isDrawing=true;
init(3);
isDrawing = true;
// init(3);
startType = 3;
MvpPre.drawGiftList(giftBagId, userIds, roomId, "100");
} else {
@@ -366,23 +362,94 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
giftLotteryDialogFragment = GiftLotteryDialogFragment.newInstance(giftBagId);
giftLotteryDialogFragment.show(getChildFragmentManager(), "GiftLotteryDialogFragment");
}else if (id == R.id.tv_start){
if (xlhData!=null){
if (xlhData.getStatus()==1){
} else if (id == R.id.tv_start) {
if (xlhData != null) {
if (xlhData.getStatus() == 1) {
FragmentManager fm = getParentFragmentManager();
if (fm != null && !fm.isDestroyed()) {
TourClubDialogFragment newDialog = TourClubDialogFragment.newInstance(
roomId);
roomId);
newDialog.show(fm, "TourClubDialogFragment");
}
this.dismissAllowingStateLoss();
}
}
}else if (id == R.id.exchange_layout){
} else if (id == R.id.exchange_layout) {
ARouter.getInstance().build(ARouteConstants.CURRENCY).navigation();
}
}
private void setBackground() {
// 预加载资源
Drawable drawableX = ContextCompat.getDrawable(getContext(), R.mipmap.chou_x);
Drawable drawableW = ContextCompat.getDrawable(getContext(), R.mipmap.chou_w);
if (icon > 0 && box_price > 0) {
if (type == 10) {
updateBackground(mBinding.mirroeSky.llOne, icon > box_price, drawableX, drawableW);
updateBackground(mBinding.mirroeSky.llTen, icon > box_price * 10, drawableX, drawableW);
updateBackground(mBinding.mirroeSky.llHundred, icon > box_price * 100, drawableX, drawableW);
} else if (type == 11) {
updateBackground(mBinding.cityTime.llOne, icon > box_price, drawableX, drawableW);
updateBackground(mBinding.cityTime.llTen, icon > box_price * 10, drawableX, drawableW);
updateBackground(mBinding.cityTime.llHundred, icon > box_price * 100, drawableX, drawableW);
} else if (type == 12) {
updateBackground(mBinding.pinnacleTime.llOne, icon > box_price, drawableX, drawableW);
updateBackground(mBinding.pinnacleTime.llTen, icon > box_price * 10, drawableX, drawableW);
updateBackground(mBinding.pinnacleTime.llHundred, icon > box_price * 100, drawableX, drawableW);
} else {
// 兜底处理:未知 type 时全部设为不可点击 + 默认背景
setAllBackgroundToDefault(drawableW);
}
} else {
// icon 或 box_price <= 0 时全部置灰不可点击
setAllBackgroundToDefault(drawableW);
}
}
private void updateBackground(View view, boolean clickable, Drawable drawableX, Drawable drawableW) {
if (clickable) {
view.setBackground(drawableX);
view.setClickable(true);
} else {
view.setBackground(drawableW);
view.setClickable(false);
}
}
private void setAllBackgroundToDefault(Drawable defaultDrawable) {
switch (type) {
case 10:
mBinding.mirroeSky.llOne.setBackground(defaultDrawable);
mBinding.mirroeSky.llTen.setBackground(defaultDrawable);
mBinding.mirroeSky.llHundred.setBackground(defaultDrawable);
mBinding.mirroeSky.llOne.setClickable(false);
mBinding.mirroeSky.llTen.setClickable(false);
mBinding.mirroeSky.llHundred.setClickable(false);
break;
case 11:
mBinding.cityTime.llOne.setBackground(defaultDrawable);
mBinding.cityTime.llTen.setBackground(defaultDrawable);
mBinding.cityTime.llHundred.setBackground(defaultDrawable);
mBinding.cityTime.llOne.setClickable(false);
mBinding.cityTime.llTen.setClickable(false);
mBinding.cityTime.llHundred.setClickable(false);
break;
case 12:
mBinding.pinnacleTime.llOne.setBackground(defaultDrawable);
mBinding.pinnacleTime.llTen.setBackground(defaultDrawable);
mBinding.pinnacleTime.llHundred.setBackground(defaultDrawable);
mBinding.pinnacleTime.llOne.setClickable(false);
mBinding.pinnacleTime.llTen.setClickable(false);
mBinding.pinnacleTime.llHundred.setClickable(false);
break;
default:
// 忽略未知类型
break;
}
}
private void init(int type) {
if (type == 1) {
mBinding.mirroeSky.llOne.setBackground(getResources().getDrawable(R.mipmap.chou_x));
@@ -515,7 +582,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
finishTargetArrayIndex.add(index);
foundTarget = true;
if (!isOpenSpecial || !isOpenSound) {
playSound("draw.mp3");
playSound("xuanz.mp3");
}
break;
@@ -605,11 +672,12 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
}
private String getRule_url;
private int box_price;//服务器返回的单次抽奖价格
@Override
public void getGiftListSuccess(BlindBoxBean blindBoxBean) {
if (blindBoxBean != null && blindBoxBean.getGift_list() != null) {
box_price = blindBoxBean.getBox_price();
upTitle(blindBoxBean.getBox_price());
giftLists = blindBoxBean.getGift_list();
getRule_url = blindBoxBean.getRule_url();
@@ -647,23 +715,24 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
}
}
}
setBackground();
}
private void upTitle(int boxPrice){
if (type==10){
mBinding.mirroeSky.oneTitle.setText(boxPrice+"币一次");
mBinding.mirroeSky.tenTitle.setText((boxPrice*10)+"币十次");
mBinding.mirroeSky.hundredTitle.setText((boxPrice*100)+"");
}else if (type==11){
mBinding.cityTime.oneTitle.setText(boxPrice+"币一次");
mBinding.cityTime.tenTitle.setText((boxPrice*10)+"币十次");
mBinding.cityTime.hundredTitle.setText((boxPrice*100)+"");
private void upTitle(int boxPrice) {
if (type == 10) {
mBinding.mirroeSky.oneTitle.setText(boxPrice + "币一次");
mBinding.mirroeSky.tenTitle.setText((boxPrice * 10) + "币十次");
mBinding.mirroeSky.hundredTitle.setText((boxPrice * 100) + "");
} else if (type == 11) {
mBinding.cityTime.oneTitle.setText(boxPrice + "币一次");
mBinding.cityTime.tenTitle.setText((boxPrice * 10) + "币十次");
mBinding.cityTime.hundredTitle.setText((boxPrice * 100) + "");
}else if (type==12){
mBinding.pinnacleTime.oneTitle.setText(boxPrice+"币一次");
mBinding.pinnacleTime.tenTitle.setText((boxPrice*10)+"币十次");
mBinding.pinnacleTime.hundredTitle.setText((boxPrice*100)+"");
} else if (type == 12) {
mBinding.pinnacleTime.oneTitle.setText(boxPrice + "币一次");
mBinding.pinnacleTime.tenTitle.setText((boxPrice * 10) + "币十次");
mBinding.pinnacleTime.hundredTitle.setText((boxPrice * 100) + "");
}
}
@@ -713,11 +782,17 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
}
}
@Override
public void drawGiftListSuccess(BlindReslutBean blindReslutBean) {
if (blindReslutBean != null && blindReslutBean.getReslut_list() != null &&
!blindReslutBean.getReslut_list().isEmpty()) {
for (GiftCardView gridView : allViewsArray) {
gridView.setSelected(false);
gridView.stopPulseAnimationWithLayer();
gridView.setVisibilitymResultTextView(false);
}
// 清空之前的数据
targetArrayIndex.clear();
finishTargetArrayIndex.clear();
@@ -739,10 +814,10 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
if (!isOpenSpecial) {
giftCardView.setVisibilitymResultTextView(true);
giftCardView.setSelected(true);
playSound("draw.mp3");
playSound("xuanz.mp3");
// 不要设置isDrawing=true这会影响动画控制
MvpPre.wallet();
isDrawing=false;
isDrawing = false;
MvpPre.giftSend(blind_box_turntable_id);
}
giftCardView.bindGiftData(giftBean);
@@ -775,6 +850,11 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
@Override
public void wallet(WalletBean walletBean) {
if (walletBean != null) {
icon = (int) Double.parseDouble(
(walletBean.getCoin() != null && !walletBean.getCoin().isEmpty())
? walletBean.getCoin()
: "0"
);
if (type == 10) {
mBinding.mirroeSky.tvIcon.setText(walletBean.getCoin());
} else if (type == 11) {
@@ -783,6 +863,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
mBinding.pinnacleTime.tvIcon.setText(walletBean.getCoin());
}
}
setBackground();
}
@@ -793,11 +874,11 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
// TODO: 2025/8/29 接收im推送过来的消息
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMusicPlay(RoomMessageEvent message) {
if (message.getMsgType() == 1056){
public void onMusicPlay(RoomMessageEvent message) {
if (message.getMsgType() == 1056) {
UpView(message.getText().getXlh_data());
}
}
}
@Override
public void onDestroyView() {
@@ -855,7 +936,7 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment<GiftLotteryPresente
player.release();
player = null;
}
if (!EventBus.getDefault().isRegistered( this)){
if (!EventBus.getDefault().isRegistered(this)) {
EventBus.getDefault().unregister(this);
}
// 建议进行垃圾回收