From 42cfcce1dc3efe09accd9426d486634458513959 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 20 Dec 2023 15:28:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=BC=80=E9=80=9A=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=BC=B9=E7=AA=97=E5=9B=9E=E8=B0=83=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ActivateEliteBattleOrderPopupWindow.java | 12 +++++- .../dialog/LiberalBattlePassPopupWindow.java | 38 ++++++++++++++++++- .../dialog/PromotionElitePopupWindow.java | 14 +++++-- .../com/yunbao/common/http/PDLiveApi.java | 3 ++ .../common/http/live/LiveNetManager.java | 23 +++++++++++ .../res/layout/liberal_battle_pass_popup.xml | 37 ++++++++++++------ .../views/MainHomeCommunityViewHolder.java | 3 +- 7 files changed, 111 insertions(+), 19 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/dialog/ActivateEliteBattleOrderPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/ActivateEliteBattleOrderPopupWindow.java index f028bd1e2..efe82b89d 100644 --- a/common/src/main/java/com/yunbao/common/dialog/ActivateEliteBattleOrderPopupWindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/ActivateEliteBattleOrderPopupWindow.java @@ -17,11 +17,18 @@ public class ActivateEliteBattleOrderPopupWindow extends CenterPopupView { private boolean elites;//是否精英战令 private String spendMoney;//花费钱 private Button buttonWarOrder; + private LiberalBattlePassPopupWindow.LiberalBattlePassCallback mPassCallback; + private String mBattlePassTypeId; - public ActivateEliteBattleOrderPopupWindow(@NonNull Context context, String mSpendMoney, boolean elites) { + public ActivateEliteBattleOrderPopupWindow(@NonNull Context context, String mSpendMoney, + boolean elites, + LiberalBattlePassPopupWindow.LiberalBattlePassCallback passCallback + , String battlePassTypeId) { super(context); this.elites = elites; spendMoney = mSpendMoney; + mPassCallback=passCallback; + mBattlePassTypeId = battlePassTypeId; } @Override @@ -64,9 +71,10 @@ public class ActivateEliteBattleOrderPopupWindow extends CenterPopupView { new XPopup.Builder(getContext()) .enableDrag(false) .maxWidth(DeviceUtils.getScreenHeight((Activity) getContext()) - DpUtil.dp2px(34)) - .asCustom(new LiberalBattlePassPopupWindow(getContext(), spendMoney, elites)) + .asCustom(new LiberalBattlePassPopupWindow(getContext(), spendMoney, elites,mPassCallback,mBattlePassTypeId)) .show(); } }); + } } diff --git a/common/src/main/java/com/yunbao/common/dialog/LiberalBattlePassPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/LiberalBattlePassPopupWindow.java index 08123554c..b2767f518 100644 --- a/common/src/main/java/com/yunbao/common/dialog/LiberalBattlePassPopupWindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/LiberalBattlePassPopupWindow.java @@ -11,17 +11,24 @@ import androidx.annotation.NonNull; import com.lxj.xpopup.core.CenterPopupView; import com.yunbao.common.R; +import com.yunbao.common.http.ResponseModel; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.views.weight.ViewClicksAntiShake; public class LiberalBattlePassPopupWindow extends CenterPopupView { private String spendMoney;//花费钱 private boolean mElites;//是否精英战令 private TextView liberalBattlePass; + private LiberalBattlePassCallback mPassCallback; + private String mBattlePassTypeId; - public LiberalBattlePassPopupWindow(@NonNull Context context, String mSpendMoney, boolean elites) { + public LiberalBattlePassPopupWindow(@NonNull Context context, String mSpendMoney, boolean elites, LiberalBattlePassCallback passCallback, String battlePassTypeId) { super(context); spendMoney = mSpendMoney; mElites = elites; + mPassCallback = passCallback; + mBattlePassTypeId = battlePassTypeId; } protected int getImplLayoutId() { @@ -53,7 +60,36 @@ public class LiberalBattlePassPopupWindow extends CenterPopupView { dialog.dismiss(); } }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.liberal_battle_sure), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + LiveNetManager.get(getContext()). + upgradesBattlePass(mBattlePassTypeId, new HttpCallback>() { + @Override + public void onSuccess(ResponseModel data) { + dialog.dismiss(); + if (mPassCallback != null) { + mPassCallback.onCallback(data.getData().getCode(), data.getData().getMsg()); + } + } + + @Override + public void onError(String error) { + + dialog.dismiss(); + if (mPassCallback != null) { + mPassCallback.onCallback(102, error); + } + } + }); + + } + }); } + + public interface LiberalBattlePassCallback { + void onCallback(int code, String msg); + } } diff --git a/common/src/main/java/com/yunbao/common/dialog/PromotionElitePopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/PromotionElitePopupWindow.java index cefbcbfd5..1283582d7 100644 --- a/common/src/main/java/com/yunbao/common/dialog/PromotionElitePopupWindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/PromotionElitePopupWindow.java @@ -16,12 +16,18 @@ import com.yunbao.common.views.weight.ViewClicksAntiShake; * 升級精英/尊享戰令 */ public class PromotionElitePopupWindow extends CenterPopupView { - private String enjoySpendMoney,quintessenceSpendMoney;//花费钱 + private String enjoySpendMoney, quintessenceSpendMoney;//花费钱 + private LiberalBattlePassPopupWindow.LiberalBattlePassCallback mPassCallback; + private String mBattlePassTypeId; - public PromotionElitePopupWindow(@NonNull Context context, String mEnjoySpendMoney, String mQuintessenceSpendMoney) { + public PromotionElitePopupWindow(@NonNull Context context, String mEnjoySpendMoney, + String mQuintessenceSpendMoney, LiberalBattlePassPopupWindow.LiberalBattlePassCallback passCallback, + String battlePassTypeId) { super(context); enjoySpendMoney = mEnjoySpendMoney; quintessenceSpendMoney = mQuintessenceSpendMoney; + mPassCallback = passCallback; + mBattlePassTypeId = battlePassTypeId; } @Override @@ -46,7 +52,7 @@ public class PromotionElitePopupWindow extends CenterPopupView { new XPopup.Builder(getContext()) .enableDrag(false) .maxWidth(DeviceUtils.getScreenHeight((Activity) getContext()) - DpUtil.dp2px(34)) - .asCustom(new ActivateEliteBattleOrderPopupWindow(getContext(), quintessenceSpendMoney, true)) + .asCustom(new ActivateEliteBattleOrderPopupWindow(getContext(), quintessenceSpendMoney, true, mPassCallback, mBattlePassTypeId)) .show(); } }); @@ -57,7 +63,7 @@ public class PromotionElitePopupWindow extends CenterPopupView { new XPopup.Builder(getContext()) .enableDrag(false) .maxWidth(DeviceUtils.getScreenHeight((Activity) getContext()) - DpUtil.dp2px(34)) - .asCustom(new ActivateEliteBattleOrderPopupWindow(getContext(), enjoySpendMoney, false)) + .asCustom(new ActivateEliteBattleOrderPopupWindow(getContext(), enjoySpendMoney, false, mPassCallback, mBattlePassTypeId)) .show(); } }); 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 b0f7ca437..e3d996bb8 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -1091,4 +1091,7 @@ public interface PDLiveApi { Observable> buyTicket( @Field("quantity") String quantity ); + + @GET("/api/public/?service=Livebattlepass.upgradesBattlePass") + Observable> upgradesBattlePass(@Query("battle_pass_type_id") String battlePassTypeId); } 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 5716e4c33..3e3df7f99 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 @@ -2460,6 +2460,29 @@ public class LiveNetManager { }).isDisposed(); } + public void upgradesBattlePass(String battlePassTypeId, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .upgradesBattlePass(battlePassTypeId) + .subscribeOn(Schedulers.io()) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe(new Consumer>() { + @Override + public void accept(ResponseModel objectResponseModel) throws Exception { + if (callback != null) { + callback.onSuccess(objectResponseModel); + } + + } + }, new Consumer() { + @Override + public void accept(Throwable throwable) throws Exception { + if (callback != null) { + callback.onError(mContext.getString(R.string.net_error)); + } + } + }).isDisposed(); + } + public void quickGiftSendGift(String quickGiftNumber, String liveUid, String stream, HttpCallback callback) { API.get().pdLiveApi(mContext) .quickGiftSendGift(quickGiftNumber, liveUid, stream) diff --git a/common/src/main/res/layout/liberal_battle_pass_popup.xml b/common/src/main/res/layout/liberal_battle_pass_popup.xml index 57f1ce146..e49136d12 100644 --- a/common/src/main/res/layout/liberal_battle_pass_popup.xml +++ b/common/src/main/res/layout/liberal_battle_pass_popup.xml @@ -23,28 +23,43 @@ android:layout_height="wrap_content" android:layout_marginTop="57dp"> - -