From a5d546d1d1b2a10b0481fe39a0714a3d79039317 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Fri, 22 Dec 2023 10:07:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=91=E6=8D=A2=E5=A5=96=E5=8A=B1=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WarOrderExchangeDetailsPopupWindow.java | 45 ++++++++++++++++--- .../com/yunbao/common/http/PDLiveApi.java | 12 +++++ .../common/http/live/LiveNetManager.java | 22 +++++++++ .../war_order_exchange_details_popup.xml | 1 + .../views/MainHomeCommunityViewHolder.java | 10 +---- 5 files changed, 76 insertions(+), 14 deletions(-) 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 @@