diff --git a/common/src/main/java/com/yunbao/common/activity/SudGameActivity.java b/common/src/main/java/com/yunbao/common/activity/SudGameActivity.java index 31ec7463f..4de7f8032 100644 --- a/common/src/main/java/com/yunbao/common/activity/SudGameActivity.java +++ b/common/src/main/java/com/yunbao/common/activity/SudGameActivity.java @@ -8,10 +8,13 @@ import android.widget.TextView; import androidx.lifecycle.Observer; import com.google.gson.Gson; +import com.lxj.xpopup.XPopup; import com.makeramen.roundedimageview.RoundedImageView; import com.yunbao.common.R; 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.event.CheckRemainingBalanceEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.http.base.HttpCallback; @@ -22,11 +25,14 @@ 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.LiveSudGameHistoryPopup; import com.yunbao.common.views.weight.ViewClicksAntiShake; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; +import java.util.ArrayList; +import java.util.List; import java.util.Locale; public class SudGameActivity extends AbsActivity { @@ -49,8 +55,28 @@ public class SudGameActivity extends AbsActivity { Bus.getOn(this); super.main(); initView(); + initDate(); } + private List customSidebarChildModels = new ArrayList<>(); + private void initDate() { + LiveNetManager.get(mContext) + .getCustomSidebarInfo("1", new HttpCallback>() { + @Override + public void onSuccess(List data) { + for (CustomSidebarInfoModel datum : data) { + if (datum.getType().equals("6")) { + customSidebarChildModels = datum.getChild(); + return; + } + } + } + @Override + public void onError(String error) { + + } + }); + } @Override protected void onDestroy() { Bus.getOff(this); @@ -81,6 +107,15 @@ public class SudGameActivity extends AbsActivity { finish(); } }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_history), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + + new XPopup.Builder(mContext) + .enableDrag(false) + .asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show(); + } + }); gameViewModel.gameViewLiveData.observe(this, new Observer() { @Override public void onChanged(View view) { diff --git a/common/src/main/java/com/yunbao/common/adapter/LiveSudGameHistoryAdapter.java b/common/src/main/java/com/yunbao/common/adapter/LiveSudGameHistoryAdapter.java new file mode 100644 index 000000000..4440bfd73 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/adapter/LiveSudGameHistoryAdapter.java @@ -0,0 +1,30 @@ +package com.yunbao.common.adapter; + +import android.content.Context; +import android.view.ViewGroup; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.GameRecordModel; +import com.yunbao.common.views.LiveSudGameHistoryViewHolder; + +public class LiveSudGameHistoryAdapter extends RefreshAdapter { + + public LiveSudGameHistoryAdapter(Context context) { + super(context); + } + + @NonNull + @Override + public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { + return new LiveSudGameHistoryViewHolder(mInflater.inflate(R.layout.item_live_sud_game_history, parent, false)); + } + + @Override + public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { + LiveSudGameHistoryViewHolder sudGameListViewHolder = (LiveSudGameHistoryViewHolder) holder; + sudGameListViewHolder.setData(mList.get(position)); + } +} diff --git a/common/src/main/java/com/yunbao/common/bean/GameRecordModel.java b/common/src/main/java/com/yunbao/common/bean/GameRecordModel.java new file mode 100644 index 000000000..73e383121 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/bean/GameRecordModel.java @@ -0,0 +1,69 @@ +package com.yunbao.common.bean; + +import com.google.gson.annotations.SerializedName; + +import java.util.List; + +public class GameRecordModel extends BaseModel{ + + @SerializedName("id") + private int id; + @SerializedName("title") + private String title; + @SerializedName("currency_type") + private int currencyType; + @SerializedName("settlement") + private int settlement; + @SerializedName("game_end_time") + private String gameEndTime; + @SerializedName("user_name") + private List userName; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public int getCurrencyType() { + return currencyType; + } + + public void setCurrencyType(int currencyType) { + this.currencyType = currencyType; + } + + public int getSettlement() { + return settlement; + } + + public void setSettlement(int settlement) { + this.settlement = settlement; + } + + public String getGameEndTime() { + return gameEndTime; + } + + public void setGameEndTime(String gameEndTime) { + this.gameEndTime = gameEndTime; + } + + public List getUserName() { + return userName; + } + + public void setUserName(List userName) { + this.userName = userName; + } +} 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 754c5d016..eea562efd 100644 --- a/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/CreateSudGamePopup.java @@ -54,7 +54,7 @@ public class CreateSudGamePopup extends BottomPopupView { private boolean isHome = false; private List roomNames = new ArrayList<>(); - private String currencyType = "1", currencyTypeName; + private String currencyType = "3", currencyTypeName; private long animDuration = 500; private ImageView roomGameArrow; @@ -95,9 +95,8 @@ public class CreateSudGamePopup extends BottomPopupView { userName = IMLoginManager.get(getContext()).getUserInfo().getUserNicename(); roomNames.add(WordUtil.isNewZh() ? "一起玩吧!" : "Let's play together!"); roomNames.add(WordUtil.isNewZh() ? "來戰斗吧!" : "Let's fight!"); - roomNames.add(WordUtil.isNewZh() ? "你的籌碼我收下了!" : ".I have taken your chips!"); - roomNames.add(WordUtil.isNewZh() ? "在線等遊戲夥伴~" : "Waiting for game partners online~ "); roomNames.add(WordUtil.isNewZh() ? "決戰到天亮 " : "Fight until dawn"); + roomNames.add(WordUtil.isNewZh() ? "在線等遊戲夥伴~" : "Waiting for game partners~"); roomNames.add(WordUtil.isNewZh() ? userName + "的房间 " : userName + "‘s room"); } @@ -162,8 +161,8 @@ public class CreateSudGamePopup extends BottomPopupView { } if (IMLoginManager.get(getContext()).getLocaleLanguage() != Locale.SIMPLIFIED_CHINESE) { - if (name.length() > 15) { - ToastUtil.show("Room name length is [1-15]"); + if (name.length() > 30) { + ToastUtil.show("Room name length is [1-30]"); return; } @@ -186,7 +185,7 @@ public class CreateSudGamePopup extends BottomPopupView { } if (TextUtils.isEmpty(sill)) { - if (TextUtils.equals(currencyType, "1")) { + if (TextUtils.equals(currencyType, "3")) { if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { ToastUtil.show("数量区间为10~1000"); } else { @@ -202,7 +201,7 @@ public class CreateSudGamePopup extends BottomPopupView { return; } - if (TextUtils.equals(currencyType, "1")) { + if (TextUtils.equals(currencyType, "3")) { if (sill.length() > 6) { if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { ToastUtil.show("数量区间为100--5W"); @@ -222,9 +221,9 @@ public class CreateSudGamePopup extends BottomPopupView { } if (sillNumber % 10 != 0) { if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { - ToastUtil.show("數量必須為10的倍數"); + ToastUtil.show("貨幣數量必須為10的倍數"); } else { - ToastUtil.show("The number must be a multiple of 10"); + ToastUtil.show("The number of currency must be a multiple of 10"); } return; } @@ -232,9 +231,9 @@ public class CreateSudGamePopup extends BottomPopupView { } else { if (sill.length() > 4) { if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { - ToastUtil.show("数量区间为10~1000"); + ToastUtil.show("星幣數量區間為[10 - 1000]"); } else { - ToastUtil.show("The quantity range is 10 to 1000"); + ToastUtil.show("The number range of star coins is [10-1000]"); } return; } else { @@ -249,9 +248,9 @@ public class CreateSudGamePopup extends BottomPopupView { } if (sillNumber % 10 != 0) { if (IMLoginManager.get(getContext()).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) { - ToastUtil.show("數量必須為10的倍數"); + ToastUtil.show("貨幣數量必須為10的倍數"); } else { - ToastUtil.show("The number must be a multiple of 10"); + ToastUtil.show("The number of currency must be a multiple of 10"); } return; } @@ -344,7 +343,7 @@ public class CreateSudGamePopup extends BottomPopupView { currencyTypeName = event.getCurrencyTypeName(); currencyType = event.getCurrencyType(); selectCurrencyType.setText(currencyTypeName); - if (TextUtils.equals(currencyType, "1")) { + if (TextUtils.equals(currencyType, "3")) { 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/SudGameListPopup.java b/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java index d38c8abdd..1e029143f 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameListPopup.java @@ -34,6 +34,7 @@ import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.LiveSudGameHistoryPopup; import com.yunbao.common.views.weight.ViewClicksAntiShake; import org.greenrobot.eventbus.Subscribe; @@ -113,7 +114,7 @@ public class SudGameListPopup extends BottomPopupView { @Override public void loadData(int p, HttpCallback callback) { page = p; - LiveHttpUtil.getRoomList(id, mSill, roomHolderType, mLiveUid, "1",p - 1, callback); + LiveHttpUtil.getRoomList(id, mSill, roomHolderType, mLiveUid, "3", p - 1, callback); } @Override @@ -265,7 +266,15 @@ public class SudGameListPopup extends BottomPopupView { .asCustom(new SudGameRuleBottom(getContext())).show(); } }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_history), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + new XPopup.Builder(getContext()) + .enableDrag(false) + .asCustom(new LiveSudGameHistoryPopup(getContext(), customSidebarChildModels)).show(); + } + }); } @Override 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 18b965509..4a4b1fb86 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameListSelectPopup.java @@ -3,7 +3,6 @@ package com.yunbao.common.dialog; import android.content.Context; import android.content.DialogInterface; import android.text.TextUtils; -import android.widget.PopupMenu; import android.widget.TextView; import androidx.annotation.NonNull; @@ -16,6 +15,7 @@ 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.LiveSudGameHistoryEvent; import com.yunbao.common.event.RoomHolderTypeEvent; import com.yunbao.common.event.SudGameListEvent; import com.yunbao.common.event.SudGameListSillEvent; @@ -59,6 +59,13 @@ public class SudGameListSelectPopup extends AttachPopupView { mSill = sill; } + public SudGameListSelectPopup(@NonNull Context context, String sill, List child) { + super(context); + this.mType = 8; + mSill = sill; + customSidebarChildModels = child; + } + protected int getImplLayoutId() { return R.layout.view_sud_game_slelect; @@ -164,7 +171,7 @@ public class SudGameListSelectPopup extends AttachPopupView { } 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.golden_bean), "3"); selectSill.put(getContext().getString(R.string.coins), "2"); index = 0; for (int i = 0; i < selectString.size(); i++) { @@ -183,7 +190,96 @@ public class SudGameListSelectPopup extends AttachPopupView { String roomHolderType = selectSill.get(roomHolderTypeName); Bus.get().post(new CurrencyTypeEvent().setCurrencyType(roomHolderType).setCurrencyTypeName(roomHolderTypeName)); dialog.dismiss(); - if(onDismissListener!=null){ + if (onDismissListener != null) { + onDismissListener.onDismiss(null); + } + } + }); + } else if (mType == 6) { + selectString.add(getContext().getString(R.string.interactive_game_create_unlimited)); + selectString.add(getContext().getString(R.string.golden_bean)); + selectString.add(getContext().getString(R.string.coins)); + selectSill.put(getContext().getString(R.string.interactive_game_create_unlimited), "0"); + selectSill.put(getContext().getString(R.string.golden_bean), "3"); + 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 LiveSudGameHistoryEvent().setType(roomHolderType).setTypeName(roomHolderTypeName).setIndex(3)); + dialog.dismiss(); + if (onDismissListener != null) { + onDismissListener.onDismiss(null); + } + } + }); + } else if (mType == 7) { + selectString.add(getContext().getString(R.string.interactive_game_create_unlimited)); + selectString.add(getContext().getString(R.string.sud_in_game_game_game_peer_today)); + selectString.add(getContext().getString(R.string.sud_in_game_game_game_peer_today_7)); + selectString.add(getContext().getString(R.string.sud_in_game_game_game_peer_today_30)); + selectSill.put(getContext().getString(R.string.interactive_game_create_unlimited), "0"); + selectSill.put(getContext().getString(R.string.sud_in_game_game_game_peer_today), "1"); + selectSill.put(getContext().getString(R.string.sud_in_game_game_game_peer_today_7), "2"); + selectSill.put(getContext().getString(R.string.sud_in_game_game_game_peer_today_30), "3"); + 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 LiveSudGameHistoryEvent().setType(roomHolderType).setTypeName(roomHolderTypeName).setIndex(2)); + dialog.dismiss(); + if (onDismissListener != null) { + onDismissListener.onDismiss(null); + } + } + }); + } else if (mType == 8) { + selectString.add(getContext().getString(R.string.interactive_game_create_unlimited)); + selectSill.put(getContext().getString(R.string.interactive_game_create_unlimited), "0"); + for (int i = 0; i < customSidebarChildModels.size(); i++) { + selectString.add(customSidebarChildModels.get(i).getTitle()); + selectSill.put(customSidebarChildModels.get(i).getTitle(), customSidebarChildModels.get(i).getId()); + } + 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 LiveSudGameHistoryEvent().setType(roomHolderType).setTypeName(roomHolderTypeName).setIndex(1)); + dialog.dismiss(); + if (onDismissListener != null) { onDismissListener.onDismiss(null); } } @@ -201,7 +297,7 @@ public class SudGameListSelectPopup extends AttachPopupView { @Override protected void onDismiss() { super.onDismiss(); - if(onDismissListener!=null){ + if (onDismissListener != null) { onDismissListener.onDismiss(null); } } diff --git a/common/src/main/java/com/yunbao/common/dialog/SudGameSearchDialogPopup.java b/common/src/main/java/com/yunbao/common/dialog/SudGameSearchDialogPopup.java index ba47fd92c..a54f30f42 100644 --- a/common/src/main/java/com/yunbao/common/dialog/SudGameSearchDialogPopup.java +++ b/common/src/main/java/com/yunbao/common/dialog/SudGameSearchDialogPopup.java @@ -172,7 +172,7 @@ public class SudGameSearchDialogPopup extends AbsDialogPopupWindow { private void search(String value) { LiveNetManager.get(mContext) - .searchRoomList("0", "0,0", "0", value, "1", 0, new HttpCallback>() { + .searchRoomList("0", "0,0", "0", value, "3", 0, new HttpCallback>() { @Override public void onSuccess(List data) { if (data.size() > 0) { diff --git a/common/src/main/java/com/yunbao/common/event/LiveSudGameHistoryEvent.java b/common/src/main/java/com/yunbao/common/event/LiveSudGameHistoryEvent.java new file mode 100644 index 000000000..a43ea4552 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/event/LiveSudGameHistoryEvent.java @@ -0,0 +1,36 @@ +package com.yunbao.common.event; + +import com.yunbao.common.bean.BaseModel; + +public class LiveSudGameHistoryEvent extends BaseModel { + private String type; + private String typeName; + private int index; + + public String getType() { + return type; + } + + public LiveSudGameHistoryEvent setType(String type) { + this.type = type; + return this; + } + + public String getTypeName() { + return typeName; + } + + public LiveSudGameHistoryEvent setTypeName(String typeName) { + this.typeName = typeName; + return this; + } + + public int getIndex() { + return index; + } + + public LiveSudGameHistoryEvent setIndex(int index) { + this.index = index; + return this; + } +} diff --git a/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java b/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java index 8c57cfd10..e496f63c7 100644 --- a/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java +++ b/common/src/main/java/com/yunbao/common/http/LiveHttpUtil.java @@ -970,14 +970,34 @@ public class LiveHttpUtil { } - public static void getRoomList(String sudGameId, String threshold, String roomHolderType, String liveUid,String currencyType,int page,HttpCallback callback ) { + public static void getRoomList(String sudGameId, String threshold, String roomHolderType, String liveUid, String currencyType, int page, HttpCallback callback) { HttpClient.getInstance().get("Sudgameserver.getRoomList", "Sudgameserver.getRoomList") - .params("sud_game_id",sudGameId) - .params("threshold",threshold) - .params("room_holder_type",roomHolderType) - .params("liveuid",liveUid) - .params("currency_type ",currencyType ) - .params("page",page) + .params("sud_game_id", sudGameId) + .params("threshold", threshold) + .params("room_holder_type", roomHolderType) + .params("liveuid", liveUid) + .params("currency_type ", currencyType) + .params("page", page) .execute(callback); } + + /** + * 游戲記錄 + * + * @param sudGameId sud_game_id 游戏ID + * @param currencyType currency_type 游戏货币类型 3=>金豆 2=>星币 0=>星币 + * @param dateType date_type 时间 0=>不限 1=>今日 2=>7日内 3=>30日内 + * @param page + * @param callback + */ + public static void gameRecord(String sudGameId, String currencyType, String dateType, int page, HttpCallback callback) { + HttpClient.getInstance().get("Sudgameserver.gameRecord", "Sudgameserver.gameRecord") + .params("sud_game_id", sudGameId) + .params("currency_type", currencyType) + .params("date_type", dateType) + .params("page", page) + .execute(callback); + } + + } diff --git a/common/src/main/java/com/yunbao/common/views/LiveSudGameHistoryPopup.java b/common/src/main/java/com/yunbao/common/views/LiveSudGameHistoryPopup.java new file mode 100644 index 000000000..77d276c54 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/LiveSudGameHistoryPopup.java @@ -0,0 +1,245 @@ +package com.yunbao.common.views; + +import android.animation.ObjectAnimator; +import android.content.Context; +import android.content.DialogInterface; +import android.util.Log; +import android.view.View; +import android.view.animation.LinearInterpolator; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.LinearLayoutManager; + +import com.google.gson.Gson; +import com.lxj.xpopup.XPopup; +import com.lxj.xpopup.core.BottomPopupView; +import com.lxj.xpopup.enums.PopupPosition; +import com.yunbao.common.R; +import com.yunbao.common.adapter.LiveSudGameHistoryAdapter; +import com.yunbao.common.adapter.RefreshAdapter; +import com.yunbao.common.bean.CustomSidebarChildModel; +import com.yunbao.common.bean.GameRecordModel; +import com.yunbao.common.custom.CommonRefreshView; +import com.yunbao.common.dialog.SudGameListSelectPopup; +import com.yunbao.common.event.LiveSudGameHistoryEvent; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.http.LiveHttpUtil; +import com.yunbao.common.utils.Bus; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +import org.greenrobot.eventbus.Subscribe; +import org.greenrobot.eventbus.ThreadMode; + +import java.util.ArrayList; +import java.util.List; + +public class LiveSudGameHistoryPopup extends BottomPopupView { + private CommonRefreshView mRefreshView; + private LiveSudGameHistoryAdapter sudGameListAdapter; + private String sudGameId = "0", currencyType = "0", dateType = "0"; + private String sudGameIdName, currencyTypeName, dateTypeName; + private int page = 1; + + private TextView gameTitle, roomSillText, houseOwnerText; + + private ImageView houseOwnerArrow, roomSillArrow, roomGameArrow; + private long animDuration = 500; + private List customSidebarChildModels = new ArrayList<>(); + + public LiveSudGameHistoryPopup(@NonNull Context context, List customSidebarChildModels) { + super(context); + this.customSidebarChildModels = customSidebarChildModels; + } + + @Override + protected int getImplLayoutId() { + return R.layout.dialog_live_sud_game_history; + } + + // 执行初始化操作,比如:findView,设置点击,或者任何你弹窗内的业务逻辑 + @Override + protected void onCreate() { + super.onCreate(); + Bus.getOn(this); + initView(); + initDate(); + } + + @Override + protected void onDismiss() { + Bus.getOff(this); + super.onDismiss(); + } + + private void initView() { + mRefreshView = findViewById(R.id.refreshView); + gameTitle = findViewById(R.id.game_title); + roomSillText = findViewById(R.id.room_sill_text); + houseOwnerText = findViewById(R.id.house_owner_text); + houseOwnerArrow = findViewById(R.id.house_owner_arrow); + roomSillArrow = findViewById(R.id.room_sill_arrow); + roomGameArrow = findViewById(R.id.room_game_arrow); + + mRefreshView.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false)); + sudGameListAdapter = new LiveSudGameHistoryAdapter(getContext()); + mRefreshView.setLoadMoreEnable(true); + mRefreshView.setRecyclerViewAdapter(sudGameListAdapter); + mRefreshView.setDataHelper(new CommonRefreshView.DataHelper() { + @Override + public RefreshAdapter getAdapter() { + return null; + } + + @Override + public void loadData(int p, HttpCallback callback) { + page = p; + LiveHttpUtil.gameRecord(sudGameId, currencyType, dateType, p - 1, callback); + } + + @Override + public List processData(String[] info) { + if (info.length > 0) { + List sudRoomListModels = new ArrayList<>(); + for (String json : info) { + GameRecordModel model = new Gson().fromJson(json, GameRecordModel.class); + sudRoomListModels.add(model); + } + return sudRoomListModels; + } else { + return new ArrayList<>(); + } + } + + @Override + public void onRefreshSuccess(List list, int listCount) { + Log.i("onRefreshSuccess", listCount + ""); + } + + @Override + public void onRefreshFailure() { + + } + + @Override + public void onLoadMoreSuccess(List loadItemList, int loadItemCount) { + sudGameListAdapter.insertList(loadItemList); + } + + @Override + public void onLoadMoreFailure() { + + } + }); + mRefreshView.initData(); + mRefreshView.setEmptyLayoutId(R.layout.sud_game_no); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.house_owner), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + ObjectAnimator animator = ObjectAnimator.ofFloat(houseOwnerArrow, "rotation", 0f, 90f); + animator.setDuration(500); + animator.setInterpolator(new LinearInterpolator()); + animator.start(); + XPopup.Builder builder = new XPopup.Builder(getContext()).atView(findViewById(R.id.house_owner)); + builder.hasShadowBg(false) + .isDestroyOnDismiss(true) + .isLightStatusBar(false) + .popupPosition(PopupPosition.Bottom) + .asCustom(new SudGameListSelectPopup(getContext(), 6, currencyTypeName) + .setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + closeAnimSudGameListEvent(houseOwnerArrow); + } + }) + ) + .show(); + + + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.room_sill), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + ObjectAnimator animator = ObjectAnimator.ofFloat(roomSillArrow, "rotation", 0f, 90f); + animator.setDuration(500); + animator.setInterpolator(new LinearInterpolator()); + animator.start(); + XPopup.Builder builder = new XPopup.Builder(getContext()).atView(findViewById(R.id.room_sill)); + builder.hasShadowBg(false) + .isDestroyOnDismiss(true) + .isLightStatusBar(false) + .popupPosition(PopupPosition.Bottom) + .asCustom(new SudGameListSelectPopup(getContext(), 7, dateTypeName) + .setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + closeAnimSudGameListEvent(roomSillArrow); + } + }) + ) + .show(); + + + } + }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.interactive_game_room_game), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + ObjectAnimator animator = ObjectAnimator.ofFloat(roomGameArrow, "rotation", 0f, 90f); + animator.setDuration(500); + animator.setInterpolator(new LinearInterpolator()); + animator.start(); + XPopup.Builder builder = new XPopup.Builder(getContext()).atView(findViewById(R.id.interactive_game_room_game)); + builder.hasShadowBg(false) + .isDestroyOnDismiss(true) + .isLightStatusBar(false) + .popupPosition(PopupPosition.Bottom) + .asCustom(new SudGameListSelectPopup(getContext(), sudGameIdName, customSidebarChildModels) + .setOnDismissListener(new DialogInterface.OnDismissListener() { + @Override + public void onDismiss(DialogInterface dialog) { + closeAnimSudGameListEvent(roomGameArrow); + } + }) + ) + .show(); + + + } + }); + } + + private void closeAnimSudGameListEvent(View view) { + ObjectAnimator animator = ObjectAnimator.ofFloat(view, "rotation", 90f, 0f); + animator.setDuration(animDuration); + animator.setInterpolator(new LinearInterpolator()); + animator.start(); + } + + private void initDate() { + sudGameIdName = getContext().getString(R.string.interactive_game_create_unlimited); + currencyTypeName = getContext().getString(R.string.interactive_game_create_unlimited); + dateTypeName = getContext().getString(R.string.interactive_game_create_unlimited); + } + + @Subscribe(threadMode = ThreadMode.MAIN) + public void onLiveSudGameHistoryEvent(LiveSudGameHistoryEvent event) { + if (event.getIndex() == 3) { + currencyTypeName = event.getTypeName(); + currencyType = event.getType(); + houseOwnerText.setText(currencyTypeName); + } else if (event.getIndex() == 2) { + dateTypeName = event.getTypeName(); + dateType = event.getType(); + roomSillText.setText(dateTypeName); + }else if (event.getIndex() == 1) { + sudGameIdName = event.getTypeName(); + sudGameId = event.getType(); + gameTitle.setText(sudGameIdName); + } + + mRefreshView.initData(); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/LiveSudGameHistoryViewHolder.java b/common/src/main/java/com/yunbao/common/views/LiveSudGameHistoryViewHolder.java new file mode 100644 index 000000000..1a16901dc --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/LiveSudGameHistoryViewHolder.java @@ -0,0 +1,51 @@ +package com.yunbao.common.views; + +import android.text.TextUtils; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.recyclerview.widget.RecyclerView; + +import com.yunbao.common.R; +import com.yunbao.common.bean.GameRecordModel; +import com.yunbao.common.glide.ImgLoader; + +public class LiveSudGameHistoryViewHolder extends RecyclerView.ViewHolder { + private TextView sudGameName, sudGameTime, sudGameUser, sudGameCoin; + + private ImageView sudGameType; + public LiveSudGameHistoryViewHolder(@NonNull View itemView) { + super(itemView); + sudGameName = itemView.findViewById(R.id.sud_game_name); + sudGameTime = itemView.findViewById(R.id.sud_game_time); + sudGameUser = itemView.findViewById(R.id.sud_game_user); + sudGameCoin = itemView.findViewById(R.id.sud_game_coin); + sudGameType = itemView.findViewById(R.id.sud_game_type); + } + + public void setData(GameRecordModel model) { + sudGameName.setText(model.getTitle()); + sudGameTime.setText(model.getGameEndTime()); + sudGameCoin.setText(String.valueOf(model.getSettlement())); + if (model.getCurrencyType()==3){ + + ImgLoader.display(itemView.getContext(),R.mipmap.gold_coin,sudGameType); + } if (model.getCurrencyType()==2) { + ImgLoader.display(itemView.getContext(),R.mipmap.icon_collectibles,sudGameType); + } + + StringBuffer stringBuffer = new StringBuffer(); + for (int i = 0; i < model.getUserName().size(); i++) { + if (i > model.getUserName().size() - 2) { + stringBuffer.append(model.getUserName().get(i)) + .append(" / "); + } else { + stringBuffer.append(model.getUserName().get(i)); + } + + } + sudGameUser.setText(stringBuffer.toString()); + } +} diff --git a/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java b/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java index 1fcb860c1..1b7f967e0 100644 --- a/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java +++ b/common/src/main/java/com/yunbao/common/views/LiveSudGamePopup.java @@ -15,6 +15,8 @@ import com.makeramen.roundedimageview.RoundedImageView; import com.yunbao.common.R; 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.event.CheckRemainingBalanceEvent; import com.yunbao.common.event.HideShowEvent; import com.yunbao.common.event.LiveSudGamePopupShowOrHideEvent; @@ -100,6 +102,15 @@ public class LiveSudGamePopup extends BottomPopupView { Bus.get().post(new LiveSudGamePopupShowOrHideEvent().setType(2)); } }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.sud_history), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + + new XPopup.Builder(getContext()) + .enableDrag(false) + .asCustom(new LiveSudGameHistoryPopup(getContext(), customSidebarChildModels)).show(); + } + }); ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.min_game), new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { @@ -156,9 +167,25 @@ public class LiveSudGamePopup extends BottomPopupView { // SudMGP平台64bit游戏ID gameViewModel.switchGame((Activity) getContext(), mLiveUid, mInteractionID); } - + private List customSidebarChildModels = new ArrayList<>(); private void initDate() { + LiveNetManager.get(getContext()) + .getCustomSidebarInfo("1", new HttpCallback>() { + @Override + public void onSuccess(List data) { + for (CustomSidebarInfoModel datum : data) { + if (datum.getType().equals("6")) { + customSidebarChildModels = datum.getChild(); + return; + } + } + } + @Override + public void onError(String error) { + + } + }); } public void BusGetOff() { diff --git a/common/src/main/res/layout/activity_sud_game.xml b/common/src/main/res/layout/activity_sud_game.xml index bc192ae65..6f6ae2637 100644 --- a/common/src/main/res/layout/activity_sud_game.xml +++ b/common/src/main/res/layout/activity_sud_game.xml @@ -29,10 +29,17 @@ + android:src="@mipmap/icon_interactive_game_create_room_seats" + android:visibility="gone" /> + + + + diff --git a/common/src/main/res/layout/dialog_live_sud_game_history.xml b/common/src/main/res/layout/dialog_live_sud_game_history.xml new file mode 100644 index 000000000..5c090a3f7 --- /dev/null +++ b/common/src/main/res/layout/dialog_live_sud_game_history.xml @@ -0,0 +1,213 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/dialog_sud_game_list.xml b/common/src/main/res/layout/dialog_sud_game_list.xml index 50ccf0fea..1364a052b 100644 --- a/common/src/main/res/layout/dialog_sud_game_list.xml +++ b/common/src/main/res/layout/dialog_sud_game_list.xml @@ -32,6 +32,14 @@ android:layout_height="1dp" android:layout_weight="1" /> + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/sud_game_no.xml b/common/src/main/res/layout/sud_game_no.xml new file mode 100644 index 000000000..cca4961ee --- /dev/null +++ b/common/src/main/res/layout/sud_game_no.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/mipmap-xxhdpi/background_sud_history.png b/common/src/main/res/mipmap-xxhdpi/background_sud_history.png new file mode 100644 index 000000000..8a126df5c Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/background_sud_history.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_collectibles.png b/common/src/main/res/mipmap-xxhdpi/icon_collectibles.png new file mode 100644 index 000000000..e839651fb Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_collectibles.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_sud_history.png b/common/src/main/res/mipmap-xxhdpi/icon_sud_history.png new file mode 100644 index 000000000..8291fe874 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_sud_history.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_sud_history_back.png b/common/src/main/res/mipmap-xxhdpi/icon_sud_history_back.png new file mode 100644 index 000000000..97590033c Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_sud_history_back.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_sud_history_live.png b/common/src/main/res/mipmap-xxhdpi/icon_sud_history_live.png new file mode 100644 index 000000000..23648bdd4 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_sud_history_live.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_sud_history_live2.png b/common/src/main/res/mipmap-xxhdpi/icon_sud_history_live2.png new file mode 100644 index 000000000..537a20b98 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_sud_history_live2.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/icon_sud_no_data.png b/common/src/main/res/mipmap-xxhdpi/icon_sud_no_data.png new file mode 100644 index 000000000..0d77b57f3 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/icon_sud_no_data.png differ diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index 2020cedff..c5433b00e 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1371,6 +1371,17 @@ Limited ride And limited avatar frame IN GAME minimize 随机 + 游戲記錄 + 時間: + 貨幣: + 貨幣 + 游戲類型 + 結算時間 + 對局用戶 + 暫無記錄~ + 今日 + 7日内 + 30日内 1. Interactive games are a new section provided by PDLIVE for users, who can participate in the game section on the homepage or in the live room; 2. Currently, we have launched \'GoBang\',\' Bumper car \',\' Flying Chess\', \'Minesweeping\', \'Dart Master\', and \'Monster Eliminating\'. We will provide more game types in the future. Stay tuned; 3. Users can customize the game threshold, which must be between 100 to 50000 gold beans or 10 to 1000 star coins, and the amount must be a multiple of 10; diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java index e1f24b3b5..c3ec658ce 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeGameViewHolder.java @@ -43,6 +43,7 @@ import com.yunbao.common.utils.Bus; import com.yunbao.common.utils.DeviceUtils; import com.yunbao.common.utils.DpUtil; import com.yunbao.common.utils.ToastUtil; +import com.yunbao.common.views.LiveSudGameHistoryPopup; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.main.R; @@ -109,7 +110,7 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement @Override public void loadData(int p, com.yunbao.common.http.HttpCallback callback) { - LiveHttpUtil.getRoomList(id, mSill, roomHolderType, "0", "1", p - 1, callback); + LiveHttpUtil.getRoomList(id, mSill, roomHolderType, "0", "3", p - 1, callback); } @Override @@ -281,7 +282,15 @@ public class MainHomeGameViewHolder extends AbsMainHomeChildViewHolder implement new SudGameSearchDialogPopup(mContext, true).showDialog(); } }); + ViewClicksAntiShake.clicksAntiShake(findViewById(com.yunbao.common.R.id.sud_history), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + new XPopup.Builder(mContext) + .enableDrag(false) + .asCustom(new LiveSudGameHistoryPopup(mContext, customSidebarChildModels)).show(); + } + }); LiveNetManager.get(mContext) .getCustomSidebarInfo("1", new HttpCallback>() { @Override diff --git a/main/src/main/res/layout/view_main_home_sud_game_list.xml b/main/src/main/res/layout/view_main_home_sud_game_list.xml index 17946d3e3..a7bf32d76 100644 --- a/main/src/main/res/layout/view_main_home_sud_game_list.xml +++ b/main/src/main/res/layout/view_main_home_sud_game_list.xml @@ -25,6 +25,14 @@ android:layout_height="1dp" android:layout_weight="1" /> + +