diff --git a/common/src/main/java/com/yunbao/common/views/GiftNumberPopup.java b/common/src/main/java/com/yunbao/common/views/GiftNumberPopup.java index 4294b8b34..7a654aaba 100644 --- a/common/src/main/java/com/yunbao/common/views/GiftNumberPopup.java +++ b/common/src/main/java/com/yunbao/common/views/GiftNumberPopup.java @@ -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)) { diff --git a/common/src/main/java/com/yunbao/common/views/InputCustomPopup.java b/common/src/main/java/com/yunbao/common/views/InputCustomPopup.java index b2598cd14..80b31e916 100644 --- a/common/src/main/java/com/yunbao/common/views/InputCustomPopup.java +++ b/common/src/main/java/com/yunbao/common/views/InputCustomPopup.java @@ -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);