修改随机开始,修改游戏的上座和结束的逻辑,添加中英文

This commit is contained in:
18401019693
2023-09-27 16:28:43 +08:00
parent 6d98afa319
commit c94f549531
19 changed files with 386 additions and 105 deletions

View File

@@ -18,6 +18,7 @@ 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.sud.state.SudMGPMGState;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
@@ -25,6 +26,8 @@ import com.yunbao.common.views.weight.ViewClicksAntiShake;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.List;
public class SudGameActivity extends AbsActivity {
private FrameLayout gameContainer;
private long mInteractionID;
@@ -112,21 +115,26 @@ public class SudGameActivity extends AbsActivity {
@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 {
if (event.getResults().size() > 0) {
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(false, event.getSeatIndex(), true, 1);
} else {
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("钱不够,细狗");
}
}
});
}
@Override
public void onError(String error) {
ToastUtil.show("钱不够,细狗");
}
});
}
}

View File

@@ -101,7 +101,7 @@ public class CreateSudGamePopup extends BottomPopupView {
if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
ToastUtil.show("房间名不能为空");
} else {
ToastUtil.show("房间名不能为空");
ToastUtil.show("The room name cannot be empty");
}
return;
}
@@ -109,7 +109,7 @@ public class CreateSudGamePopup extends BottomPopupView {
if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
ToastUtil.show("还未选择游戏");
} else {
ToastUtil.show("还未选择游戏");
ToastUtil.show("No game has been selected");
}
return;
}
@@ -117,7 +117,7 @@ public class CreateSudGamePopup extends BottomPopupView {
if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
ToastUtil.show("数量区间为100--5W");
} else {
ToastUtil.show("数量区间为100--5W");
ToastUtil.show("The quantity range is 100 to 5 W");
}
return;
}
@@ -126,7 +126,7 @@ public class CreateSudGamePopup extends BottomPopupView {
if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
ToastUtil.show("数量区间为100--5W");
} else {
ToastUtil.show("数量区间为100--5W");
ToastUtil.show("The quantity range is 100 to 5 W");
}
return;
}

View File

@@ -28,8 +28,8 @@ import com.yunbao.common.event.SudGameListEvent;
import com.yunbao.common.event.SudGameListSillEvent;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.RandomUtil;
import com.yunbao.common.views.LiveSudGamePopup;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
@@ -152,25 +152,38 @@ public class SudGameListPopup extends BottomPopupView {
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.random_start), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
LiveNetManager.get(getContext())
.randomRoom(new com.yunbao.common.http.base.HttpCallback<CreateSudRoomModel>() {
@Override
public void onSuccess(CreateSudRoomModel data) {
if (data != null) {
new XPopup.Builder(getContext())
.enableDrag(false)
.dismissOnTouchOutside(false)
.dismissOnBackPressed(false)
.asCustom(new LiveSudGamePopup(getContext(), data))
.show();
dialog.dismiss();
}
}
List<SudRoomListModel> sudRoomListModels = sudGameListAdapter.getList();
if (sudRoomListModels.size() > 1) {
int random = RandomUtil.nextInt(sudRoomListModels.size() - 1);
CreateSudRoomModel createSudRoomModel = new CreateSudRoomModel();
createSudRoomModel.setSudGameId(sudRoomListModels.get(random).getSudGameId());
createSudRoomModel.setSudGameRoomId(sudRoomListModels.get(random).getSudGameRoomId());
createSudRoomModel.setAvatar(sudRoomListModels.get(random).getAvatar());
createSudRoomModel.setRoomName(sudRoomListModels.get(random).getRoomName());
createSudRoomModel.setSudGameName(sudRoomListModels.get(random).getSudGameName());
new XPopup.Builder(getContext())
.enableDrag(false)
.dismissOnTouchOutside(false)
.dismissOnBackPressed(false)
.asCustom(new LiveSudGamePopup(getContext(), createSudRoomModel))
.show();
dialog.dismiss();
}
@Override
public void onError(String error) {
}
});
// List<SudRoomListModel> sudRoomListModels = sudGameListAdapter.getList();
// if (sudRoomListModels.size() > 1) {
// int random = RandomUtil.nextInt(sudRoomListModels.size() - 1);
// CreateSudRoomModel createSudRoomModel = new CreateSudRoomModel();
// createSudRoomModel.setSudGameId(sudRoomListModels.get(random).getSudGameId());
// createSudRoomModel.setSudGameRoomId(sudRoomListModels.get(random).getSudGameRoomId());
// createSudRoomModel.setAvatar(sudRoomListModels.get(random).getAvatar());
// createSudRoomModel.setRoomName(sudRoomListModels.get(random).getRoomName());
// createSudRoomModel.setSudGameName(sudRoomListModels.get(random).getSudGameName());
// }
//
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.search), new ViewClicksAntiShake.ViewClicksCallBack() {

View File

@@ -1,9 +1,23 @@
package com.yunbao.common.event;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.sud.state.SudMGPMGState;
import java.util.ArrayList;
import java.util.List;
public class CheckRemainingBalanceEvent extends BaseModel {
public int seatIndex;
public List<SudMGPMGState.MGCommonGameSettle.PlayerResult> results = new ArrayList<>();
public List<SudMGPMGState.MGCommonGameSettle.PlayerResult> getResults() {
return results;
}
public CheckRemainingBalanceEvent setResults(List<SudMGPMGState.MGCommonGameSettle.PlayerResult> results) {
this.results = results;
return this;
}
public int getSeatIndex() {
return seatIndex;

View File

@@ -1024,5 +1024,9 @@ public interface PDLiveApi {
@Query("room_id") String roomId
);
@GET("/api/public/?service=Sudgameserver.randomRoom")
Observable<ResponseModel<CreateSudRoomModel>> randomRoom(
);
}

View File

@@ -2241,6 +2241,28 @@ public class LiveNetManager {
}).isDisposed();
}
public void randomRoom(HttpCallback<CreateSudRoomModel> callback) {
API.get().pdLiveApi(mContext)
.randomRoom()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<CreateSudRoomModel>>() {
@Override
public void accept(ResponseModel<CreateSudRoomModel> createSudRoomModelResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(createSudRoomModelResponseModel.getData().getInfo());
}
}
}, new Consumer<Throwable>() {
@Override
public void accept(Throwable throwable) throws Exception {
if (callback != null) {
callback.onError(mContext.getString(R.string.net_error));
}
}
}).isDisposed();
}
public void getRoomList(String sudGameId, String threshold, String roomHolderType, String liveUid, int page, HttpCallback<List<SudRoomListModel>> callback) {
API.get().pdLiveApi(mContext)
.getRoomList(sudGameId, threshold, roomHolderType, liveUid, page)

View File

@@ -51,6 +51,15 @@ public class IMLoginManager extends BaseCacheManager {
private final String LIVE_NOTIFY_SETTINGS = "liveNotifySettings";//开播通知
private final String KEY_LANGUAGE = "language";
private final String KEY_GAME = "key_game";
public void setSudGame(String sudGameJson) {
put(KEY_GAME, sudGameJson);
}
public String getSudGame() {
return getString(KEY_GAME);
}
public void setLanguage(boolean isEnglish) {
put(KEY_LANGUAGE, isEnglish);

View File

@@ -173,6 +173,7 @@ public class SudFSMMGDecorator implements ISudFSMMG {
} else {
listener.onGameMGCommonGameSettle(handle, mgCommonGameSettle);
}
Bus.get().post(new CheckRemainingBalanceEvent().setResults(mgCommonGameSettle.results));
break;
case SudMGPMGState.MG_COMMON_SELF_CLICK_JOIN_BTN: // 4. 加入游戏按钮点击状态
SudMGPMGState.MGCommonSelfClickJoinBtn mgCommonSelfClickJoinBtn = SudJsonUtils.fromJson(dataJson, SudMGPMGState.MGCommonSelfClickJoinBtn.class);

View File

@@ -18,6 +18,7 @@ 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.manager.IMLoginManager;
import com.yunbao.common.sud.QuickStartGameViewModel;
import com.yunbao.common.sud.model.GameConfigModel;
import com.yunbao.common.utils.Bus;
@@ -51,6 +52,7 @@ public class LiveSudGamePopup extends BottomPopupView {
mCreateSudRoomModel = createSudRoomModel;
mInteractionID = mCreateSudRoomModel.getLongSudGameId();
mLiveUid = mCreateSudRoomModel.getSudGameRoomId();
IMLoginManager.get(context).setSudGame("");
}
// 返回自定义弹窗的布局
@@ -120,20 +122,25 @@ public class LiveSudGamePopup extends BottomPopupView {
@Subscribe(threadMode = ThreadMode.MAIN)
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 {
if (event.getResults().size() > 0) {
gameViewModel.sudFSTAPPDecorator.notifyAPPCommonSelfIn(false, event.getSeatIndex(), true, 1);
} else {
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("钱不够,细狗");
}
}
});
}
@Override
public void onError(String error) {
ToastUtil.show("钱不够,细狗");
}
});
}
}

View File

@@ -9,17 +9,24 @@ import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.lxj.xpopup.XPopup;
import com.makeramen.roundedimageview.RoundedImageView;
import com.yunbao.common.R;
import com.yunbao.common.activity.SudGameActivity;
import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.SudRoomListModel;
import com.yunbao.common.bean.playerObject;
import com.yunbao.common.event.SudGameListDissMissEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.LiveHttpUtil;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.RouteUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import java.util.List;
@@ -101,9 +108,35 @@ public class SudGameListViewHolder extends RecyclerView.ViewHolder {
createSudRoomModel.setRoomName(model.getRoomName());
createSudRoomModel.setSudGameName(model.getSudGameName());
if (isHome) {
Intent intent = new Intent(itemView.getContext(), SudGameActivity.class);
intent.putExtra("CreateSudRoom", new Gson().toJson(createSudRoomModel));
itemView.getContext().startActivity(intent);
if (TextUtils.equals(model.getLiveUid(), "0")) {
Intent intent = new Intent(itemView.getContext(), SudGameActivity.class);
intent.putExtra("CreateSudRoom", new Gson().toJson(createSudRoomModel));
itemView.getContext().startActivity(intent);
} else {
LiveHttpUtil.getLiveInfo(model.getLiveUid() + "", new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0 && info.length > 0) {
LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
new LiveRoomCheckLivePresenter(itemView.getContext(), liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
@Override
public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
IMLoginManager.get(itemView.getContext()).setSudGame(new Gson().toJson(createSudRoomModel));
}
@Override
public void onCheckError(String contextError) {
}
});
} else {
RouteUtil.forwardUserHome(itemView.getContext(), model.getLiveUid(), 0);
}
}
});
}
} else {
new XPopup.Builder(itemView.getContext())
.enableDrag(false)