diff --git a/common/src/main/java/com/yunbao/common/activity/SudGameActivity.java b/common/src/main/java/com/yunbao/common/activity/SudGameActivity.java index 2ede7c550..55aae7fc7 100644 --- a/common/src/main/java/com/yunbao/common/activity/SudGameActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/SudGameActivity.java @@ -10,12 +10,21 @@ import androidx.lifecycle.Observer; import com.google.gson.Gson; import com.makeramen.roundedimageview.RoundedImageView; import com.yunbao.common.R; +import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.CreateSudRoomModel; +import com.yunbao.common.event.CheckRemainingBalanceEvent; import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.sud.QuickStartGameViewModel; import com.yunbao.common.sud.model.GameConfigModel; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + public class SudGameActivity extends AbsActivity { private FrameLayout gameContainer; private long mInteractionID; @@ -33,10 +42,17 @@ public class SudGameActivity extends AbsActivity { @Override protected void main() { + Bus.getOn(this); super.main(); initView(); } + @Override + protected void onDestroy() { + Bus.getOff(this); + super.onDestroy(); + } + private void initView() { String createSudRoomJson = getIntent().getStringExtra("CreateSudRoom"); mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class); @@ -76,7 +92,41 @@ public class SudGameActivity extends AbsActivity { GameConfigModel gameConfigModel = gameViewModel.getGameConfigModel(); gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值 gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值 + + gameConfigModel.ui.lobby_players.custom = true; + gameConfigModel.ui.join_btn.custom = true; + // SudMGP平台64bit游戏ID gameViewModel.switchGame((Activity) mContext, mLiveUid, mInteractionID); +// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, -1, true, 1); +// gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfCaptain(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId())); +// ViewClicksAntiShake.clicksAntiShake(gameTitle, new ViewClicksAntiShake.ViewClicksCallBack() { +// @Override +// public void onViewClicks() { +// +// } +// }); + + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onCheckRemainingBalanceEvent(CheckRemainingBalanceEvent event) { + LiveNetManager.get(mContext).checkRemainingBalance(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() { + @Override + public void onSuccess(CheckRemainingBalance data) { + if (data.getGoldenBeanRemainingBalance() == 1) { + gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, event.getSeatIndex(), true, 1); + } else { + ToastUtil.show("钱不够,细狗"); + } + } + + @Override + public void onError(String error) { + ToastUtil.show("钱不够,细狗"); + } + }); + } + } diff --git a/common/src/main/java/com/yunbao/common/bean/CheckRemainingBalance.java b/common/src/main/java/com/yunbao/common/bean/CheckRemainingBalance.java new file mode 100644 index 000000000..399eb1dfa --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/CheckRemainingBalance.java @@ -0,0 +1,17 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +public class CheckRemainingBalance extends BaseModel{ + + @SerializedName("golden_bean_remaining_balance") + private int goldenBeanRemainingBalance; + + public int getGoldenBeanRemainingBalance() { + return goldenBeanRemainingBalance; + } + + public void setGoldenBeanRemainingBalance(int goldenBeanRemainingBalance) { + this.goldenBeanRemainingBalance = goldenBeanRemainingBalance; + } +} diff --git a/common/src/main/java/com/yunbao/common/event/CheckRemainingBalanceEvent.java b/common/src/main/java/com/yunbao/common/event/CheckRemainingBalanceEvent.java new file mode 100644 index 000000000..71da13c47 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/CheckRemainingBalanceEvent.java @@ -0,0 +1,16 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; + +public class CheckRemainingBalanceEvent extends BaseModel { + public int seatIndex; + + public int getSeatIndex() { + return seatIndex; + } + + public CheckRemainingBalanceEvent setSeatIndex(int seatIndex) { + this.seatIndex = seatIndex; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index 5257a3bf2..c0ca1661d 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -7,6 +7,7 @@ import com.yunbao.common.bean.AnchorRecommendModel; import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BlindBoxInfoModel; import com.yunbao.common.bean.CheckLiveModel; +import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.ContributeModel; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarInfoModel; @@ -1004,9 +1005,9 @@ public interface PDLiveApi { @Query("liveuid") String liveUid, @Query("page") int page ); + /** * 获取游戏房列表 - 搜索 - * */ @GET("/api/public/?service=Sudgameserver.getRoomList") Observable>> searchRoomList( @@ -1018,5 +1019,10 @@ public interface PDLiveApi { @Query("page") int page ); + @GET("/api/public/?service=Sudgameserver.checkRemainingBalance") + Observable> checkRemainingBalance( + @Query("room_id") String roomId + ); + } diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 6434bfb3a..4b939934e 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -10,6 +10,7 @@ import com.yunbao.common.bean.ActiveModel; import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BlindBoxInfoModel; import com.yunbao.common.bean.CheckLiveModel; +import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.DiscountsModel; @@ -2261,9 +2262,10 @@ public class LiveNetManager { } }).isDisposed(); } + public void searchRoomList(String sudGameId, String threshold, String roomHolderType, String search, int page, HttpCallback> callback) { API.get().pdLiveApi(mContext) - .searchRoomList(sudGameId,threshold,roomHolderType,"0",search,page) + .searchRoomList(sudGameId, threshold, roomHolderType, "0", search, page) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Consumer>>() { @@ -2284,6 +2286,29 @@ public class LiveNetManager { }).isDisposed(); } + public void checkRemainingBalance(String roomId, HttpCallback callback) { + API.get().pdLiveApi(mContext) + .checkRemainingBalance(roomId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel checkRemainingBalanceResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(checkRemainingBalanceResponseModel.getData().getInfo()); + } + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + throwable.printStackTrace(); + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + /** * 直播间取消网络请求 */ diff --git a/common/src/main/java/com/yunbao/common/sud/QuickStartGameViewModel.java b/common/src/main/java/com/yunbao/common/sud/QuickStartGameViewModel.java index 01733549e..f35ee471a 100644 --- a/common/src/main/java/com/yunbao/common/sud/QuickStartGameViewModel.java +++ b/common/src/main/java/com/yunbao/common/sud/QuickStartGameViewModel.java @@ -1,6 +1,7 @@ package com.yunbao.common.sud; import android.app.Activity; +import android.util.Log; import android.view.View; import androidx.lifecycle.MutableLiveData; @@ -243,6 +244,7 @@ public class QuickStartGameViewModel extends BaseGameViewModel { @Override public void onGameMGCommonGameState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameState model) { super.onGameMGCommonGameState(handle, model); + Log.e("QuickStartGameViewModel",model.toString()); } } diff --git a/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java b/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java index fc213354a..9cbcccf80 100644 --- a/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java +++ b/common/src/main/java/com/yunbao/common/sud/decorator/SudFSMMGDecorator.java @@ -6,7 +6,11 @@ package com.yunbao.common.sud.decorator; +import android.util.Log; + +import com.yunbao.common.event.CheckRemainingBalanceEvent; import com.yunbao.common.sud.state.SudMGPMGState; +import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.ISudFSMStateHandleUtils; import com.yunbao.common.utils.SudJsonUtils; @@ -172,11 +176,13 @@ public class SudFSMMGDecorator implements ISudFSMMG { break; case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN: // 4. 加入游戏按钮点击状态 SudMGPMGState.MGCommonSelfClickJoinBtn mgCommonSelfClickJoinBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickJoinBtn.class); - if (listener == null) { - ISudFSMStateHandleUtils.handleSuccess(handle); - } else { - listener.onGameMGCommonSelfClickJoinBtn(handle, mgCommonSelfClickJoinBtn); - } + Bus.get().post(new CheckRemainingBalanceEvent().setSeatIndex(mgCommonSelfClickJoinBtn.seatIndex)); +// if (listener == null) { +// ISudFSMStateHandleUtils.handleSuccess(handle); +// } else { +// listener.onGameMGCommonSelfClickJoinBtn(handle, mgCommonSelfClickJoinBtn); +// } + break; case SudMGPMGState.MG_COMMON_SELF_CLICK_CANCEL_JOIN_BTN: // 5. 取消加入(退出)游戏按钮点击状态 SudMGPMGState.MGCommonSelfClickCancelJoinBtn selfClickCancelJoinBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickCancelJoinBtn.class); @@ -808,6 +814,7 @@ public class SudFSMMGDecorator implements ISudFSMMG { if (listener != null && listener.onPlayerStateChange(handle, userId, state, dataJson)) { return; } + Log.e("SudFSMMGDecorator", "userId:" + userId + " state:" + state + " dataJson:" + dataJson); switch (state) { case SudMGPMGState.MG_COMMON_PLAYER_IN: // 1.加入状态(已修改) SudMGPMGState.MGCommonPlayerIn mgCommonPlayerIn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerIn.class); @@ -819,6 +826,7 @@ public class SudFSMMGDecorator implements ISudFSMMG { } break; case SudMGPMGState.MG_COMMON_PLAYER_READY: // 2.准备状态(已修改) + SudMGPMGState.MGCommonPlayerReady mgCommonPlayerReady = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerReady.class); sudFSMMGCache.onPlayerMGCommonPlayerReady(userId, mgCommonPlayerReady); if (listener == null) { diff --git a/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java b/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java index ec10e42b9..23bf22a1b 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java @@ -12,12 +12,16 @@ import androidx.lifecycle.Observer; import com.lxj.xpopup.core.BottomPopupView; import com.makeramen.roundedimageview.RoundedImageView; import com.yunbao.common.R; +import com.yunbao.common.bean.CheckRemainingBalance; import com.yunbao.common.bean.CreateSudRoomModel; -import com.yunbao.common.event.LiveNewWishListEvent; +import com.yunbao.common.event.CheckRemainingBalanceEvent; import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.sud.QuickStartGameViewModel; import com.yunbao.common.sud.model.GameConfigModel; import com.yunbao.common.utils.Bus; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; import org.greenrobot.eventbus.Subscribe; @@ -115,7 +119,21 @@ public class LiveSudGamePopup extends BottomPopupView { } @Subscribe(threadMode = ThreadMode.MAIN) - public void onLiveNewWishListEvent(LiveNewWishListEvent event) { + public void onCheckRemainingBalanceEvent(CheckRemainingBalanceEvent event) { + LiveNetManager.get(getContext()).checkRemainingBalance(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback() { + @Override + public void onSuccess(CheckRemainingBalance data) { + if (data.getGoldenBeanRemainingBalance() == 1) { + gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(true, event.getSeatIndex(), true, 1); + } else { + ToastUtil.show("钱不够,细狗"); + } + } + @Override + public void onError(String error) { + ToastUtil.show("钱不够,细狗"); + } + }); } } diff --git a/main/src/main/res/mipmap-b+en+us/icon_main_live_type_1.png b/main/src/main/res/mipmap-b+en+us/icon_main_live_type_1.png new file mode 100644 index 000000000..efcc58227 Binary files /dev/null and b/main/src/main/res/mipmap-b+en+us/icon_main_live_type_1.png differ diff --git a/main/src/main/res/mipmap-b+en+us/icon_user_home_living.gif b/main/src/main/res/mipmap-b+en+us/icon_user_home_living.gif new file mode 100644 index 000000000..0dd148bff Binary files /dev/null and b/main/src/main/res/mipmap-b+en+us/icon_user_home_living.gif differ diff --git a/main/src/main/res/mipmap-mdpi/icon_main_live_type_1.png b/main/src/main/res/mipmap-mdpi/icon_main_live_type_1.png index c5588a53f..33fc54b75 100644 Binary files a/main/src/main/res/mipmap-mdpi/icon_main_live_type_1.png and b/main/src/main/res/mipmap-mdpi/icon_main_live_type_1.png differ