diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/GiftBean.java b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/GiftBean.java index 345f8fe..493d022 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/GiftBean.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/GiftBean.java @@ -1,7 +1,11 @@ package com.xscm.moduleutil.bean; import lombok.Data; - +/** + *@author qx + *@data 2025/8/27 + *@description: 推送过来的礼物信息,复用在盲盒活动获取礼物信息中 + */ @Data public class GiftBean { @@ -12,4 +16,5 @@ public class GiftBean { private String play_image; private String base_image; private String gift_type; + private int number; } diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/RoomMessageEvent1.java b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/RoomMessageEvent1.java deleted file mode 100644 index 97145f8..0000000 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/RoomMessageEvent1.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.xscm.moduleutil.bean; - -import lombok.Data; -@Data -public class RoomMessageEvent1 { - private int MsgType; // 消息类型,如 QXRoomMessageTypeJoin - private String RoomId; // 房间 ID - private RoomMessageEvent.T Text; // 携带的数据对象 - - public RoomMessageEvent1(int msgType, String roomId, RoomMessageEvent.T text) { - MsgType = msgType; - RoomId = roomId; - Text = text; - } - - - @Data - public static class T { - private String text; - private String GiftNum; - - private UserInfo FromUserInfo; - private UserInfo ToUserInfo; - private GiftBean GiftInfo; - } -} diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/RoonGiftModel.java b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/RoonGiftModel.java index 4a0a49e..8465e09 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/RoonGiftModel.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/RoonGiftModel.java @@ -31,7 +31,8 @@ public class RoonGiftModel { private boolean isSelected; private boolean can_send_self;//是否能送自己 private int num;//礼物数量 - + private int activities_id;//4:盲盒 ;5:天空之境; + private int gift_bag; public boolean isCan_send_self() { if ( isManghe()) { return true; diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/blindboxwheel/BlindBoxBean.java b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/blindboxwheel/BlindBoxBean.java new file mode 100644 index 0000000..c885ba2 --- /dev/null +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/blindboxwheel/BlindBoxBean.java @@ -0,0 +1,31 @@ +package com.xscm.moduleutil.bean.blindboxwheel; + +import com.xscm.moduleutil.bean.GiftBean; + +import java.util.List; + +import lombok.Data; + +/** + *@author qx + *@data 2025/8/27 + *@description: 获取活动礼物列表 + */ +@Data +public class BlindBoxBean { + private String title; + private String rule_url; + private String rule; + private String box_price ; + private int is_xlh; ///是否开启巡乐会 0 关闭 1 开启 + private XlhData xlh_data; + private List gift_list; + + @Data + public class XlhData{ + private String waiting_start_num;//等待开始需要达到的次数 + private String start_num;//巡乐会开启需要达到的次数 + private int current_num;//当前已抽奖次数 + private int status; + } +} diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/bean/blindboxwheel/BlindReslutBean.java b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/blindboxwheel/BlindReslutBean.java new file mode 100644 index 0000000..f59d487 --- /dev/null +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/bean/blindboxwheel/BlindReslutBean.java @@ -0,0 +1,23 @@ +package com.xscm.moduleutil.bean.blindboxwheel; + +import java.util.List; + +import lombok.Data; + +/** + * @author qx + * @data 2025/8/27 + * @description: 礼物抽奖结果 + */ +@Data +public class BlindReslutBean { + private String blind_box_turntable_id;//本次抽奖标识 Id 效果完成后用这个值推送发放 + private List reslut_list; + + @Data + public class ReslutList { + private int gift_id;//中奖礼物Id + private int count;//中奖礼物数量 + } + +} diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryContacts.java b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryContacts.java index 3cf4e23..44cd5cc 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryContacts.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryContacts.java @@ -4,13 +4,19 @@ import android.app.Activity; import com.xscm.moduleutil.activity.IPresenter; import com.xscm.moduleutil.activity.IView; +import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean; +import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean; public class GiftLotteryContacts { public interface View extends IView { + void getGiftListSuccess(BlindBoxBean blindBoxBean); + void drawGiftListSuccess(BlindReslutBean blindReslutBean); } public interface IRoomPre extends IPresenter { + void getGiftList(String giftBagId,String roomId); + void drawGiftList(String giftBagId,String gift_user_ids,String roomId,String num); } } diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryDialog.java b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryDialog.java index 643902b..f6c8985 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryDialog.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/dialog/giftLottery/GiftLotteryDialog.java @@ -2,7 +2,10 @@ package com.xscm.moduleutil.dialog.giftLottery; import android.app.Dialog; import android.content.Context; +import android.content.DialogInterface; import android.os.Bundle; +import android.os.Handler; +import android.os.Looper; import android.view.View; import android.view.Window; @@ -11,10 +14,16 @@ import androidx.annotation.Nullable; import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.RecyclerView; +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.blindboxwheel.BlindBoxBean; +import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean; import com.xscm.moduleutil.databinding.DialogGiftLotteryBinding; +import com.xscm.moduleutil.http.RetrofitClient; +import com.xscm.moduleutil.widget.GiftCardView; import java.util.ArrayList; import java.util.List; @@ -22,23 +31,51 @@ import java.util.List; /** * @author qx * @data 2025/8/18 - * @description: 礼物抽奖 + * @description: 天空之境礼物抽奖 */ public class GiftLotteryDialog extends BaseMvpDialogFragment implements GiftLotteryContacts.View { - private int topCount = 4; - private int bottomCount = 4; + private String giftBagId; + private String roomId; + private String userIds; + + ///共有12个礼物 + private int giftMaxCount = 12; + ///最少转6圈 + private int minRoundCount = 6; + ///距离4个的时候放慢 + private int toSlowCount = 4; + + private List allViewsArray=new ArrayList<>() ;//视图的集合 + private int targetIndex;//目标的下标 + private List targetArrayIndex=new ArrayList<>();//中奖的下标 + private List finishTargetArrayIndex=new ArrayList<>(); + private int currentIndex;///当前转到第几个下标 + private int roundCount;//转动多少次 + private double delayTime;//延时 + + private GiftCardView currentGiftCardView; + private boolean isDrawing;//是否正在抽奖 + private boolean isOpenSound;//是否开启音效 + private boolean isOpenSpecial;//是否开启特效 + + private Handler handler; + private Runnable timerRunnable;//定时器 + private int startType;//类型,点击的事抽奖1次还是10次还是100次 + + private List giftLists=new ArrayList<>(); @Override protected GiftLotteryPresenter bindPresenter() { return new GiftLotteryPresenter(this, getActivity()); } - public static GiftLotteryDialog newInstance(int top, int bottom) { + public static GiftLotteryDialog newInstance(String giftBagId,String roomId,String userIds) { GiftLotteryDialog dialog = new GiftLotteryDialog(); Bundle args = new Bundle(); - args.putInt("top", top); - args.putInt("bottom", bottom); + args.putString("giftBagId", giftBagId); + args.putString("roomId", roomId); + args.putString("userIds", userIds); dialog.setArguments(args); return dialog; } @@ -53,58 +90,357 @@ public class GiftLotteryDialog extends BaseMvpDialogFragment getTargetArrayIndex() { + if (targetArrayIndex == null) { + targetArrayIndex = new ArrayList<>(); + } + return targetArrayIndex; + } + + private List getFinishTargetArrayIndex() { + if (finishTargetArrayIndex == null) { + finishTargetArrayIndex = new ArrayList<>(); + } + return finishTargetArrayIndex; } @Override protected void initView() { - mBinding.recyclerGifts.setLayoutManager(new GridLayoutManager(requireContext(), 4)); - List 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() { + allViewsArray.add(mBinding.gift1); + allViewsArray.add(mBinding.gift2); + allViewsArray.add(mBinding.gift3); + allViewsArray.add(mBinding.gift4); + allViewsArray.add(mBinding.gift5); + allViewsArray.add(mBinding.gift6); + allViewsArray.add(mBinding.gift7); + allViewsArray.add(mBinding.gift8); + allViewsArray.add(mBinding.gift9); + allViewsArray.add(mBinding.gift10); + allViewsArray.add(mBinding.gift11); + allViewsArray.add(mBinding.gift12); + mBinding.llOne.setOnClickListener(this::onClisk); + mBinding.llTen.setOnClickListener(this::onClisk); + mBinding.llHundred.setOnClickListener(this::onClisk); + mBinding.swLockYx.setOnClickListener(this::onClisk); + mBinding.swTex.setOnClickListener(this::onClisk); + init(0); + mBinding.swLockYx.setChecked(true); + mBinding.swTex.setChecked(true); + isOpenSpecial=true; + } + + private void onClisk(View view) { + int id = view.getId(); + if (id == R.id.ll_one){ + if (!isDrawing) { + init(1); + startType = 1; + MvpPre.drawGiftList(giftBagId, userIds, roomId, "1"); + }else { + com.hjq.toast.ToastUtils.show("正在抽奖中..."); + return; + } + }else if (id == R.id.ll_ten){ + if (!isDrawing) { + init(2); + startType = 2; + MvpPre.drawGiftList(giftBagId, userIds, roomId, "10"); + }else { + com.hjq.toast.ToastUtils.show("正在抽奖中..."); + } + }else if (id == R.id.ll_hundred){ + if (!isDrawing) { + init(3); + startType = 3; + MvpPre.drawGiftList(giftBagId, userIds, roomId, "100"); + }else { + com.hjq.toast.ToastUtils.show("正在抽奖中..."); + } + }else if (id == R.id.sw_lock_yx){ + isOpenSpecial=mBinding.swLockYx.isChecked(); + }else if (id == R.id.sw_tex){ + isOpenSpecial=mBinding.swTex.isChecked(); + } + } + + private void init(int type) { + if (type == 1) { + mBinding.llOne.setBackground(getResources().getDrawable(R.mipmap.chou_x)); + mBinding.llTen.setBackground(getResources().getDrawable(R.mipmap.chou_w)); + mBinding.llHundred.setBackground(getResources().getDrawable(R.mipmap.chou_w)); + } else if (type == 2) { + mBinding.llOne.setBackground(getResources().getDrawable(R.mipmap.chou_w)); + mBinding.llTen.setBackground(getResources().getDrawable(R.mipmap.chou_x)); + mBinding.llHundred.setBackground(getResources().getDrawable(R.mipmap.chou_w)); + } else if (type == 3) { + mBinding.llOne.setBackground(getResources().getDrawable(R.mipmap.chou_w)); + mBinding.llTen.setBackground(getResources().getDrawable(R.mipmap.chou_w)); + mBinding.llHundred.setBackground(getResources().getDrawable(R.mipmap.chou_x)); + }else { + mBinding.llOne.setBackground(getResources().getDrawable(R.mipmap.chou_w)); + mBinding.llTen.setBackground(getResources().getDrawable(R.mipmap.chou_w)); + mBinding.llHundred.setBackground(getResources().getDrawable(R.mipmap.chou_w)); + } + } + ///定时器 + public void startFastAnimate() { + if (allViewsArray.isEmpty()) { + return; + } + currentGiftCardView = allViewsArray.get(0); + currentGiftCardView.setSelected(true); + + // 停止之前的定时器 + stopFastAnimate(); + + if (isOpenSound) { + // 假设此处有播放音乐的逻辑 + // player.seekTo(0); + // player.start(); + } + + roundCount = 0; + delayTime = 0.2; + handler = new Handler(Looper.getMainLooper()); + + timerRunnable = new Runnable() { @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(); + public void run() { + roundCount++; + if ((roundCount / giftMaxCount == minRoundCount) && startType != 0) { + boolean has = false; + for (int index : finishTargetArrayIndex) { + if (index == currentIndex) { + has = true; + break; + } + } + currentGiftCardView.setSelected(false); + GiftCardView giftView = allViewsArray.get(currentIndex); + if (has) { + giftView.setSelected(true); + } else { + giftView.setSelected(false); + } + } else { + currentGiftCardView.setSelected(false); } + + currentIndex = roundCount % giftMaxCount; + GiftCardView giftView = allViewsArray.get(currentIndex); + giftView.setSelected(true); + currentGiftCardView = giftView; + + if (roundCount / giftMaxCount == minRoundCount) { + for (int i = 0; i < targetArrayIndex.size(); i++) { + int index = targetArrayIndex.get(i); + if (currentIndex == index) { + GiftCardView targetGiftView = allViewsArray.get(index); + targetGiftView.setSelected(true); + targetGiftView.setVisibilitymResultTextView(true); + targetGiftView.startPulseAnimationWithLayer(); + targetArrayIndex.remove(i); + finishTargetArrayIndex.add(index); + break; + } + } + delayTime = 0.03; + if (targetArrayIndex.size()==0) { + isDrawing = false; + stopFastAnimate(); + } + } else { + delayTime = delayTime - 0.02; + if (delayTime <= 0.03) { + delayTime = 0.03; + } + } + + // 重新调度任务 + handler.postDelayed(this, (long) (delayTime * 1000)); } - }); + }; + + // 启动定时器 + handler.postDelayed(timerRunnable, (long) (0.2 * 1000)); + } + + public void stopFastAnimate() { + if (handler != null && timerRunnable != null) { + + handler.removeCallbacks(timerRunnable); + timerRunnable=null; + } } @Override protected int getLayoutId() { return R.layout.dialog_gift_lottery; } + + @Override + public void getGiftListSuccess(BlindBoxBean blindBoxBean) { + if (blindBoxBean != null && blindBoxBean.getGift_list() != null) { + giftLists = blindBoxBean.getGift_list(); + + // 确保数据数量不超过视图数量 + int size = Math.min(giftLists.size(), allViewsArray.size()); + + // 一对一绑定数据到视图 + for (int i = 0; i < size; i++) { + GiftCardView giftCardView = allViewsArray.get(i); + GiftBean giftBean = giftLists.get(i); + giftCardView.bindGiftData(giftBean); + } + + // 如果礼物数量少于视图数量,隐藏多余的视图 + for (int i = size; i < allViewsArray.size(); i++) { + allViewsArray.get(i).setVisibility(View.GONE); + } + } + } + + @Override + public void drawGiftListSuccess(BlindReslutBean blindReslutBean) { + if (blindReslutBean!=null || !blindReslutBean.getReslut_list().isEmpty()){ + for (int i=0;i 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() { + @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) { + api.drawGiftList(giftBagId, gift_user_ids, roomId, num, new BaseObserver() { + + @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); + } + }); + } } diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/http/ApiServer.java b/moduleUtil/src/main/java/com/xscm/moduleutil/http/ApiServer.java index c3c0397..8d2fbb1 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/http/ApiServer.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/http/ApiServer.java @@ -55,6 +55,8 @@ import com.xscm.moduleutil.bean.UserTagBean; import com.xscm.moduleutil.bean.WalletBean; import com.xscm.moduleutil.bean.WalletConfig; import com.xscm.moduleutil.bean.WithdrawalBean; +import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean; +import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean; import com.xscm.moduleutil.bean.room.AuctionBean; import com.xscm.moduleutil.bean.room.FriendUserBean; import com.xscm.moduleutil.bean.room.RoomApplyListBean; @@ -86,12 +88,14 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.LOGIN) Observable>> login(@Field("user_login") String user_login, @Field("sms_code") String sms_code); + @FormUrlEncoded //手机换绑 @POST(Constants.MODIFY_MOBILE) - Call> mobileView(@Field("mobile") String mobile, @Field("new_mobile") String new_mobile,@Field("sms_code") String sms_code); + Call> mobileView(@Field("mobile") String mobile, @Field("new_mobile") String new_mobile, @Field("sms_code") String sms_code); + @FormUrlEncoded //手机绑定 @POST(Constants.BIND_MOBILE) - Call> mobileView2( @Field("new_mobile") String new_mobile,@Field("sms_code") String sms_code); + Call> mobileView2(@Field("new_mobile") String new_mobile, @Field("sms_code") String sms_code); @FormUrlEncoded @POST(Constants.USER_LOGIN) @@ -135,7 +139,7 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.POST_USER_WALL) - Observable> giftWall(@Field("user_id")String userId); + Observable> giftWall(@Field("user_id") String userId); @GET(Constants.CURRENT_HEADLINE) Observable> currentHeadline(); @@ -159,7 +163,7 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.POST_MESSAGE_LIST) - Observable>> getMessagetitle(@Field("type")String type, @Field("page")String page, @Field("page_limit")String page_limit); + Observable>> getMessagetitle(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit); @FormUrlEncoded @POST(Constants.POST_ROOM_RANK) @@ -259,7 +263,7 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.GET_EXPAND_COLUMN) - Observable>> getExpandColumn(@Field("type") String type,@Field("page") String page, @Field("page_limit") String page_limit); + Observable>> getExpandColumn(@Field("type") String type, @Field("page") String page, @Field("page_limit") String page_limit); @GET(Constants.GET_OFFICIAL_NOTICE) Observable> getOfficialNotice(); @@ -290,6 +294,7 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.POST_BLACK_LIST) Observable>> getBlacklist(@Field("page") String page, @Field("page_limit") String page_limit); + @FormUrlEncoded @POST(Constants.POST_LOCK_MI_LIST) Observable>> getLockMiniList(@Field("page") String page, @Field("page_limit") String page_limit); @@ -435,7 +440,7 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.POST_CLEAR_USER_CHARM) - Call> clearUserCharm(@Field("room_id") String roomId,@Field("user_id") String userId); + Call> clearUserCharm(@Field("room_id") String roomId, @Field("user_id") String userId); @FormUrlEncoded @POST(Constants.REMOVE_BLACK_LIST) @@ -443,7 +448,7 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.POST_USER_OLINE_STATUS) - Call>> userOnlineStatus(@Field("user_id") String userId,@Field("room_id")String roomId); + Call>> userOnlineStatus(@Field("user_id") String userId, @Field("room_id") String roomId); @FormUrlEncoded @POST(Constants.postRoomSwToken) @@ -500,7 +505,7 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.GET_ROOM_GIFT) - Call> roomGift(@Field("room_id") String room_id, @Field("gift_id") String gift_id, @Field("gift_num") String num, @Field("to_uid") String to_uid, @Field("type") String gift_type, @Field("pit_number") String pit_number,@Field("heart_id")String heat_id); + Call> roomGift(@Field("room_id") String room_id, @Field("gift_id") String gift_id, @Field("gift_num") String num, @Field("to_uid") String to_uid, @Field("type") String gift_type, @Field("pit_number") String pit_number, @Field("heart_id") String heat_id); @GET(Constants.GET_FIRST_CHARGE_GIFT) Observable> firstChargeGift(); @@ -542,16 +547,18 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.START_FRIEND) Call> startFriend(@Field("room_id") String room_id); + @FormUrlEncoded @POST(Constants.END_FRIEND) Call> endFriend(@Field("friend_id") String friend_id, @Field("room_id") String room_id); + @FormUrlEncoded @POST(Constants.CREATE_RELATION) - Call> createRelation( @Field("room_id") String room_id,@Field("friend_id") String friend_id,@Field("user1_id") String user1_id,@Field("user2_id") String user2_id,@Field("relation_id") String relation_id); + Call> createRelation(@Field("room_id") String room_id, @Field("friend_id") String friend_id, @Field("user1_id") String user1_id, @Field("user2_id") String user2_id, @Field("relation_id") String relation_id); @FormUrlEncoded @POST(Constants.DELAY) - Call> delay(@Field("friend_id")String friend_id, @Field("room_id") String room_id,@Field("delay_times")String delay_times); + Call> delay(@Field("friend_id") String friend_id, @Field("room_id") String room_id, @Field("delay_times") String delay_times); @FormUrlEncoded @POST(Constants.DOWN_PIT) @@ -648,7 +655,7 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.POST_GIVE_COIN) - Call> giveCoin(@Field("user_id") String user_id,@Field("coin") String coin); + Call> giveCoin(@Field("user_id") String user_id, @Field("coin") String coin); @FormUrlEncoded @POST(Constants.POST_SET_MUTE_PIT) @@ -663,7 +670,7 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.POST_CHARM_LIST) - Observable> getCharmList(@Field("room_id") String room_id, @Field("start_time") String start_time, @Field("end_time") String end_time,@Field("page") String page); + Observable> getCharmList(@Field("room_id") String room_id, @Field("start_time") String start_time, @Field("end_time") String end_time, @Field("page") String page); @FormUrlEncoded @POST(Constants.POST_SET_UPLOAD_BG_IMG) @@ -675,7 +682,7 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.POST_AUCTION_END) - Call> auctionEnd(@Field("auction_id") String auction_id,@Field("room_id") String room_id); + Call> auctionEnd(@Field("auction_id") String auction_id, @Field("room_id") String room_id); @FormUrlEncoded @POST(Constants.POST_AUCTION_MODE) @@ -723,4 +730,11 @@ public interface ApiServer { @FormUrlEncoded @POST(Constants.POST_SEARCH_PK_ROOM) Observable>> searchPkRoom(@Field("room_id") String room_id, @Field("page") String page, @Field("limit") String limit); + + @GET(Constants.GET_BOX_GIFT_LIST) + Call> getBoxGiftList(@Query("gift_bag_id") String gift_bag_id, @Query("room_id") String room_id); + + @FormUrlEncoded + @POST(Constants.POST_DRAW_GIFT_LIST) + Call> drawGiftList(@Field("gift_bag_id") String gift_bag_id, @Field("gift_user_ids") String gift_user_ids,@Field("room_id")String room_id,@Field("num")String num); } diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/http/RetrofitClient.java b/moduleUtil/src/main/java/com/xscm/moduleutil/http/RetrofitClient.java index a6940f5..95435a3 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/http/RetrofitClient.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/http/RetrofitClient.java @@ -72,6 +72,8 @@ import com.xscm.moduleutil.bean.UserTagBean; import com.xscm.moduleutil.bean.WalletBean; import com.xscm.moduleutil.bean.WalletConfig; import com.xscm.moduleutil.bean.WithdrawalBean; +import com.xscm.moduleutil.bean.blindboxwheel.BlindBoxBean; +import com.xscm.moduleutil.bean.blindboxwheel.BlindReslutBean; import com.xscm.moduleutil.bean.room.AuctionBean; import com.xscm.moduleutil.bean.room.FriendUserBean; import com.xscm.moduleutil.bean.room.RoomApplyListBean; @@ -103,6 +105,7 @@ import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; +import io.reactivex.disposables.Disposable; import okhttp3.Cache; import okhttp3.OkHttpClient; import okhttp3.ResponseBody; @@ -2204,5 +2207,39 @@ public class RetrofitClient { } } + ///获取活动礼物列表 + public void getBoxGiftList(String giftBagId, String roomId, BaseObserver observer){ + sApiServer.getBoxGiftList(giftBagId, roomId).enqueue(new Callback>() { + @Override + public void onResponse(Call> call, Response> response) { + if (response.code() == 200) { + BaseModel baseModel = response.body(); + observer.onNext(baseModel.getData()); + } + } + + @Override + public void onFailure(Call> call, Throwable t) { + t.printStackTrace(); + } + }); + } + ///盲盒转盘抽奖 + public void drawGiftList(String giftBagId, String gift_user_ids, String roomId, String num,BaseObserver observer){ + sApiServer.drawGiftList(giftBagId, gift_user_ids, roomId, num).enqueue(new Callback>() { + @Override + public void onResponse(Call> call, Response> response) { + if (response.code() == 200) { + BaseModel baseModel = response.body(); + observer.onNext(baseModel.getData()); + } + } + + @Override + public void onFailure(Call> call, Throwable t) { + t.printStackTrace(); + } + }); + } } diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/utils/config/EnvironmentEnum.java b/moduleUtil/src/main/java/com/xscm/moduleutil/utils/config/EnvironmentEnum.java index 3951ea9..afc09fb 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/utils/config/EnvironmentEnum.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/utils/config/EnvironmentEnum.java @@ -15,7 +15,7 @@ public enum EnvironmentEnum { "tcp://81.70.45.221", "https://vespa.qxmier.com"), TEST(//测试环境 - "http://tmd.qixing2.top/", + "http://md.qxmier.com/", "6rdWuz058oq5OahdbFiGEybUcdahd12J83L34Uc7MrPIrxtFG+rXiwDvRcqNvjwbClbbmvMrmxKVkIysFByBsl0Qe9kqd2w8T/nhK5G6eXXlk2V9AjYCieIU+jRnjZBB+Cfechr6rCGJ2aeBARIsXcRPW7wm9WFK9euh5T+v6Pyte68yNaNdcYCll3+U4/uCEog7HygCnMIbAU+kqoPdmn2H+51YOHW+VsnsHd4w1+I3f8Tt0xLIXGM4GWnQueZ5GR46GTWiSYMy8dCIh9SPIMRyC91GosVcfGPMJSdcXqc=", "https://oss-cn-hangzhou.aliyuncs.com/", "LTAI5tJ2UYfFNF7K3F4e1siv", diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/AvatarFrameView.java b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/AvatarFrameView.java index 9bdd74c..e549d7f 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/AvatarFrameView.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/AvatarFrameView.java @@ -103,9 +103,33 @@ public class AvatarFrameView extends FrameLayout implements IAnimListener { } else { isPlaying = false; // playNextFromQueue(); // 播放下一项 + // 播放完成后立即清理当前资源 + clearCurrentResource(); mainHandler.postDelayed(this::playNextFromQueue, 50); } } + + private void clearCurrentResource() { + // 清理当前播放的文件引用 +// mFile = null; + + // 清理SVGA资源 + if (svgaSurface != null) { + svgaSurface.stopAnimation(); + svgaSurface.clearAnimation(); + svgaSurface.setImageDrawable(null); + } + + // 清理MP4资源 + if (exoPlayer != null) { + exoPlayer.stop(); + exoPlayer.clearVideoSurface(); + } + + if (mBinding != null && mBinding.playView != null) { + mBinding.playView.stopPlay(); + } + } @Override public void onVideoDestroy() { diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/Constants.java b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/Constants.java index a5c20a2..b566a5e 100644 --- a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/Constants.java +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/Constants.java @@ -374,6 +374,8 @@ public class Constants { public static final String DELAY = "/api/Friend/delay";//点击延时 交友房 public static final String END_FRIEND = "/api/Friend/end_friend";//点击结束 交友房 public static final String CREATE_RELATION = "/api/Friend/create_relation";//卡关系 (创建关系) 交友房 + public static final String GET_BOX_GIFT_LIST = "/api/BlindBoxTurntable/get_gift_list";//获取活动礼物列表 + public static final String POST_DRAW_GIFT_LIST = "/api/BlindBoxTurntable/draw_gift";//盲盒转盘抽奖 diff --git a/moduleUtil/src/main/java/com/xscm/moduleutil/widget/GiftCardView.java b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/GiftCardView.java new file mode 100644 index 0000000..49313e2 --- /dev/null +++ b/moduleUtil/src/main/java/com/xscm/moduleutil/widget/GiftCardView.java @@ -0,0 +1,291 @@ +package com.xscm.moduleutil.widget; + +import android.animation.ObjectAnimator; +import android.content.Context; +import android.content.res.TypedArray; +import android.graphics.Color; +import android.graphics.drawable.Drawable; +import android.graphics.drawable.GradientDrawable; +import android.graphics.drawable.LayerDrawable; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.FrameLayout; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.core.content.ContextCompat; + +import com.google.android.material.card.MaterialCardView; +import com.xscm.moduleutil.R; +import com.xscm.moduleutil.bean.GiftBean; +import com.xscm.moduleutil.utils.ImageUtils; + +/** + * 礼物卡片控件 - 支持选中效果和自定义样式 + */ +public class GiftCardView extends FrameLayout { + + private ImageView mIconImageView; + private TextView mNameTextView; + private TextView mCountTextView; + private TextView mResultTextView; + + private boolean isSelected = false; + private Drawable selectedBackground; + private Drawable normalBackground; + + // 添加GiftBean数据引用 + private GiftBean giftBean; + + private ObjectAnimator pulseAnimator; + + public GiftCardView(Context context) { + this(context, null); + } + + public GiftCardView(Context context, AttributeSet attrs) { + this(context, attrs, 0); + } + + public GiftCardView(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + initViews(); + initAttributes(attrs); + } + + private void initViews() { + LayoutInflater.from(getContext()).inflate(R.layout.view_gift_card, this, true); + + mIconImageView = findViewById(R.id.img_gift_icon); + mNameTextView = findViewById(R.id.tv_gift_name); + mCountTextView = findViewById(R.id.tv_gift_count); + mResultTextView= findViewById(R.id.result); + + // 设置默认点击事件 + setOnClickListener(v -> { + if (getOnGiftClickListener() != null) { + getOnGiftClickListener().onGiftClick(this); + } + }); + } + + private void initAttributes(AttributeSet attrs) { + TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.GiftCardView); + + try { + // 获取自定义属性 + String name = typedArray.getString(R.styleable.GiftCardView_giftName); + String count = typedArray.getString(R.styleable.GiftCardView_giftCount); + int iconResId = typedArray.getResourceId(R.styleable.GiftCardView_giftIcon, 0); + + // 设置默认值 + if (name != null) { + setName(name); + } + if (count != null) { + setCount(count); + } + if (iconResId != 0) { + setIcon(""); + } + + // 获取选中状态相关属性 + selectedBackground = typedArray.getDrawable(R.styleable.GiftCardView_selectedBackground); + normalBackground = typedArray.getDrawable(R.styleable.GiftCardView_normalBackground); + + // 如果没有设置选中背景,则使用默认的选中效果 + if (selectedBackground == null) { + selectedBackground = ContextCompat.getDrawable(getContext(), R.mipmap.tkzj_x); + } + if (normalBackground == null) { + normalBackground = ContextCompat.getDrawable(getContext(), R.mipmap.tkzj_w); + } + + // 设置默认背景 + if (normalBackground != null) { + setBackground(normalBackground); + } + + } finally { + typedArray.recycle(); + } + } + /** + * 绑定GiftBean数据 + */ + public void bindGiftData(GiftBean giftBean) { + this.giftBean = giftBean; + + if (giftBean != null) { + // 设置礼物图标 + if (giftBean.getBase_image() != null && !giftBean.getBase_image().isEmpty()) { + setIcon(giftBean.getBase_image()); + // 如果是资源ID + + } else { + setIcon(""); + } + + // 设置礼物名称 + setName(giftBean.getGift_name() != null ? giftBean.getGift_name() : "未知礼物"); + + // 设置礼物数量 + setCount(giftBean.getGift_price() != null ? giftBean.getGift_price() : "0"); + setmResultTextView(giftBean.getNumber()); + } + } + + /** + * 获取绑定的GiftBean数据 + */ + public GiftBean getGiftBean() { + return giftBean; + } + /** + * 设置礼物图标(URL) + */ + public void setIcon(String url) { + if (mIconImageView != null) { + if (url != null && !url.isEmpty()) { + ImageUtils.loadHeadCC(url, mIconImageView); + } else { + mIconImageView.setImageResource(R.mipmap.ic_launcher); + } + } + } + + public void startPulseAnimationWithLayer() { + if (pulseAnimator != null && pulseAnimator.isRunning()) { + pulseAnimator.cancel(); + } + pulseAnimator = ObjectAnimator.ofFloat(this, "scaleX", 0.9f, 1.1f); + pulseAnimator.setDuration(500); + pulseAnimator.setRepeatCount(ObjectAnimator.INFINITE); + pulseAnimator.setRepeatMode(ObjectAnimator.REVERSE); + ObjectAnimator scaleYAnimator = ObjectAnimator.ofFloat(this, "scaleY", 0.9f, 1.1f); + scaleYAnimator.setDuration(500); + scaleYAnimator.setRepeatCount(ObjectAnimator.INFINITE); + scaleYAnimator.setRepeatMode(ObjectAnimator.REVERSE); + + // 组合动画 + android.animation.AnimatorSet animatorSet = new android.animation.AnimatorSet(); + animatorSet.playTogether(pulseAnimator, scaleYAnimator); + animatorSet.start(); + } + + public void stopPulseAnimationWithLayer() { + if (pulseAnimator != null) { + pulseAnimator.cancel(); + } + this.setScaleX(1f); + this.setScaleY(1f); + } + /** + * 设置礼物名称 + */ + public void setName(String name) { + if (mNameTextView != null) { + mNameTextView.setText(name); + } + } + + /** + * 设置礼物数量 + */ + public void setCount(String count) { + if (mCountTextView != null) { + mCountTextView.setText(count); + } + } + + /** + * 设置选中状态 + */ + public void setSelected(boolean selected) { + isSelected = selected; + + if (selected) { + setBackground(selectedBackground); + // 可以添加额外的选中效果 + setElevation(8f); // 提高阴影 + // 添加发光效果 + addGlowEffect(); + } else { + setBackground(normalBackground); + setElevation(4f); // 恢复默认阴影 + removeGlowEffect(); + } + } + + public void setmResultTextView(int num){ + if (mResultTextView!=null) { + mResultTextView.setText("X" + num); + } + } + + public void setVisibilitymResultTextView(boolean isVisible){ + if (mResultTextView!=null) { + mResultTextView.setVisibility(isVisible?View.VISIBLE:View.GONE); + } + } + + /** + * 添加发光效果 + */ + private void addGlowEffect() { + // 使用LayerDrawable创建发光效果 + GradientDrawable glow = new GradientDrawable(); + glow.setColor(Color.TRANSPARENT); + glow.setStroke(8, Color.argb(150, 255, 255, 255)); + glow.setCornerRadius(16f); + + LayerDrawable layerDrawable = new LayerDrawable(new Drawable[]{glow, getBackground()}); + setBackground(layerDrawable); + } + + /** + * 移除发光效果 + */ + private void removeGlowEffect() { + setBackground(normalBackground); + } + + /** + * 获取当前是否选中 + */ + public boolean isSelected() { + return isSelected; + } + + /** + * 切换选中状态 + */ + public void toggleSelected() { + setSelected(!isSelected); + } + + /** + * 设置点击监听器 + */ + public void setOnGiftClickListener(OnGiftClickListener listener) { + this.onGiftClickListener = listener; + } + + /** + * 获取点击监听器 + */ + public OnGiftClickListener getOnGiftClickListener() { + return onGiftClickListener; + } + + /** + * 点击监听器接口 + */ + public interface OnGiftClickListener { + void onGiftClick(GiftCardView giftCardView); + } + + private OnGiftClickListener onGiftClickListener; +} + diff --git a/moduleUtil/src/main/res/layout/dialog_gift_lottery.xml b/moduleUtil/src/main/res/layout/dialog_gift_lottery.xml index 655f38b..a820e4b 100644 --- a/moduleUtil/src/main/res/layout/dialog_gift_lottery.xml +++ b/moduleUtil/src/main/res/layout/dialog_gift_lottery.xml @@ -1,55 +1,377 @@ + xmlns:app="http://schemas.android.com/apk/res-auto" + xmlns:tools="http://schemas.android.com/tools"> + android:layout_height="match_parent" + android:background="@mipmap/tkzj_bj"> + android:orientation="horizontal" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent"> -