1.直播间游戏提示优化

2.战令经验值购买优化
This commit is contained in:
Martin
2024-06-28 17:52:41 +08:00
parent b68c7f1c46
commit 8f82c7c785
6 changed files with 125 additions and 76 deletions

View File

@@ -1,8 +1,10 @@
package com.yunbao.common.dialog;
import android.app.Dialog;
import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ProgressBar;
import android.widget.TextView;
@@ -17,7 +19,6 @@ import com.yunbao.common.http.base.HttpCallback;
import com.yunbao.common.http.live.LiveNetManager;
import com.yunbao.common.interfaces.OnItemClickListener;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
@@ -28,18 +29,17 @@ import java.math.BigDecimal;
* 战令等级 经验
*/
public class OrderLevelPopupWindow extends CenterPopupView {
private TextView orderLevel, orderLevelDiamond, balanceDiamond, current, expText;
private TextView orderLevelDiamond, balanceDiamond, current, expText;
private int currentExperience, totalExperience;//当前经验,全部经验
private String buyExp = "100", currentLevel, balance;
private String buyExp = "1", currentLevel, balance;
private ProgressBar progressBar;
private OrderLevelCallback orderLevelCallback;
private long maxExp;
private BattlePassUserInfoBean userInfoBean;
private Context mContext;
private EditText orderLevel;
public OrderLevelPopupWindow(@NonNull Context context, BattlePassUserInfoBean userInfoBean,
int mCurrentExperience, int mTotalExperience,
String mCurrentLevel, String mBalance, long maxExp, OrderLevelCallback mOrderLevelCallback) {
public OrderLevelPopupWindow(@NonNull Context context, BattlePassUserInfoBean userInfoBean, int mCurrentExperience, int mTotalExperience, String mCurrentLevel, String mBalance, long maxExp, OrderLevelCallback mOrderLevelCallback) {
super(context);
this.mContext = context;
this.userInfoBean = userInfoBean;
@@ -71,15 +71,15 @@ public class OrderLevelPopupWindow extends CenterPopupView {
progressBar.setProgress(currentExperience);
expText.setText(String.format("%s/%s", userInfoBean.getBattlePassExp(), userInfoBean.getNextLevelExp()));
current.setText(String.format("Lv%s", currentLevel));
balanceDiamond.setText(WordUtil.isNewZh()?"剩餘:":"Balance"+balance);
balanceDiamond.setText((WordUtil.isNewZh() ? "剩餘:" : "Balance") + balance);
findViewById(R.id.sub).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
float exp = new BigDecimal(buyExp).floatValue();
if (exp > 100) {
BigDecimal buyExpBigDecimal = new BigDecimal(buyExp).subtract(new BigDecimal("100"));
if (exp > 1) {
BigDecimal buyExpBigDecimal = new BigDecimal(buyExp).subtract(new BigDecimal("1"));
buyExp = String.valueOf(buyExpBigDecimal.intValue());
orderLevelDiamond.setText("00 = "+String.valueOf(buyExpBigDecimal.floatValue()));
orderLevelDiamond.setText("00 = " + buyExp + "00");
orderLevel.setText(buyExp);
}
}
@@ -88,15 +88,14 @@ public class OrderLevelPopupWindow extends CenterPopupView {
@Override
public void onClick(View view) {
float exp = new BigDecimal(buyExp).floatValue();
if (exp < maxExp && exp < 10000) {
BigDecimal buyExpBigDecimal = new BigDecimal(buyExp).add(new BigDecimal("100"));
if (exp < maxExp && (exp + 1) < 10000) {
BigDecimal buyExpBigDecimal = new BigDecimal(buyExp).add(new BigDecimal("1"));
buyExp = String.valueOf(buyExpBigDecimal.intValue());
orderLevelDiamond.setText("00 = "+String.valueOf(buyExpBigDecimal.floatValue()));
orderLevelDiamond.setText("00 = " + buyExp + "00");
orderLevel.setText(buyExp);
} else if (exp >= maxExp) {
ToastUtil.show(WordUtil.isNewZh() ? "经验已滿" : "Experience full");
ToastUtil.show(WordUtil.isNewZh() ? "經驗超出,僅需" + maxExp + "經驗可達滿级" : "Exp exceeds.Only " + maxExp + " exp is needed to reach the max level.");
}
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.war_order_close), new ViewClicksAntiShake.ViewClicksCallBack() {
@@ -105,56 +104,58 @@ public class OrderLevelPopupWindow extends CenterPopupView {
dialog.dismiss();
}
});
orderLevel.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
buyExp = charSequence.toString();
orderLevelDiamond.setText("00 = " + charSequence.toString() + "00");
}
@Override
public void afterTextChanged(Editable editable) {
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.buying_experience), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
LiveNetManager.get(getContext())
.buyingExperiencePoint(buyExp, new HttpCallback<ResponseModel<Object>>() {
@Override
public void onSuccess(ResponseModel<Object> data) {
if (orderLevelCallback != null) {
orderLevelCallback.onCallback(data.getData().getCode(), data.getMsg());
}
dialog.dismiss();
if (Integer.parseInt(orderLevel.getText().toString()+"00") <= maxExp) {
LiveNetManager.get(getContext()).buyingExperiencePoint(buyExp + "00", new HttpCallback<ResponseModel<Object>>() {
@Override
public void onSuccess(ResponseModel<Object> data) {
if (orderLevelCallback != null) {
orderLevelCallback.onCallback(data.getData().getCode(), data.getMsg());
}
@Override
public void onError(String error) {
if (orderLevelCallback != null) {
orderLevelCallback.onCallback(102, error);
}
dialog.dismiss();
}
});
}
});
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.tickets_plus_minus), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
DialogUitl.showSimpleInputDialog(mContext, getResources().getString(R.string.buying_experience_point), DialogUitl.INPUT_TYPE_NUMBER, 4, new DialogUitl.SimpleCallback2() {
@Override
public void onCancelClick() {
}
@Override
public void onConfirmClick(Dialog dialog, String content) {
orderLevel.setText(content);
}
});
}
});
IMLoginManager.get(getContext())
.updateUserCoin(new OnItemClickListener<JSONObject>() {
@Override
public void onItemClick(JSONObject bean, int position) {
if (bean != null) {
balance = bean.getString("coin");
balanceDiamond.setText(WordUtil.isNewZh()?"剩餘:":"Balance"+balance);
dialog.dismiss();
}
}
});
@Override
public void onError(String error) {
if (orderLevelCallback != null) {
orderLevelCallback.onCallback(102, error);
}
dialog.dismiss();
}
});
} else {
ToastUtil.show(WordUtil.isNewZh() ? "經驗超出,僅需" + maxExp + "經驗可達滿级" : "Exp exceeds.Only " + maxExp + " exp is needed to reach the max level.");
}
}
});
IMLoginManager.get(getContext()).updateUserCoin(new OnItemClickListener<JSONObject>() {
@Override
public void onItemClick(JSONObject bean, int position) {
if (bean != null) {
balance = bean.getString("coin");
balanceDiamond.setText((WordUtil.isNewZh() ? "剩餘:" : "Balance") + balance);
}
}
});
}
public interface OrderLevelCallback {

View File

@@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="240dp"
android:id="@+id/root"
android:layout_marginStart="17dp"
android:layout_marginEnd="17dp"
android:background="@drawable/background_order_dialog"
@@ -70,6 +71,7 @@
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="500/1000" />
</androidx.constraintlayout.widget.ConstraintLayout>
@@ -103,7 +105,7 @@
android:layout_height="match_parent"
android:layout_weight="1" />
<TextView
<EditText
android:id="@+id/tickets_plus_minus"
android:layout_width="0dp"
android:layout_height="match_parent"
@@ -111,6 +113,8 @@
android:background="@null"
android:gravity="center"
android:imeOptions="actionSend"
android:maxEms="4"
android:maxLength="4"
android:inputType="number"
android:singleLine="true"
android:text="0"
@@ -129,7 +133,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:text="100"
android:text="00 = 100"
android:textColor="#000000"
android:textSize="11sp" />