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"> + + +