全屏游戏

This commit is contained in:
18401019693 2023-09-27 14:06:22 +08:00
parent 79fa6be313
commit 6d98afa319
11 changed files with 151 additions and 9 deletions

View File

@ -10,12 +10,21 @@ import androidx.lifecycle.Observer;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.makeramen.roundedimageview.RoundedImageView; import com.makeramen.roundedimageview.RoundedImageView;
import com.yunbao.common.R; import com.yunbao.common.R;
import com.yunbao.common.bean.CheckRemainingBalance;
import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.event.CheckRemainingBalanceEvent;
import com.yunbao.common.glide.ImgLoader; 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.QuickStartGameViewModel;
import com.yunbao.common.sud.model.GameConfigModel; 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 com.yunbao.common.views.weight.ViewClicksAntiShake;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
public class SudGameActivity extends AbsActivity { public class SudGameActivity extends AbsActivity {
private FrameLayout gameContainer; private FrameLayout gameContainer;
private long mInteractionID; private long mInteractionID;
@ -33,10 +42,17 @@ public class SudGameActivity extends AbsActivity {
@Override @Override
protected void main() { protected void main() {
Bus.getOn(this);
super.main(); super.main();
initView(); initView();
} }
@Override
protected void onDestroy() {
Bus.getOff(this);
super.onDestroy();
}
private void initView() { private void initView() {
String createSudRoomJson = getIntent().getStringExtra("CreateSudRoom"); String createSudRoomJson = getIntent().getStringExtra("CreateSudRoom");
mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class); mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class);
@ -76,7 +92,41 @@ public class SudGameActivity extends AbsActivity {
GameConfigModel gameConfigModel = gameViewModel.getGameConfigModel(); GameConfigModel gameConfigModel = gameViewModel.getGameConfigModel();
gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值 gameConfigModel.ui.ping.hide = true; // 配置不隐藏ping值
gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值 gameConfigModel.ui.level.hide = true; // 配置不隐藏ping值
gameConfigModel.ui.lobby_players.custom = true;
gameConfigModel.ui.join_btn.custom = true;
// SudMGP平台64bit游戏ID // SudMGP平台64bit游戏ID
gameViewModel.switchGame((Activity) mContext, mLiveUid, mInteractionID); 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<CheckRemainingBalance>() {
@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("钱不够,细狗");
}
});
}
} }

View File

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

View File

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

View File

@ -7,6 +7,7 @@ import com.yunbao.common.bean.AnchorRecommendModel;
import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.BlindBoxInfoModel; import com.yunbao.common.bean.BlindBoxInfoModel;
import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CheckLiveModel;
import com.yunbao.common.bean.CheckRemainingBalance;
import com.yunbao.common.bean.ContributeModel; import com.yunbao.common.bean.ContributeModel;
import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.CustomSidebarInfoModel;
@ -1004,9 +1005,9 @@ public interface PDLiveApi {
@Query("liveuid") String liveUid, @Query("liveuid") String liveUid,
@Query("page") int page @Query("page") int page
); );
/** /**
* 获取游戏房列表 - 搜索 * 获取游戏房列表 - 搜索
*
*/ */
@GET("/api/public/?service=Sudgameserver.getRoomList") @GET("/api/public/?service=Sudgameserver.getRoomList")
Observable<ResponseModel<List<SudRoomListModel>>> searchRoomList( Observable<ResponseModel<List<SudRoomListModel>>> searchRoomList(
@ -1018,5 +1019,10 @@ public interface PDLiveApi {
@Query("page") int page @Query("page") int page
); );
@GET("/api/public/?service=Sudgameserver.checkRemainingBalance")
Observable<ResponseModel<CheckRemainingBalance>> checkRemainingBalance(
@Query("room_id") String roomId
);
} }

View File

@ -10,6 +10,7 @@ import com.yunbao.common.bean.ActiveModel;
import com.yunbao.common.bean.BaseModel; import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.BlindBoxInfoModel; import com.yunbao.common.bean.BlindBoxInfoModel;
import com.yunbao.common.bean.CheckLiveModel; import com.yunbao.common.bean.CheckLiveModel;
import com.yunbao.common.bean.CheckRemainingBalance;
import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.CustomSidebarInfoModel; import com.yunbao.common.bean.CustomSidebarInfoModel;
import com.yunbao.common.bean.DiscountsModel; import com.yunbao.common.bean.DiscountsModel;
@ -2261,9 +2262,10 @@ public class LiveNetManager {
} }
}).isDisposed(); }).isDisposed();
} }
public void searchRoomList(String sudGameId, String threshold, String roomHolderType, String search, int page, HttpCallback<List<SudRoomListModel>> callback) { public void searchRoomList(String sudGameId, String threshold, String roomHolderType, String search, int page, HttpCallback<List<SudRoomListModel>> callback) {
API.get().pdLiveApi(mContext) API.get().pdLiveApi(mContext)
.searchRoomList(sudGameId,threshold,roomHolderType,"0",search,page) .searchRoomList(sudGameId, threshold, roomHolderType, "0", search, page)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<List<SudRoomListModel>>>() { .subscribe(new Consumer<ResponseModel<List<SudRoomListModel>>>() {
@ -2284,6 +2286,29 @@ public class LiveNetManager {
}).isDisposed(); }).isDisposed();
} }
public void checkRemainingBalance(String roomId, HttpCallback<CheckRemainingBalance> callback) {
API.get().pdLiveApi(mContext)
.checkRemainingBalance(roomId)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<CheckRemainingBalance>>() {
@Override
public void accept(ResponseModel<CheckRemainingBalance> checkRemainingBalanceResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(checkRemainingBalanceResponseModel.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
throwable.printStackTrace();
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
/** /**
* 直播间取消网络请求 * 直播间取消网络请求
*/ */

View File

@ -1,6 +1,7 @@
package com.yunbao.common.sud; package com.yunbao.common.sud;
import android.app.Activity; import android.app.Activity;
import android.util.Log;
import android.view.View; import android.view.View;
import androidx.lifecycle.MutableLiveData; import androidx.lifecycle.MutableLiveData;
@ -243,6 +244,7 @@ public class QuickStartGameViewModel extends BaseGameViewModel {
@Override @Override
public void onGameMGCommonGameState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameState model) { public void onGameMGCommonGameState(ISudFSMStateHandle handle, SudMGPMGState.MGCommonGameState model) {
super.onGameMGCommonGameState(handle, model); super.onGameMGCommonGameState(handle, model);
Log.e("QuickStartGameViewModel",model.toString());
} }
} }

View File

@ -6,7 +6,11 @@
package com.yunbao.common.sud.decorator; 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.sud.state.SudMGPMGState;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.ISudFSMStateHandleUtils; import com.yunbao.common.utils.ISudFSMStateHandleUtils;
import com.yunbao.common.utils.SudJsonUtils; import com.yunbao.common.utils.SudJsonUtils;
@ -172,11 +176,13 @@ public class SudFSMMGDecorator implements ISudFSMMG {
break; break;
case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN: // 4. 加入游戏按钮点击状态 case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN: // 4. 加入游戏按钮点击状态
SudMGPMGState.MGCommonSelfClickJoinBtn mgCommonSelfClickJoinBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickJoinBtn.class); SudMGPMGState.MGCommonSelfClickJoinBtn mgCommonSelfClickJoinBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickJoinBtn.class);
if (listener == null) { Bus.get().post(new CheckRemainingBalanceEvent().setSeatIndex(mgCommonSelfClickJoinBtn.seatIndex));
ISudFSMStateHandleUtils.handleSuccess(handle); // if (listener == null) {
} else { // ISudFSMStateHandleUtils.handleSuccess(handle);
listener.onGameMGCommonSelfClickJoinBtn(handle, mgCommonSelfClickJoinBtn); // } else {
} // listener.onGameMGCommonSelfClickJoinBtn(handle, mgCommonSelfClickJoinBtn);
// }
break; break;
case SudMGPMGState.MG_COMMON_SELF_CLICK_CANCEL_JOIN_BTN: // 5. 取消加入(退出)游戏按钮点击状态 case SudMGPMGState.MG_COMMON_SELF_CLICK_CANCEL_JOIN_BTN: // 5. 取消加入(退出)游戏按钮点击状态
SudMGPMGState.MGCommonSelfClickCancelJoinBtn selfClickCancelJoinBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickCancelJoinBtn.class); 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)) { if (listener != null && listener.onPlayerStateChange(handle, userId, state, dataJson)) {
return; return;
} }
Log.e("SudFSMMGDecorator", "userId:" + userId + " state:" + state + " dataJson:" + dataJson);
switch (state) { switch (state) {
case SudMGPMGState.MG_COMMON_PLAYER_IN: // 1.加入状态已修改 case SudMGPMGState.MG_COMMON_PLAYER_IN: // 1.加入状态已修改
SudMGPMGState.MGCommonPlayerIn mgCommonPlayerIn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerIn.class); SudMGPMGState.MGCommonPlayerIn mgCommonPlayerIn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerIn.class);
@ -819,6 +826,7 @@ public class SudFSMMGDecorator implements ISudFSMMG {
} }
break; break;
case SudMGPMGState.MG_COMMON_PLAYER_READY: // 2.准备状态已修改 case SudMGPMGState.MG_COMMON_PLAYER_READY: // 2.准备状态已修改
SudMGPMGState.MGCommonPlayerReady mgCommonPlayerReady = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerReady.class); SudMGPMGState.MGCommonPlayerReady mgCommonPlayerReady = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonPlayerReady.class);
sudFSMMGCache.onPlayerMGCommonPlayerReady(userId, mgCommonPlayerReady); sudFSMMGCache.onPlayerMGCommonPlayerReady(userId, mgCommonPlayerReady);
if (listener == null) { if (listener == null) {

View File

@ -12,12 +12,16 @@ import androidx.lifecycle.Observer;
import com.lxj.xpopup.core.BottomPopupView; import com.lxj.xpopup.core.BottomPopupView;
import com.makeramen.roundedimageview.RoundedImageView; import com.makeramen.roundedimageview.RoundedImageView;
import com.yunbao.common.R; import com.yunbao.common.R;
import com.yunbao.common.bean.CheckRemainingBalance;
import com.yunbao.common.bean.CreateSudRoomModel; 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.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.QuickStartGameViewModel;
import com.yunbao.common.sud.model.GameConfigModel; import com.yunbao.common.sud.model.GameConfigModel;
import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.common.views.weight.ViewClicksAntiShake;
import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.Subscribe;
@ -115,7 +119,21 @@ public class LiveSudGamePopup extends BottomPopupView {
} }
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void onLiveNewWishListEvent(LiveNewWishListEvent event) { public void onCheckRemainingBalanceEvent(CheckRemainingBalanceEvent event) {
LiveNetManager.get(getContext()).checkRemainingBalance(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback<CheckRemainingBalance>() {
@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("钱不够,细狗");
}
});
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 4.9 KiB