修复礼物栏自定义数量过长导致的闪退问题

This commit is contained in:
zlzw 2023-08-07 18:26:45 +08:00
parent d899975495
commit 3ab91a74d1
2 changed files with 13 additions and 1 deletions

View File

@ -54,7 +54,9 @@ public class GiftNumberPopup extends BottomPopupView {
new XPopup.Builder(getContext())
.asCustom(new InputCustomPopup(getContext(),
getContext().getString(R.string.the_title_financier3),
R.string.custom_quantity, true).setListener(new InputCustomPopup.InputCustomListener() {
R.string.custom_quantity, true)
.setMaxValue(4)
.setListener(new InputCustomPopup.InputCustomListener() {
@Override
public void onConfirm(String text) {
if (!TextUtils.isEmpty(text)) {

View File

@ -1,6 +1,7 @@
package com.yunbao.common.views;
import android.content.Context;
import android.text.InputFilter;
import android.text.InputType;
import android.text.TextUtils;
import android.view.View;
@ -22,6 +23,7 @@ public class InputCustomPopup extends CenterPopupView {
private String message = "";
private int title = R.string.dialog_tip;
private boolean isType;
private int maxValue=0;
public InputCustomPopup(@NonNull Context context, String message, int title) {
super(context);
@ -36,6 +38,11 @@ public class InputCustomPopup extends CenterPopupView {
this.isType = isType;
}
public InputCustomPopup setMaxValue(int maxValue) {
this.maxValue = maxValue;
return this;
}
public InputCustomPopup(@NonNull Context context, int title) {
super(context);
this.title = title;
@ -53,6 +60,9 @@ public class InputCustomPopup extends CenterPopupView {
super.onCreate();
EditText content = findViewById(R.id.content);
TextView titleText = findViewById(R.id.title);
if(maxValue>0){
content.setFilters(new InputFilter[]{new InputFilter.LengthFilter(maxValue)});
}
if (isType) {
content.setHint(message);