添加创建游戏的时候星币配置的接口

This commit is contained in:
18401019693 2023-11-11 15:43:41 +08:00
parent eb5aebda51
commit b7842d5ac9
5 changed files with 77 additions and 4 deletions

View File

@ -24,6 +24,7 @@ import com.yunbao.common.R;
import com.yunbao.common.activity.SudGameActivity; import com.yunbao.common.activity.SudGameActivity;
import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CreateSudRoomModel;
import com.yunbao.common.bean.CustomSidebarChildModel; import com.yunbao.common.bean.CustomSidebarChildModel;
import com.yunbao.common.event.CheckCurrencyModel;
import com.yunbao.common.event.CreateSudGameEvent; import com.yunbao.common.event.CreateSudGameEvent;
import com.yunbao.common.event.CurrencyTypeEvent; import com.yunbao.common.event.CurrencyTypeEvent;
import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent;
@ -89,6 +90,7 @@ public class CreateSudGamePopup extends BottomPopupView {
} }
private String userName; private String userName;
private boolean isYuanbao;
private void initDate() { private void initDate() {
currencyTypeName = getContext().getString(R.string.golden_bean); currencyTypeName = getContext().getString(R.string.golden_bean);
@ -98,6 +100,17 @@ public class CreateSudGamePopup extends BottomPopupView {
roomNames.add(WordUtil.isNewZh() ? "決戰到天亮 " : "Fight until dawn"); roomNames.add(WordUtil.isNewZh() ? "決戰到天亮 " : "Fight until dawn");
roomNames.add(WordUtil.isNewZh() ? "在線等遊戲夥伴~" : "Waiting for game partners~"); roomNames.add(WordUtil.isNewZh() ? "在線等遊戲夥伴~" : "Waiting for game partners~");
roomNames.add(WordUtil.isNewZh() ? userName + "的房间 " : userName + "s room"); roomNames.add(WordUtil.isNewZh() ? userName + "的房间 " : userName + "s room");
LiveNetManager.get(getContext()).checkCurrency(new HttpCallback<CheckCurrencyModel>() {
@Override
public void onSuccess(CheckCurrencyModel data) {
isYuanbao = TextUtils.equals(data.getIsYuanbao(), "1") || TextUtils.equals(data.getIsYuanbao(), "true");
}
@Override
public void onError(String error) {
}
});
} }
private void initView() { private void initView() {
@ -155,7 +168,7 @@ public class CreateSudGamePopup extends BottomPopupView {
String name = roomName.getText().toString(); String name = roomName.getText().toString();
if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) {
if (name.length() > 15) { if (name.length() > 15) {
ToastUtil.show("房間名长度为[1-10]"); ToastUtil.show("房間名长度为[1-15]");
return; return;
} }
@ -304,7 +317,7 @@ public class CreateSudGamePopup extends BottomPopupView {
.isDestroyOnDismiss(true) .isDestroyOnDismiss(true)
.isLightStatusBar(false) .isLightStatusBar(false)
.popupPosition(PopupPosition.Bottom) .popupPosition(PopupPosition.Bottom)
.asCustom(new SudGameListSelectPopup(getContext(), 5, currencyTypeName) .asCustom(new SudGameListSelectPopup(getContext(), 5, currencyTypeName,isYuanbao)
.setOnDismissListener(new DialogInterface.OnDismissListener() { .setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override @Override
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {

View File

@ -40,6 +40,7 @@ public class SudGameListSelectPopup extends AttachPopupView {
private long interactionID = 0; private long interactionID = 0;
private DialogInterface.OnDismissListener onDismissListener; private DialogInterface.OnDismissListener onDismissListener;
private String mSill; private String mSill;
private boolean isYuanbao;
public SudGameListSelectPopup(@NonNull Context context, int type, List<CustomSidebarChildModel> child, long interactionID) { public SudGameListSelectPopup(@NonNull Context context, int type, List<CustomSidebarChildModel> child, long interactionID) {
super(context); super(context);
@ -59,6 +60,13 @@ public class SudGameListSelectPopup extends AttachPopupView {
mSill = sill; mSill = sill;
} }
public SudGameListSelectPopup(@NonNull Context context, int mType, String sill, boolean isYuanbao) {
super(context);
this.mType = mType;
mSill = sill;
this.isYuanbao = isYuanbao;
}
public SudGameListSelectPopup(@NonNull Context context, String sill, List<CustomSidebarChildModel> child) { public SudGameListSelectPopup(@NonNull Context context, String sill, List<CustomSidebarChildModel> child) {
super(context); super(context);
this.mType = 8; this.mType = 8;
@ -174,9 +182,14 @@ public class SudGameListSelectPopup extends AttachPopupView {
}); });
} else if (mType == 5) { } else if (mType == 5) {
selectString.add(getContext().getString(R.string.golden_bean)); selectString.add(getContext().getString(R.string.golden_bean));
selectString.add(getContext().getString(R.string.coins)); if (isYuanbao) {
selectString.add(getContext().getString(R.string.coins));
}
selectSill.put(getContext().getString(R.string.golden_bean), "3"); selectSill.put(getContext().getString(R.string.golden_bean), "3");
selectSill.put(getContext().getString(R.string.coins), "2"); if (isYuanbao) {
selectSill.put(getContext().getString(R.string.coins), "2");
}
index = 0; index = 0;
for (int i = 0; i < selectString.size(); i++) { for (int i = 0; i < selectString.size(); i++) {
if (TextUtils.equals(mSill, selectString.get(i))) { if (TextUtils.equals(mSill, selectString.get(i))) {

View File

@ -0,0 +1,19 @@
package com.yunbao.common.event;
import com.google.gson.annotations.SerializedName;
import com.yunbao.common.bean.BaseModel;
public class CheckCurrencyModel extends BaseModel {
@SerializedName("is_yuanbao")
private String isYuanbao;
public String getIsYuanbao() {
return isYuanbao;
}
public CheckCurrencyModel setIsYuanbao(String isYuanbao) {
this.isYuanbao = isYuanbao;
return this;
}
}

View File

@ -63,6 +63,7 @@ import com.yunbao.common.bean.UserAvatarSelectBean;
import com.yunbao.common.bean.VipModel; import com.yunbao.common.bean.VipModel;
import com.yunbao.common.bean.WishListGiftConfModel; import com.yunbao.common.bean.WishListGiftConfModel;
import com.yunbao.common.bean.WishListModel; import com.yunbao.common.bean.WishListModel;
import com.yunbao.common.event.CheckCurrencyModel;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -1061,4 +1062,8 @@ public interface PDLiveApi {
Observable<ResponseModel<Object>> deductMoney( Observable<ResponseModel<Object>> deductMoney(
@Query("room_id") String roomId @Query("room_id") String roomId
); );
@GET("/api/public/?service=Sudgameserver.checkCurrency")
Observable<ResponseModel<CheckCurrencyModel>> checkCurrency(
);
} }

View File

@ -59,6 +59,7 @@ import com.yunbao.common.bean.UserAvatarSelectBean;
import com.yunbao.common.bean.VipModel; import com.yunbao.common.bean.VipModel;
import com.yunbao.common.bean.WishListGiftConfModel; import com.yunbao.common.bean.WishListGiftConfModel;
import com.yunbao.common.bean.WishListModel; import com.yunbao.common.bean.WishListModel;
import com.yunbao.common.event.CheckCurrencyModel;
import com.yunbao.common.http.API; import com.yunbao.common.http.API;
import com.yunbao.common.http.ResponseModel; import com.yunbao.common.http.ResponseModel;
import com.yunbao.common.http.base.CheckLiveCallBack; import com.yunbao.common.http.base.CheckLiveCallBack;
@ -2333,6 +2334,28 @@ public class LiveNetManager {
}).isDisposed(); }).isDisposed();
} }
public void checkCurrency(HttpCallback<CheckCurrencyModel> callback) {
API.get().pdLiveApi(mContext)
.checkCurrency()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<CheckCurrencyModel>>() {
@Override
public void accept(ResponseModel<CheckCurrencyModel> objectResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(objectResponseModel.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 gameStartCheckRemainingBalance(String mgId, String roomId, HttpCallback<CheckRemainingBalance> callback) { public void gameStartCheckRemainingBalance(String mgId, String roomId, HttpCallback<CheckRemainingBalance> callback) {
API.get().pdLiveApi(mContext) API.get().pdLiveApi(mContext)
.gameStartCheckRemainingBalance(mgId, roomId) .gameStartCheckRemainingBalance(mgId, roomId)