diff --git a/common/src/main/java/com/yunbao/common/dialog/WarOrderExchangeDetailsPopupWindow.java b/common/src/main/java/com/yunbao/common/dialog/WarOrderExchangeDetailsPopupWindow.java index 1d7ecbe70..88a410505 100644 --- a/common/src/main/java/com/yunbao/common/dialog/WarOrderExchangeDetailsPopupWindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/WarOrderExchangeDetailsPopupWindow.java @@ -10,7 +10,11 @@ import androidx.annotation.NonNull; import com.lxj.xpopup.core.CenterPopupView; import com.yunbao.common.R; import com.yunbao.common.glide.ImgLoader; +import com.yunbao.common.http.ResponseModel; +import com.yunbao.common.http.base.HttpCallback; +import com.yunbao.common.http.live.LiveNetManager; import com.yunbao.common.utils.WordUtil; +import com.yunbao.common.views.weight.ViewClicksAntiShake; import java.math.BigDecimal; @@ -23,6 +27,8 @@ public class WarOrderExchangeDetailsPopupWindow extends CenterPopupView { private int mPoint, mLimitQuantity, mScale; private String mImageUrl; private ImageView exchangeParticulars; + private String battlePassPointsId; + private WarOrderExchangeDetailsCallback orderExchangeDetailsCallback; /*** * @@ -33,12 +39,14 @@ public class WarOrderExchangeDetailsPopupWindow extends CenterPopupView { * @param imageUrl 物品图片的url */ public WarOrderExchangeDetailsPopupWindow(@NonNull Context context, int limitQuantity, - int point, int scale, String imageUrl) { + int point, int scale, String imageUrl, String battlePassPointsId, WarOrderExchangeDetailsCallback orderExchangeDetailsCallback) { super(context); mPoint = point; mLimitQuantity = limitQuantity; mScale = scale; mImageUrl = imageUrl; + this.battlePassPointsId = battlePassPointsId; + this.orderExchangeDetailsCallback = orderExchangeDetailsCallback; } @Override @@ -54,8 +62,8 @@ public class WarOrderExchangeDetailsPopupWindow extends CenterPopupView { exchangeParticulars = findViewById(R.id.exchange_particulars); pointExchange = findViewById(R.id.point_exchange); orderLevel.setText(buyExp); - BigDecimal needExpBigDecimal = new BigDecimal(buyExp).multiply(new BigDecimal(mScale)); - pointExchange.setText(String.format(WordUtil.getString(R.string.point_exchange),needExpBigDecimal.toString())); + BigDecimal needExpBigDecimal = new BigDecimal(buyExp).multiply(new BigDecimal(mScale)); + pointExchange.setText(String.format(WordUtil.getString(R.string.point_exchange), needExpBigDecimal.toString())); ImgLoader.display(getContext(), mImageUrl, exchangeParticulars); findViewById(R.id.sub).setOnClickListener(new OnClickListener() { @Override @@ -66,7 +74,7 @@ public class WarOrderExchangeDetailsPopupWindow extends CenterPopupView { buyExp = String.valueOf(buyExpBigDecimal.intValue()); orderLevel.setText(buyExp); BigDecimal needExpBigDecimal = buyExpBigDecimal.multiply(new BigDecimal(mScale)); - pointExchange.setText(String.format(WordUtil.getString(R.string.point_exchange),needExpBigDecimal.toString())); + pointExchange.setText(String.format(WordUtil.getString(R.string.point_exchange), needExpBigDecimal.toString())); } } }); @@ -80,9 +88,36 @@ public class WarOrderExchangeDetailsPopupWindow extends CenterPopupView { buyExp = String.valueOf(buyExpBigDecimal.intValue()); orderLevel.setText(buyExp); BigDecimal needExpBigDecimal = buyExpBigDecimal.multiply(new BigDecimal(mScale)); - pointExchange.setText(String.format(WordUtil.getString(R.string.point_exchange),needExpBigDecimal.toString())); + pointExchange.setText(String.format(WordUtil.getString(R.string.point_exchange), needExpBigDecimal.toString())); } } }); + ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.point_exchange_linear), new ViewClicksAntiShake.ViewClicksCallBack() { + @Override + public void onViewClicks() { + LiveNetManager.get(getContext()) + .pointsExchange(battlePassPointsId, buyExp, new HttpCallback>() { + @Override + public void onSuccess(ResponseModel data) { + dialog.dismiss(); + if (orderExchangeDetailsCallback != null) { + orderExchangeDetailsCallback.onCallback(data.getData().getCode(), data.getData().getMsg()); + } + } + + @Override + public void onError(String error) { + dialog.dismiss(); + if (orderExchangeDetailsCallback != null) { + orderExchangeDetailsCallback.onCallback(102, error); + } + } + }); + } + }); + } + + public interface WarOrderExchangeDetailsCallback { + 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 cf8469679..01af5c38a 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -1097,4 +1097,16 @@ public interface PDLiveApi { @GET("/api/public/?service=Livebattlepass.buyingExperiencePoint") Observable> buyingExperiencePoint(@Query("exp_count") String expCount); + + /** + * battle_pass_points_id => 兑换列表ID + * count => 兑换物品的数量 + * + * @return + */ + @GET("/api/public/?service=Livebattlepass.pointsExchange") + Observable> pointsExchange( + @Query("battle_pass_points_id ") String battlePassPointsId, + @Query("count ") String count + ); } 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 252732b82..41f0eb708 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,28 @@ public class LiveNetManager { }).isDisposed(); } + public void pointsExchange(String battlePassPointsId, String count, HttpCallback> callback) { + API.get().pdLiveApi(mContext) + .pointsExchange(battlePassPointsId, count) + .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 buyingExperiencePoint(String expCount, HttpCallback> callback) { API.get().pdLiveApi(mContext) .buyingExperiencePoint(expCount) diff --git a/common/src/main/res/layout/war_order_exchange_details_popup.xml b/common/src/main/res/layout/war_order_exchange_details_popup.xml index 4e85c34a3..780308348 100644 --- a/common/src/main/res/layout/war_order_exchange_details_popup.xml +++ b/common/src/main/res/layout/war_order_exchange_details_popup.xml @@ -83,6 +83,7 @@