From f46d14ce2879c6c61ce30201a7c40b0f79d43c6c Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Thu, 21 Dec 2023 15:24:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=AD=E4=B9=B0=E7=BB=8F=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/dialog/OrderLevelPopupWindow.java | 34 ++++++++++++++++++- .../com/yunbao/common/http/PDLiveApi.java | 3 ++ .../common/http/live/LiveNetManager.java | 23 ++++++++++++- .../src/main/res/layout/order_level_popup.xml | 1 + 4 files changed, 59 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/dialog/OrderLevelPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/OrderLevelPopupWindow.java index 0cc8aa227..560227642 100644 --- a/common/src/main/java/com/yunbao/common/dialog/OrderLevelPopupWindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/OrderLevelPopupWindow.java @@ -9,6 +9,9 @@ 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; import java.math.BigDecimal; @@ -21,13 +24,17 @@ public class OrderLevelPopupWindow extends CenterPopupView { private int currentExperience, totalExperience;//当前经验,全部经验 private String buyExp = "100", currentLevel, balance; private ProgressBar progressBar; + private OrderLevelCallback orderLevelCallback; - public OrderLevelPopupWindow(@NonNull Context context, int mCurrentExperience, int mTotalExperience, String mCurrentLevel, String mBalance) { + public OrderLevelPopupWindow(@NonNull Context context, + int mCurrentExperience, int mTotalExperience, + String mCurrentLevel, String mBalance, OrderLevelCallback mOrderLevelCallback) { super(context); currentExperience = mCurrentExperience; totalExperience = mTotalExperience; currentLevel = mCurrentLevel; balance = mBalance; + orderLevelCallback = mOrderLevelCallback; } @Override @@ -80,5 +87,30 @@ public class OrderLevelPopupWindow extends CenterPopupView { dialog.dismiss(); } }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.buying_experience), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + LiveNetManager.get(getContext()) + .buyingExperiencePoint(buyExp, new HttpCallback>() { + @Override + public void onSuccess(ResponseModel data) { + if (orderLevelCallback != null) { + orderLevelCallback.onCallback(data.getData().getCode(), data.getMsg()); + }dialog.dismiss(); + } + + @Override + public void onError(String error) { + if (orderLevelCallback != null) { + orderLevelCallback.onCallback(102, error); + } dialog.dismiss(); + } + }); + } + }); + } + + public interface OrderLevelCallback { + void onCallback(int code, String msg); } } 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 e3d996bb8..cf8469679 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -1094,4 +1094,7 @@ public interface PDLiveApi { @GET("/api/public/?service=Livebattlepass.upgradesBattlePass") Observable> upgradesBattlePass(@Query("battle_pass_type_id") String battlePassTypeId); + + @GET("/api/public/?service=Livebattlepass.buyingExperiencePoint") + Observable> buyingExperiencePoint(@Query("exp_count") String expCount); } 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 3e3df7f99..252732b82 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,13 +2460,34 @@ public class LiveNetManager { }).isDisposed(); } + public void buyingExperiencePoint(String expCount, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .buyingExperiencePoint(expCount) + .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 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); diff --git a/common/src/main/res/layout/order_level_popup.xml b/common/src/main/res/layout/order_level_popup.xml index e1037fe28..f7ffef01b 100644 --- a/common/src/main/res/layout/order_level_popup.xml +++ b/common/src/main/res/layout/order_level_popup.xml @@ -138,6 +138,7 @@