新增小游戏相关内容
This commit is contained in:
@@ -27,12 +27,14 @@ import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.adapter.SudGameChatAdapter;
|
||||
import com.yunbao.common.adapter.SudGameUserListAdapter;
|
||||
import com.yunbao.common.bean.BaseModel;
|
||||
import com.yunbao.common.bean.CheckRemainingBalance;
|
||||
import com.yunbao.common.bean.CreateSudRoomModel;
|
||||
import com.yunbao.common.bean.CustomSidebarChildModel;
|
||||
import com.yunbao.common.bean.CustomSidebarInfoModel;
|
||||
import com.yunbao.common.bean.HttpCallbackModel;
|
||||
import com.yunbao.common.bean.RoomMicStatusModel;
|
||||
import com.yunbao.common.bean.SudActivityGameInfoBean;
|
||||
import com.yunbao.common.bean.SudGameChatImModel;
|
||||
import com.yunbao.common.bean.SudGameInfoBean;
|
||||
import com.yunbao.common.bean.SudGameScoreBean;
|
||||
@@ -49,6 +51,7 @@ import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.base.HttpCallback;
|
||||
import com.yunbao.common.http.live.LiveNetManager;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.manager.RandomSudGameManager;
|
||||
import com.yunbao.common.manager.imrongcloud.GameSwMicManager;
|
||||
import com.yunbao.common.sud.QuickStartGameViewModel;
|
||||
import com.yunbao.common.sud.model.GameConfigModel;
|
||||
@@ -248,7 +251,7 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
|
||||
|
||||
}
|
||||
});
|
||||
if(isSw){
|
||||
if (isSw) {
|
||||
SWAuManager.get().exitChannelAll();
|
||||
}
|
||||
if (gameMicManager != null) {
|
||||
@@ -261,14 +264,16 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
private boolean isActivityGame;
|
||||
|
||||
private void initView() {
|
||||
isActivityGame = getIntent().getBooleanExtra("isRandom", false);
|
||||
String createSudRoomJson = getIntent().getStringExtra("CreateSudRoom");
|
||||
mCreateSudRoomModel = new Gson().fromJson(createSudRoomJson, CreateSudRoomModel.class);
|
||||
mInteractionID = mCreateSudRoomModel.getLongSudGameId();
|
||||
mLiveUid = mCreateSudRoomModel.getSudGameRoomId();
|
||||
//第二次进入时,viewmodel数据丢失,所以初始化时直接获取
|
||||
gameViewModel.getScore(mCreateSudRoomModel.getSudGameRoomId(),mContext);
|
||||
gameViewModel.getScore(mCreateSudRoomModel.getSudGameRoomId(), mContext);
|
||||
|
||||
gameContainer = findViewById(R.id.game_container);
|
||||
roomName = findViewById(R.id.room_name);
|
||||
@@ -432,9 +437,9 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
|
||||
} else {
|
||||
disable = true;
|
||||
// 设置禁用麦克风采集
|
||||
if(isSw){
|
||||
if (isSw) {
|
||||
SWAuManager.get().setMicAn(false);
|
||||
}else{
|
||||
} else {
|
||||
RCRTCEngine.getInstance().getDefaultAudioStream().setMicrophoneDisable(disable);
|
||||
}
|
||||
ImgLoader.display(mContext, R.mipmap.icon_game_close_wheat, gameCloseWheat);
|
||||
@@ -518,7 +523,9 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
|
||||
sudGameDoubleDialog = new SudGameDoubleDialog(this);//双人游戏
|
||||
sudGameMultipleDialog = new SudGameMultipleDialog(this);//多人游戏
|
||||
sudLoadDialog = new SudLoadDialog(this);//加载弹窗
|
||||
|
||||
if (isActivityGame) {
|
||||
sudGameDoubleDialog.setActivityGame();
|
||||
}
|
||||
//游戏结算结束
|
||||
gameViewModel.listMutableLiveData.observe(this, sudSettleBeans -> {
|
||||
//观察结算排名数据,点击跳过和再来一局不需要显示结算界面
|
||||
@@ -538,14 +545,21 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
|
||||
|
||||
//加载弹窗消失监听,自动消失和点击跳过在这个监听中都不做处理
|
||||
sudLoadDialog.setOnDismissListener(() -> {
|
||||
if (sudLoadDialog.getClickStatus() == 2){
|
||||
if (sudLoadDialog.getClickStatus() == 2) {
|
||||
Bus.get().post(new CheckRemainingBalanceEvent().setSudMGPMGState(SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN).setSubReady(false));
|
||||
}
|
||||
});
|
||||
//通知活动游戏
|
||||
if (isActivityGame) {
|
||||
RandomSudGameManager.getManager().onInitGame(mCreateSudRoomModel);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
public void onCheckRemainingBalanceEvent(CheckRemainingBalanceEvent event) {
|
||||
if (isActivityGame) {
|
||||
RandomSudGameManager.getManager().onGameState(event);
|
||||
}
|
||||
switch (event.getSudMGPMGState()) {
|
||||
case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN:
|
||||
case SudMGPMGState.MG_COMMON_SELF_CLICK_GAME_SETTLE_AGAIN_BTN:
|
||||
@@ -589,15 +603,45 @@ public class SudSwGameActivity extends AbsActivity implements GameSwMicManager.M
|
||||
//先获取用户信息再进行结算处理
|
||||
LiveNetManager.get(mContext).getSudGameInfo(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback<List<SudGameInfoBean>>() {
|
||||
@Override
|
||||
public void onSuccess(List<SudGameInfoBean> data) {
|
||||
if (!data.isEmpty()){
|
||||
gameViewModel.setSudGameInfoBeanList(data);
|
||||
gameViewModel.sudGameRank(event.getMgCommonGameSettle());//结算游戏
|
||||
}else {
|
||||
public void onSuccess(List<SudGameInfoBean> infoBean) {
|
||||
if (!infoBean.isEmpty()) {
|
||||
System.out.println("结算,是否为游戏活动:"+isActivityGame);
|
||||
if(isActivityGame) {
|
||||
loadScore(infoBean, 3);
|
||||
}else{
|
||||
gameViewModel.setSudGameInfoBeanList(infoBean);
|
||||
gameViewModel.sudGameRank(event.getMgCommonGameSettle(null));//结算游戏
|
||||
}
|
||||
} else {
|
||||
ToastUtil.show(getString(R.string.net_error));
|
||||
}
|
||||
}
|
||||
|
||||
private void loadScore(List<SudGameInfoBean> infoBean,int index) {
|
||||
if(index==0){
|
||||
return;
|
||||
}
|
||||
LiveNetManager.get(mContext)
|
||||
.ballClearanceTableGetResultScore(mCreateSudRoomModel.getSudGameRoomId(), new HttpCallback<>() {
|
||||
@Override
|
||||
public void onSuccess(List<SudActivityGameInfoBean> data) {
|
||||
if (data.isEmpty()) {
|
||||
new Handler(Looper.getMainLooper()).postDelayed(() -> {
|
||||
loadScore(infoBean,index-1);
|
||||
}, 300);
|
||||
return;
|
||||
}
|
||||
gameViewModel.setSudGameInfoBeanList(infoBean);
|
||||
gameViewModel.sudGameRank(event.getMgCommonGameSettle(data));//结算游戏
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastUtil.show(error);
|
||||
|
||||
Reference in New Issue
Block a user