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 @@