兌換詳情弹窗

This commit is contained in:
18401019693
2023-12-20 17:37:18 +08:00
parent d415efde35
commit 1495bfee99
5 changed files with 202 additions and 6 deletions

View File

@@ -18,16 +18,17 @@ import com.yunbao.common.views.weight.ViewClicksAntiShake;
public class PromotionElitePopupWindow extends CenterPopupView {
private String enjoySpendMoney, quintessenceSpendMoney;//花费钱
private LiberalBattlePassPopupWindow.LiberalBattlePassCallback mPassCallback;
private String mBattlePassTypeId;
private String elitesTypeId,enjoyTypeId;
public PromotionElitePopupWindow(@NonNull Context context, String mEnjoySpendMoney,
String mQuintessenceSpendMoney, LiberalBattlePassPopupWindow.LiberalBattlePassCallback passCallback,
String battlePassTypeId) {
String elitesTypeId, String enjoyTypeId) {
super(context);
enjoySpendMoney = mEnjoySpendMoney;
quintessenceSpendMoney = mQuintessenceSpendMoney;
mPassCallback = passCallback;
mBattlePassTypeId = battlePassTypeId;
this.elitesTypeId = elitesTypeId;
this.enjoyTypeId = enjoyTypeId;
}
@Override
@@ -52,7 +53,7 @@ public class PromotionElitePopupWindow extends CenterPopupView {
new XPopup.Builder(getContext())
.enableDrag(false)
.maxWidth(DeviceUtils.getScreenHeight((Activity) getContext()) - DpUtil.dp2px(34))
.asCustom(new ActivateEliteBattleOrderPopupWindow(getContext(), quintessenceSpendMoney, true, mPassCallback, mBattlePassTypeId))
.asCustom(new ActivateEliteBattleOrderPopupWindow(getContext(), quintessenceSpendMoney, true, mPassCallback, elitesTypeId))
.show();
}
});
@@ -63,7 +64,7 @@ public class PromotionElitePopupWindow extends CenterPopupView {
new XPopup.Builder(getContext())
.enableDrag(false)
.maxWidth(DeviceUtils.getScreenHeight((Activity) getContext()) - DpUtil.dp2px(34))
.asCustom(new ActivateEliteBattleOrderPopupWindow(getContext(), enjoySpendMoney, false, mPassCallback, mBattlePassTypeId))
.asCustom(new ActivateEliteBattleOrderPopupWindow(getContext(), enjoySpendMoney, false, mPassCallback, enjoyTypeId))
.show();
}
});

View File

@@ -0,0 +1,88 @@
package com.yunbao.common.dialog;
import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
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.utils.WordUtil;
import java.math.BigDecimal;
/**
* 战令兑换详情
*/
public class WarOrderExchangeDetailsPopupWindow extends CenterPopupView {
private TextView orderLevel, pointExchange;
private String buyExp = "1";
private int mPoint, mLimitQuantity, mScale;
private String mImageUrl;
private ImageView exchangeParticulars;
/***
*
* @param context
* @param limitQuantity 最大限制数量
* @param point 自己的积分
* @param scale 兑换比例
* @param imageUrl 物品图片的url
*/
public WarOrderExchangeDetailsPopupWindow(@NonNull Context context, int limitQuantity,
int point, int scale, String imageUrl) {
super(context);
mPoint = point;
mLimitQuantity = limitQuantity;
mScale = scale;
mImageUrl = imageUrl;
}
@Override
protected int getImplLayoutId() {
return R.layout.war_order_exchange_details_popup;
}
// 执行初始化操作比如findView设置点击或者任何你弹窗内的业务逻辑
@Override
protected void onCreate() {
super.onCreate();
orderLevel = findViewById(R.id.tickets_plus_minus);
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()));
ImgLoader.display(getContext(), mImageUrl, exchangeParticulars);
findViewById(R.id.sub).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
float exp = new BigDecimal(buyExp).floatValue();
if (exp > 1) {
BigDecimal buyExpBigDecimal = new BigDecimal(buyExp).subtract(new BigDecimal("1"));
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()));
}
}
});
findViewById(R.id.add).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
int number = new BigDecimal(mScale).multiply(new BigDecimal(buyExp)).intValue();
int exp = new BigDecimal(buyExp).intValue();
if (exp < mLimitQuantity && number < mPoint) {
BigDecimal buyExpBigDecimal = new BigDecimal(buyExp).add(new BigDecimal("1"));
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()));
}
}
});
}
}