From 816fd21fbc0f58772354a7ed70139ed22e387a5e Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Tue, 7 Nov 2023 16:13:40 +0800 Subject: [PATCH] =?UTF-8?q?1.=20=E5=A2=9E=E5=8A=A0=E6=98=9F=E5=B8=81?= =?UTF-8?q?=E5=8F=82=E4=B8=8E=E6=B8=B8=E6=88=8F=E7=9A=84=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=EF=BC=88=E5=85=88=E5=BC=80=E9=80=9A=E5=B9=B6=E9=9A=90=E8=97=8F?= =?UTF-8?q?=EF=BC=8C=E6=9A=82=E4=B8=8D=E5=BC=80=E6=94=BE=EF=BC=89=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E6=8E=A7=E5=88=B6=E8=BF=98=E6=9C=AA=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=20=E5=9C=A8=E6=B8=B8=E6=88=8F=E9=97=A8=E6=A7=9B=E5=A4=84?= =?UTF-8?q?=EF=BC=8C=E7=94=A8=E6=88=B7=E5=8F=AF=E8=87=AA=E7=94=B1=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E9=87=91=E5=B8=81=E6=88=96=E6=98=9F=E5=B8=81=E4=BD=9C?= =?UTF-8?q?=E4=B8=BA=E6=B8=B8=E6=88=8F=E9=97=A8=E6=A7=9B=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=8F=AF=E8=BE=93=E5=85=A5=E7=9B=B8=E5=BA=94=E6=95=B0=E9=87=8F?= =?UTF-8?q?=EF=BC=8C=E6=98=9F=E5=B8=81=E9=97=A8=E6=A7=9B=E4=B8=BA10~1000?= =?UTF-8?q?=EF=BC=8C=E6=95=B0=E9=87=8F=E5=BF=85=E9=A1=BB=E4=B8=BA10?= =?UTF-8?q?=E7=9A=84=E5=80=8D=E6=95=B0=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dialog/CreateSudGamePopup.java | 131 +++++++++++++++--- .../common/dialog/SudGameListSelectPopup.java | 28 ++++ .../common/event/CurrencyTypeEvent.java | 26 ++++ .../com/yunbao/common/http/PDLiveApi.java | 1 + .../common/http/live/LiveNetManager.java | 4 +- .../res/layout/dialog_create_sud_game.xml | 23 ++- .../layout/dialog_home_create_sud_game.xml | 23 ++- .../layout/view_main_home_sud_game_list.xml | 4 +- 8 files changed, 216 insertions(+), 24 deletions(-) create mode 100644 common/src/main/java/com/yunbao/common/event/CurrencyTypeEvent.java diff --git a/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java b/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java index c31fb2b55..754c5d016 100644 --- a/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java @@ -2,12 +2,16 @@ package com.yunbao.common.dialog; import static androidx.core.content.ContextCompat.getSystemService; +import android.animation.ObjectAnimator; import android.content.Context; +import android.content.DialogInterface; import android.content.Intent; import android.os.Handler; import android.text.TextUtils; +import android.view.animation.LinearInterpolator; import android.view.inputmethod.InputMethodManager; import android.widget.EditText; +import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; @@ -21,6 +25,7 @@ import com.yunbao.common.activity.SudGameActivity; import com.yunbao.common.bean.CreateSudRoomModel; import com.yunbao.common.bean.CustomSidebarChildModel; import com.yunbao.common.event.CreateSudGameEvent; +import com.yunbao.common.event.CurrencyTypeEvent; import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; import com.yunbao.common.event.SudGameListDissMissEvent; import com.yunbao.common.http.base.HttpCallback; @@ -41,7 +46,7 @@ import java.util.Random; public class CreateSudGamePopup extends BottomPopupView { private List customSidebarChildModels = new ArrayList<>(); - private TextView createGameType; + private TextView createGameType, selectCurrencyType; private EditText roomName, gameSill; private long interactionID = 0; private String id; @@ -49,6 +54,10 @@ public class CreateSudGamePopup extends BottomPopupView { private boolean isHome = false; private List roomNames = new ArrayList<>(); + private String currencyType = "1", currencyTypeName; + private long animDuration = 500; + private ImageView roomGameArrow; + public CreateSudGamePopup(@NonNull Context context, List child, boolean isHome) { super(context); customSidebarChildModels = child; @@ -82,6 +91,7 @@ public class CreateSudGamePopup extends BottomPopupView { private String userName; private void initDate() { + currencyTypeName = getContext().getString(R.string.golden_bean); userName = IMLoginManager.get(getContext()).getUserInfo().getUserNicename(); roomNames.add(WordUtil.isNewZh() ? "一起玩吧!" : "Let's play together!"); roomNames.add(WordUtil.isNewZh() ? "來戰斗吧!" : "Let's fight!"); @@ -93,8 +103,10 @@ public class CreateSudGamePopup extends BottomPopupView { private void initView() { createGameType = findViewById(R.id.create_game_type); + selectCurrencyType = findViewById(R.id.select_currency_type); roomName = findViewById(R.id.room_name); gameSill = findViewById(R.id.game_sill); + roomGameArrow = findViewById(R.id.room_game_arrow); ViewClicksAntiShake.clicksAntiShake(createGameType, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { @@ -139,6 +151,7 @@ public class CreateSudGamePopup extends BottomPopupView { ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.create_room), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { + String sill = gameSill.getText().toString(); String name = roomName.getText().toString(); if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { @@ -171,43 +184,83 @@ public class CreateSudGamePopup extends BottomPopupView { } return; } + if (TextUtils.isEmpty(sill)) { - if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { - ToastUtil.show("数量区间为100--5W"); + if (TextUtils.equals(currencyType, "1")) { + if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { + ToastUtil.show("数量区间为10~1000"); + } else { + ToastUtil.show("The quantity range is 10 to 1000"); + } } else { - ToastUtil.show("The quantity range is 100 to 5 W"); + if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { + ToastUtil.show("数量区间为100--5W"); + } else { + ToastUtil.show("The quantity range is 100 to 5 W"); + } } + return; } - if (sill.length() > 6) { - if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { - ToastUtil.show("数量区间为100--5W"); - } else { - ToastUtil.show("The quantity range is 100 to 5 W"); - } - return; - } else { - int sillNumber = Integer.parseInt(sill); - if (sillNumber < 100 || sillNumber > 50000) { + if (TextUtils.equals(currencyType, "1")) { + if (sill.length() > 6) { if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { ToastUtil.show("数量区间为100--5W"); } else { ToastUtil.show("The quantity range is 100 to 5 W"); } return; + } else { + int sillNumber = Integer.parseInt(sill); + if (sillNumber < 100 || sillNumber > 50000) { + if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { + ToastUtil.show("数量区间为100--5W"); + } else { + ToastUtil.show("The quantity range is 100 to 5 W"); + } + return; + } + if (sillNumber % 10 != 0) { + if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { + ToastUtil.show("數量必須為10的倍數"); + } else { + ToastUtil.show("The number must be a multiple of 10"); + } + return; + } } - if (sillNumber % 10 != 0) { + } else { + if (sill.length() > 4) { if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { - ToastUtil.show("金豆數量必須為10的倍數"); + ToastUtil.show("数量区间为10~1000"); } else { - ToastUtil.show("The number of golden beans must be a multiple of 10"); + ToastUtil.show("The quantity range is 10 to 1000"); } return; + } else { + int sillNumber = Integer.parseInt(sill); + if (sillNumber < 10 || sillNumber > 1000) { + if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { + ToastUtil.show("数量区间为10~1000"); + } else { + ToastUtil.show("The quantity range is 10 to 1000"); + } + return; + } + if (sillNumber % 10 != 0) { + if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { + ToastUtil.show("數量必須為10的倍數"); + } else { + ToastUtil.show("The number must be a multiple of 10"); + } + return; + } } } + LiveNetManager.get(getContext()) - .createSudRoom(name, sill, id, new HttpCallback() { + .createSudRoom(name, sill, currencyType, id, new HttpCallback() { @Override public void onSuccess(CreateSudRoomModel data) { if (isHome) { @@ -240,6 +293,36 @@ public class CreateSudGamePopup extends BottomPopupView { roomName.setText(roomNames.get(randomNumber)); } }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.currency_type), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + ObjectAnimator animator = ObjectAnimator.ofFloat(roomGameArrow, "rotation", 0f, 90f); + animator.setDuration(animDuration); + animator.setInterpolator(new LinearInterpolator()); + animator.start(); + XPopup.Builder builder = new XPopup.Builder(getContext()).atView(findViewById(R.id.currency_type)); + builder.hasShadowBg(false) + .isDestroyOnDismiss(true) + .isLightStatusBar(false) + .popupPosition(PopupPosition.Bottom) + .asCustom(new SudGameListSelectPopup(getContext(), 5, currencyTypeName) + .setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + closeAnimSudGameListEvent(); + } + }) + ) + .show(); + } + }); + } + + private void closeAnimSudGameListEvent() { + ObjectAnimator animator = ObjectAnimator.ofFloat(roomGameArrow, "rotation", 90f, 0f); + animator.setDuration(animDuration); + animator.setInterpolator(new LinearInterpolator()); + animator.start(); } @Override @@ -255,4 +338,16 @@ public class CreateSudGamePopup extends BottomPopupView { id = event.getId(); } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onCurrencyTypeEvent(CurrencyTypeEvent event) { + currencyTypeName = event.getCurrencyTypeName(); + currencyType = event.getCurrencyType(); + selectCurrencyType.setText(currencyTypeName); + if (TextUtils.equals(currencyType, "1")) { + gameSill.setHint(getContext().getString(R.string.interactive_game_create_gold_bean_quantity)); + } else { + gameSill.setHint(WordUtil.isNewZh() ? "請選擇星幣數量" : "Please enter the number of Coins"); + } + } } diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java b/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java index 7f0571bcb..18b965509 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java @@ -15,6 +15,7 @@ import com.yunbao.common.R; import com.yunbao.common.adapter.SudTitleSelectAdapter; import com.yunbao.common.bean.CustomSidebarChildModel; import com.yunbao.common.event.CreateSudGameEvent; +import com.yunbao.common.event.CurrencyTypeEvent; import com.yunbao.common.event.RoomHolderTypeEvent; import com.yunbao.common.event.SudGameListEvent; import com.yunbao.common.event.SudGameListSillEvent; @@ -160,6 +161,33 @@ public class SudGameListSelectPopup extends AttachPopupView { dialog.dismiss(); } }); + } else if (mType == 5) { + selectString.add(getContext().getString(R.string.golden_bean)); + selectString.add(getContext().getString(R.string.coins)); + selectSill.put(getContext().getString(R.string.golden_bean), "1"); + selectSill.put(getContext().getString(R.string.coins), "2"); + index = 0; + for (int i = 0; i < selectString.size(); i++) { + if (TextUtils.equals(mSill, selectString.get(i))) { + index = i; + } + } + sudTitleSelectAdapter = new SudTitleSelectAdapter(selectString, index, mType); + sudTitleSelect.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); + sudTitleSelect.setAdapter(sudTitleSelectAdapter); + topSelect.setVisibility(GONE); + sudTitleSelectAdapter.setSudTitleSelectCallBack(new SudTitleSelectAdapter.SudTitleSelectCallBack() { + @Override + public void onSudTitleSelectCallBack(int index) { + String roomHolderTypeName = selectString.get(index); + String roomHolderType = selectSill.get(roomHolderTypeName); + Bus.get().post(new CurrencyTypeEvent().setCurrencyType(roomHolderType).setCurrencyTypeName(roomHolderTypeName)); + dialog.dismiss(); + if(onDismissListener!=null){ + onDismissListener.onDismiss(null); + } + } + }); } ViewClicksAntiShake.clicksAntiShake(topSelect, new ViewClicksAntiShake.ViewClicksCallBack() { @Override diff --git a/common/src/main/java/com/yunbao/common/event/CurrencyTypeEvent.java b/common/src/main/java/com/yunbao/common/event/CurrencyTypeEvent.java new file mode 100644 index 000000000..3a6d6ab8e --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/CurrencyTypeEvent.java @@ -0,0 +1,26 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; + +public class CurrencyTypeEvent extends BaseModel { + private String currencyType; + private String currencyTypeName; + + public String getCurrencyType() { + return currencyType; + } + + public CurrencyTypeEvent setCurrencyType(String currencyType) { + this.currencyType = currencyType; + return this; + } + + public String getCurrencyTypeName() { + return currencyTypeName; + } + + public CurrencyTypeEvent setCurrencyTypeName(String currencyTypeName) { + this.currencyTypeName = currencyTypeName; + 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 59dff12c6..1240eb605 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -996,6 +996,7 @@ public interface PDLiveApi { Observable> createSudRoom( @Query("room_name") String roomName, @Query("golden_bean_number") String goldenBeanNumber, + @Query("currency_type ") String currencyType , @Query("game_id") String gameId); /** 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 6bba433fa..8a66006db 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 @@ -2244,9 +2244,9 @@ public class LiveNetManager { }).isDisposed(); } - public void createSudRoom(String roomName, String goldenBeanNumber, String gameId, HttpCallback callback) { + public void createSudRoom(String roomName, String goldenBeanNumber, String currencyType, String gameId, HttpCallback callback) { API.get().pdLiveApi(mContext) - .createSudRoom(roomName, goldenBeanNumber, gameId) + .createSudRoom(roomName, goldenBeanNumber, currencyType, gameId) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Consumer>() { diff --git a/common/src/main/res/layout/dialog_create_sud_game.xml b/common/src/main/res/layout/dialog_create_sud_game.xml index 894d1f93c..9de019fe6 100644 --- a/common/src/main/res/layout/dialog_create_sud_game.xml +++ b/common/src/main/res/layout/dialog_create_sud_game.xml @@ -141,10 +141,31 @@ android:layout_marginTop="10dp"> + android:background="@drawable/bg_live_sud_list_input" + android:gravity="center_vertical" + android:orientation="horizontal"> + + + + android:background="@drawable/bg_live_sud_list_input_home" + android:gravity="center_vertical" + android:orientation="horizontal"> + + +