兑换奖励接口

This commit is contained in:
18401019693 2023-12-22 10:07:47 +08:00
parent f46d14ce28
commit a5d546d1d1
5 changed files with 76 additions and 14 deletions

View File

@ -10,7 +10,11 @@ import androidx.annotation.NonNull;
import com.lxj.xpopup.core.CenterPopupView; import com.lxj.xpopup.core.CenterPopupView;
import com.yunbao.common.R; import com.yunbao.common.R;
import com.yunbao.common.glide.ImgLoader; 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.utils.WordUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -23,6 +27,8 @@ public class WarOrderExchangeDetailsPopupWindow extends CenterPopupView {
private int mPoint, mLimitQuantity, mScale; private int mPoint, mLimitQuantity, mScale;
private String mImageUrl; private String mImageUrl;
private ImageView exchangeParticulars; private ImageView exchangeParticulars;
private String battlePassPointsId;
private WarOrderExchangeDetailsCallback orderExchangeDetailsCallback;
/*** /***
* *
@ -33,12 +39,14 @@ public class WarOrderExchangeDetailsPopupWindow extends CenterPopupView {
* @param imageUrl 物品图片的url * @param imageUrl 物品图片的url
*/ */
public WarOrderExchangeDetailsPopupWindow(@NonNull Context context, int limitQuantity, 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); super(context);
mPoint = point; mPoint = point;
mLimitQuantity = limitQuantity; mLimitQuantity = limitQuantity;
mScale = scale; mScale = scale;
mImageUrl = imageUrl; mImageUrl = imageUrl;
this.battlePassPointsId = battlePassPointsId;
this.orderExchangeDetailsCallback = orderExchangeDetailsCallback;
} }
@Override @Override
@ -54,8 +62,8 @@ public class WarOrderExchangeDetailsPopupWindow extends CenterPopupView {
exchangeParticulars = findViewById(R.id.exchange_particulars); exchangeParticulars = findViewById(R.id.exchange_particulars);
pointExchange = findViewById(R.id.point_exchange); pointExchange = findViewById(R.id.point_exchange);
orderLevel.setText(buyExp); orderLevel.setText(buyExp);
BigDecimal needExpBigDecimal = new BigDecimal(buyExp).multiply(new BigDecimal(mScale)); BigDecimal needExpBigDecimal = new BigDecimal(buyExp).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()));
ImgLoader.display(getContext(), mImageUrl, exchangeParticulars); ImgLoader.display(getContext(), mImageUrl, exchangeParticulars);
findViewById(R.id.sub).setOnClickListener(new OnClickListener() { findViewById(R.id.sub).setOnClickListener(new OnClickListener() {
@Override @Override
@ -66,7 +74,7 @@ public class WarOrderExchangeDetailsPopupWindow extends CenterPopupView {
buyExp = String.valueOf(buyExpBigDecimal.intValue()); buyExp = String.valueOf(buyExpBigDecimal.intValue());
orderLevel.setText(buyExp); orderLevel.setText(buyExp);
BigDecimal needExpBigDecimal = buyExpBigDecimal.multiply(new BigDecimal(mScale)); 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()); buyExp = String.valueOf(buyExpBigDecimal.intValue());
orderLevel.setText(buyExp); orderLevel.setText(buyExp);
BigDecimal needExpBigDecimal = buyExpBigDecimal.multiply(new BigDecimal(mScale)); 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<ResponseModel<Object>>() {
@Override
public void onSuccess(ResponseModel<Object> 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);
} }
} }

View File

@ -1097,4 +1097,16 @@ public interface PDLiveApi {
@GET("/api/public/?service=Livebattlepass.buyingExperiencePoint") @GET("/api/public/?service=Livebattlepass.buyingExperiencePoint")
Observable<ResponseModel<Object>> buyingExperiencePoint(@Query("exp_count") String expCount); Observable<ResponseModel<Object>> buyingExperiencePoint(@Query("exp_count") String expCount);
/**
* battle_pass_points_id => 兑换列表ID
* count => 兑换物品的数量
*
* @return
*/
@GET("/api/public/?service=Livebattlepass.pointsExchange")
Observable<ResponseModel<Object>> pointsExchange(
@Query("battle_pass_points_id ") String battlePassPointsId,
@Query("count ") String count
);
} }

View File

@ -2460,6 +2460,28 @@ public class LiveNetManager {
}).isDisposed(); }).isDisposed();
} }
public void pointsExchange(String battlePassPointsId, String count, HttpCallback<ResponseModel<Object>> callback) {
API.get().pdLiveApi(mContext)
.pointsExchange(battlePassPointsId, count)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Consumer<ResponseModel<Object>>() {
@Override
public void accept(ResponseModel<Object> objectResponseModel) throws Exception {
if (callback != null) {
callback.onSuccess(objectResponseModel);
}
}
}, new Consumer<Throwable>() {
@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<ResponseModel<Object>> callback) { public void buyingExperiencePoint(String expCount, HttpCallback<ResponseModel<Object>> callback) {
API.get().pdLiveApi(mContext) API.get().pdLiveApi(mContext)
.buyingExperiencePoint(expCount) .buyingExperiencePoint(expCount)

View File

@ -83,6 +83,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/point_exchange_linear"
android:layout_width="140dp" android:layout_width="140dp"
android:layout_height="38dp" android:layout_height="38dp"
android:layout_gravity="center" android:layout_gravity="center"

View File

@ -39,9 +39,6 @@ import com.yunbao.common.bean.CoolConfig;
import com.yunbao.common.bean.LiveBean; import com.yunbao.common.bean.LiveBean;
import com.yunbao.common.bean.NativeCallbackModel; import com.yunbao.common.bean.NativeCallbackModel;
import com.yunbao.common.dialog.CinemaTicketPopupWindow; import com.yunbao.common.dialog.CinemaTicketPopupWindow;
import com.yunbao.common.dialog.LiberalBattlePassPopupWindow;
import com.yunbao.common.dialog.OrderLevelPopupWindow;
import com.yunbao.common.dialog.PromotionElitePopupWindow;
import com.yunbao.common.dialog.WarOrderExchangeDetailsPopupWindow; import com.yunbao.common.dialog.WarOrderExchangeDetailsPopupWindow;
import com.yunbao.common.event.JavascriptInterfaceEvent; import com.yunbao.common.event.JavascriptInterfaceEvent;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
@ -234,12 +231,7 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
findViewById(R.id.native_callback).setOnClickListener(new View.OnClickListener() { findViewById(R.id.native_callback).setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
new XPopup.Builder(mContext)
.enableDrag(false)
.maxWidth(DeviceUtils.getScreenHeight((Activity) mContext) - DpUtil.dp2px(34))
.asCustom(new WarOrderExchangeDetailsPopupWindow(mContext,10,90000,10,
"https://downs.yaoulive.com/20230706/0572c0f694601f4d2695cd210effbe93.jpeg?imageView2/2/w/600/h/600"))
.show();
} }
}); });
}//战令等级 }//战令等级