Java 类android.text.InputFilter.LengthFilter 实例源码

项目:MyLife    文件:TextViewUtils.java   
public static void setMaxLength(TextView textView, int length) {
    InputFilter[] inputFilters = textView.getFilters();
    ArrayList<InputFilter> inputFilterArray = new ArrayList<InputFilter>();

    if (inputFilters != null) {
        for (int i = 0; i < inputFilters.length; i++) {
            InputFilter inputFilter = inputFilters[i];

            if (!(inputFilter instanceof LengthFilter))
                inputFilterArray.add(inputFilter);
        }

    }
    inputFilterArray.add(new LengthFilter(length));
    textView.setFilters(inputFilterArray.toArray(new InputFilter[0]));
}
项目:FMTech    文件:AclPickerActionBarView.java   
protected final void onFinishInflate()
{
  super.onFinishInflate();
  this.d = findViewById(aau.xL);
  this.d.setOnClickListener(new gob(this));
  this.e = findViewById(aau.xR);
  a(false);
  this.e.setOnClickListener(new goc(this));
  this.h = true;
  this.f = findViewById(aau.xS);
  this.f.setOnClickListener(new god(this));
  this.g = findViewById(aau.xQ);
  this.g.setOnClickListener(new goe(this));
  this.a = ((SearchView)findViewById(aau.xT));
  this.a.a(false);
  EditText localEditText = (EditText)this.a.findViewById(aau.xW);
  localEditText.setTextAppearance(getContext(), aau.xY);
  InputFilter[] arrayOfInputFilter = new InputFilter[1];
  arrayOfInputFilter[0] = new InputFilter.LengthFilter(200);
  localEditText.setFilters(arrayOfInputFilter);
  localEditText.addTextChangedListener(new gof(this, localEditText));
}
项目:EditTagsView    文件:EditTagsView.java   
private void initView(Context context) {
    float scale = context.getResources().getDisplayMetrics().density;
    dp10 = (int) (10 * scale + 0.5f);
    mTags = new ArrayList<String>();
    LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT,
            LayoutParams.WRAP_CONTENT);
    mEdtView = new EditText(getContext());
    mEdtView.setLayoutParams(lp);
    mEdtView.setMinWidth(dp10 * 8);
    mEdtView.setBackgroundColor(Color.argb(0, 0, 0, 0));
    mEdtView.setImeOptions(EditorInfo.IME_ACTION_DONE);
    mEdtView.setSingleLine(true);
    mEdtView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15);
    mEdtView.setTextColor(Color.BLACK);
    mEdtView.setPadding(dp10 / 2, dp10 / 2, dp10 / 2, dp10 / 2);
    mEdtView.setOnEditorActionListener(this);
    mEdtView.addTextChangedListener(this);
    mEdtView.setOnKeyListener(this);
    if (mMaxLength > 0) {
        InputFilter[] filters = { new LengthFilter(mMaxLength + 1) };
        mEdtView.setFilters(filters);
    }
    addView(mEdtView);
}
项目:CreditCardForm    文件:CardEditText.java   
private void updateCardType() {
    CardType type = CardType.forCardNumber(getText().toString());
    if (mCardType != type) {
        mCardType = type;

        InputFilter[] filters = {new LengthFilter(mCardType.getMaxCardLength())};
        setFilters(filters);
        invalidate();

        if (mOnCardTypeChangedListener != null) {
            mOnCardTypeChangedListener.onCardTypeChanged(mCardType);
        }
    }
}
项目:ToastUI    文件:ColorPickerDialog.java   
private void updateHexLengthFilter() {
    if (getAlphaSliderVisible()) {
        this.mHexVal.setFilters(new InputFilter[]{new LengthFilter(9)});
        return;
    }
    this.mHexVal.setFilters(new InputFilter[]{new LengthFilter(7)});
}
项目:FMTech    文件:CreditCardUpdateFragment.java   
protected final View onCreateThemedView(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, Bundle paramBundle)
{
  View localView = paramLayoutInflater.inflate(R.layout.fragment_credit_card_update, null, false);
  this.mCreditCardLabel = ((TextView)localView.findViewById(R.id.credit_card_label));
  this.mCreditCardLabel.setText(((CreditCard.CreditCardUpdateForm)this.mFormProto).cardLabel);
  ((ImageWithCaptionView)localView.findViewById(R.id.card_logo)).setImageWithCaption(((CreditCard.CreditCardUpdateForm)this.mFormProto).icon, PaymentUtils.getImageLoader(getActivity().getApplicationContext()), ((Boolean)G.images.useWebPForFife.get()).booleanValue());
  this.mExpDateText = ((ExpDateEditText)localView.findViewById(R.id.exp_date));
  this.mCvcText = ((FormEditText)localView.findViewById(R.id.cvc));
  this.mFieldData.add(new FormFragment.FieldData(0, this.mExpDateText, null));
  FormEditText localFormEditText = this.mCvcText;
  InputFilter[] arrayOfInputFilter = new InputFilter[1];
  arrayOfInputFilter[0] = new InputFilter.LengthFilter(((CreditCard.CreditCardUpdateForm)this.mFormProto).cvcLength);
  localFormEditText.setFilters(arrayOfInputFilter);
  this.mCvcHintImage = localView.findViewById(R.id.cvc_hint);
  this.mCvcHintImage.setOnClickListener(this);
  CvcValidator localCvcValidator = new CvcValidator(this.mCvcText, ((CreditCard.CreditCardUpdateForm)this.mFormProto).cvcLength);
  this.mCvcText.addValidator(localCvcValidator);
  this.mFieldData.add(new FormFragment.FieldData(0, this.mCvcText, null));
  UiFieldOuterClass.UiField localUiField = new UiFieldOuterClass.UiField();
  localUiField.isOptional = false;
  localUiField.label = getString(R.string.wallet_uic_exp_date);
  localUiField.dateField = new UiFieldOuterClass.UiField.DateField();
  localUiField.dateField.type = 2;
  localUiField.dateField.minDate = new DateOuterClass.Date();
  localUiField.dateField.minDate.month = ((CreditCard.CreditCardUpdateForm)this.mFormProto).minMonth;
  localUiField.dateField.minDate.year = ((CreditCard.CreditCardUpdateForm)this.mFormProto).minYear;
  localUiField.dateField.maxDate = new DateOuterClass.Date();
  localUiField.dateField.maxDate.month = ((CreditCard.CreditCardUpdateForm)this.mFormProto).maxMonth;
  localUiField.dateField.maxDate.year = ((CreditCard.CreditCardUpdateForm)this.mFormProto).maxYear;
  WalletUiUtils.applyUiFieldSpecificationToFormEditText(localUiField, this.mExpDateText);
  this.mCvcText.enableAutoAdvance(localCvcValidator, this.mCvcText, true);
  doEnableUi();
  return localView;
}
项目:FMTech    文件:AddCreditCardFragment.java   
public final void onCreditCardTypeChanged(CreditCard.CardType paramCardType)
{
  CreditCardImagesView localCreditCardImagesView = this.mCreditCardImagesView;
  ImageWithCaptionOuterClass.ImageWithCaption localImageWithCaption;
  if (paramCardType != null)
  {
    localImageWithCaption = paramCardType.icon;
    localCreditCardImagesView.setCardIcon(localImageWithCaption);
    if (paramCardType == null) {
      break label88;
    }
  }
  label88:
  for (int i = paramCardType.cvcLength;; i = 4)
  {
    FormEditText localFormEditText = this.mCvcText;
    InputFilter[] arrayOfInputFilter = new InputFilter[1];
    arrayOfInputFilter[0] = new InputFilter.LengthFilter(i);
    localFormEditText.setFilters(arrayOfInputFilter);
    if (!TextUtils.isEmpty(this.mCvcText.getText())) {
      this.mCvcText.validate();
    }
    return;
    localImageWithCaption = null;
    break;
  }
}
项目:FMTech    文件:FormEditText.java   
public void setMinMaxLength(int paramInt1, int paramInt2)
{
  if (this.mTemplate != null)
  {
    if (paramInt2 != this.mTemplateInputIndices.size()) {
      throw new IllegalArgumentException("maxLength (" + paramInt2 + ") must be equal to the number of input placeholder characters in the template (" + this.mTemplateInputIndices.size() + ")");
    }
  }
  else if (paramInt2 > 0)
  {
    InputFilter[] arrayOfInputFilter = new InputFilter[1];
    arrayOfInputFilter[0] = new InputFilter.LengthFilter(paramInt2);
    setFilters(arrayOfInputFilter);
    this.mMaxFieldLength = paramInt2;
    enableAutoAdvance(this, this, false);
  }
  if (this.mMinLengthValidator != null) {
    removeValidator(this.mMinLengthValidator);
  }
  if (paramInt1 > 0)
  {
    this.mMinLengthValidator = new InputLengthValidator(paramInt1)
    {
      protected final boolean isRequired()
      {
        return FormEditText.this.mRequired;
      }
    };
    addValidator(this.mMinLengthValidator);
  }
}
项目:FMTech    文件:jxg.java   
protected void a(Context paramContext)
{
  if (!f)
  {
    Resources localResources = paramContext.getResources();
    g = (int)localResources.getDimension(efj.TA);
    o = (int)localResources.getDimension(efj.Tz);
    m = (int)localResources.getDimension(efj.Tx);
    n = (int)localResources.getDimension(efj.Ty);
    j = (int)localResources.getDimension(efj.Tt);
    k = localResources.getColor(eyg.aS);
    h = localResources.getColor(eyg.aR);
    l = localResources.getColor(eyg.aP);
    i = localResources.getInteger(efj.TK);
    NumberFormat localNumberFormat = NumberFormat.getPercentInstance(localResources.getConfiguration().locale);
    J = localNumberFormat;
    localNumberFormat.setMaximumFractionDigits(0);
    InputFilter[] arrayOfInputFilter = new InputFilter[1];
    K = arrayOfInputFilter;
    arrayOfInputFilter[0] = new InputFilter.LengthFilter(localResources.getInteger(efj.TJ));
    f = true;
  }
  this.p = new ArrayList();
  this.r = new ArrayList();
  this.s = new ArrayList();
  this.q = new ArrayList();
  this.t = new ImageView(getContext());
  this.t.setBackgroundResource(efj.TI);
  this.D = new jxb();
  this.L = jr.a().d;
}
项目:FMTech    文件:lwc.java   
public lwc(EditText paramEditText, TextView paramTextView, int paramInt)
{
  this.a = paramEditText;
  this.b = paramTextView;
  this.c = paramInt;
  InputFilter[] arrayOfInputFilter = new InputFilter[1];
  arrayOfInputFilter[0] = new InputFilter.LengthFilter(paramInt);
  paramEditText.setFilters(arrayOfInputFilter);
}
项目:android-card-form    文件:CardEditText.java   
private void updateCardType() {
    CardType type = CardType.forCardNumber(getText().toString());
    if (mCardType != type) {
        mCardType = type;

        InputFilter[] filters = { new LengthFilter(mCardType.getMaxCardLength()) };
        setFilters(filters);
        invalidate();

        if (mOnCardTypeChangedListener != null) {
            mOnCardTypeChangedListener.onCardTypeChanged(mCardType);
        }
    }
}
项目:android-card-form    文件:MobileNumberEditText.java   
private void init() {
    if (isInEditMode()) {
        return;
    }

    setInputType(InputType.TYPE_CLASS_PHONE);
    InputFilter[] filters = { new LengthFilter(14) };
    setFilters(filters);
    addTextChangedListener(new PhoneNumberFormattingTextWatcher());
}
项目:android-card-form    文件:CvvEditText.java   
/**
 * Sets the card type associated with the security code type. {@link CardType#AMEX} has a
 * different icon and length than other card types. Typically handled through
 * {@link com.braintreepayments.cardform.view.CardEditText.OnCardTypeChangedListener#onCardTypeChanged(com.braintreepayments.cardform.utils.CardType)}.
 *
 * @param cardType Type of card represented by the current value of card number input.
 */
public void setCardType(CardType cardType) {
    mCardType = cardType;

    InputFilter[] filters = { new LengthFilter(cardType.getSecurityCodeLength()) };
    setFilters(filters);

    setContentDescription(getContext().getString(cardType.getSecurityCodeName()));
    setFieldHint(cardType.getSecurityCodeName());

    invalidate();
}
项目:android-card-form    文件:ExpirationDateEditText.java   
private void init() {
    setInputType(InputType.TYPE_CLASS_NUMBER);
    InputFilter[] filters = { new LengthFilter(6) };
    setFilters(filters);
    addTextChangedListener(this);
    setShowKeyboardOnFocus(!mUseExpirationDateDialog);
    setCursorVisible(!mUseExpirationDateDialog);
    super.setOnClickListener(this);
}
项目:sms_DualCard    文件:ComposeMessageActivity.java   
private void showSubjectEditor(boolean show) {
    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("" + show);
    }

    if (mSubjectTextEditor == null) {
        // Don't bother to initialize the subject editor if
        // we're just going to hide it.
        if (show == false) {
            return;
        }
        mSubjectTextEditor = (EditText) findViewById(R.id.subject);
        mSubjectTextEditor.setFilters(new InputFilter[] { new LengthFilter(
                MmsConfig.getMaxSubjectLength()) });
    }

    mSubjectTextEditor.setOnKeyListener(show ? mSubjectKeyListener : null);

    if (show) {
        mSubjectTextEditor.addTextChangedListener(mSubjectEditorWatcher);
    } else {
        mSubjectTextEditor.removeTextChangedListener(mSubjectEditorWatcher);
    }

    mSubjectTextEditor.setText(mWorkingMessage.getSubject());
    mSubjectTextEditor.setVisibility(show ? View.VISIBLE : View.GONE);
    hideOrShowTopPanel();
}
项目:android-aosp-mms    文件:ComposeMessageActivity.java   
private void showSubjectEditor(boolean show) {
    if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
        log("" + show);
    }

    if (mSubjectTextEditor == null) {
        // Don't bother to initialize the subject editor if
        // we're just going to hide it.
        if (show == false) {
            return;
        }
        mSubjectTextEditor = (EditText)findViewById(R.id.subject);
        mSubjectTextEditor.setFilters(new InputFilter[] {
                new LengthFilter(MmsConfig.getMaxSubjectLength())});
    }

    mSubjectTextEditor.setOnKeyListener(show ? mSubjectKeyListener : null);

    if (show) {
        mSubjectTextEditor.addTextChangedListener(mSubjectEditorWatcher);
    } else {
        mSubjectTextEditor.removeTextChangedListener(mSubjectEditorWatcher);
    }

    mSubjectTextEditor.setText(mWorkingMessage.getSubject());
    mSubjectTextEditor.setVisibility(show ? View.VISIBLE : View.GONE);
    hideOrShowTopPanel();
}
项目:lineagex86    文件:LightSettingsDialog.java   
public void setAlphaSliderVisible(boolean visible) {
    mHexColorInput.setFilters(new InputFilter[] { new InputFilter.LengthFilter(visible ? 8 : 6) } );
    mColorPicker.setAlphaSliderVisible(visible);
}
项目:CreditCardForm    文件:MonthYearEditText.java   
private void init() {
    setInputType(InputType.TYPE_CLASS_NUMBER);
    InputFilter[] filters = { new LengthFilter(6) };
    setFilters(filters);
    addTextChangedListener(this);
}
项目:CreditCardForm    文件:CvvEditText.java   
private void init() {
    setInputType(InputType.TYPE_CLASS_NUMBER);
    setFilters(new InputFilter[]{new LengthFilter(DEFAULT_MAX_LENGTH)});
    addTextChangedListener(this);
}
项目:CreditCardForm    文件:PostalCodeEditText.java   
private void init() {
    setInputType(InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS);
    InputFilter[] filters = { new LengthFilter(16) };
    setFilters(filters);
}
项目:FMTech    文件:luy.java   
public final Dialog c(Bundle paramBundle)
{
  Bundle localBundle = this.m;
  Context localContext = ar_();
  un localun = new un(localContext);
  View localView = LayoutInflater.from(localContext).inflate(efj.ZQ, null);
  this.Z = ((EditText)localView.findViewById(aw.eK));
  this.Z.addTextChangedListener(this);
  CharSequence localCharSequence1 = localBundle.getCharSequence("hint_text");
  if (localCharSequence1 != null) {
    this.Z.setHint(localCharSequence1);
  }
  this.aa = localBundle.getInt("max_length", 1000);
  if (this.aa > 0)
  {
    EditText localEditText = this.Z;
    InputFilter[] arrayOfInputFilter = new InputFilter[1];
    arrayOfInputFilter[0] = new InputFilter.LengthFilter(this.aa);
    localEditText.setFilters(arrayOfInputFilter);
  }
  if (paramBundle != null) {
    this.Z.setText(paramBundle.getCharSequence("text_value"));
  }
  for (;;)
  {
    String str1 = localBundle.getString("error_msg");
    if (str1 != null) {
      this.Z.setError(str1);
    }
    TextView localTextView = (TextView)localView.findViewById(aw.eJ);
    String str2 = localBundle.getString("notice_text");
    if (str2 != null)
    {
      localTextView.setText(str2);
      localTextView.setVisibility(0);
    }
    localun.a(localView);
    CharSequence localCharSequence2 = localBundle.getCharSequence("dialog_title");
    localun.a.e = localCharSequence2;
    localun.a(fi.b, this);
    localun.b(localBundle.getInt("cancel_resource_id", fi.a), this);
    ((ImageView)localView.findViewById(aw.eH)).setOnClickListener(new luz(this));
    this.Z.post(new lva(this, localBundle));
    return localun.a();
    this.Z.setText(localBundle.getCharSequence("text_value"));
  }
}
项目:android-card-form    文件:CvvEditText.java   
private void init() {
    setInputType(InputType.TYPE_CLASS_NUMBER);
    setFilters(new InputFilter[]{new LengthFilter(DEFAULT_MAX_LENGTH)});
    addTextChangedListener(this);
}
项目:android-card-form    文件:CountryCodeEditText.java   
private void init() {
    setInputType(InputType.TYPE_CLASS_PHONE);
    InputFilter[] filters = { new LengthFilter(4) };
    setFilters(filters);
}
项目:android-card-form    文件:PostalCodeEditText.java   
private void init() {
    setInputType(InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS);
    InputFilter[] filters = { new LengthFilter(16) };
    setFilters(filters);
}
项目:sms_DualCard    文件:ComposeMessageActivity.java   
/**
 * Initialize all UI elements from resources.
 */
private void initResourceRefs() {
    mMsgListView = (MessageListView) findViewById(R.id.history);
    mMsgListView.setDivider(null); // no divider so we look like IM
                                    // conversation.

    // called to enable us to show some padding between the message list and
    // the
    // input field but when the message list is scrolled that padding area
    // is filled
    // in with message content
    mMsgListView.setClipToPadding(false);

    mMsgListView.setOnSizeChangedListener(new OnSizeChangedListener() {
        public void onSizeChanged(int width, int height, int oldWidth,
                int oldHeight) {
            // The message list view changed size, most likely because the
            // keyboard
            // appeared or disappeared or the user typed/deleted chars in
            // the message
            // box causing it to change its height when expanding/collapsing
            // to hold more
            // lines of text.
            smoothScrollToEnd(false, height - oldHeight);
        }
    });

    mBottomPanel = findViewById(R.id.bottom_panel);
    mTextEditor = (EditText) findViewById(R.id.embedded_text_editor);
    mTextEditor.setOnEditorActionListener(this);
    mTextEditor.addTextChangedListener(mTextEditorWatcher);
    // zaizhe
    mIsMmsMessage = false;
    mTextEditor.setFilters(new InputFilter[] { new LengthFilter(MmsConfig
            .getMaxTextLimit()) });
    mTextCounter = (TextView) findViewById(R.id.text_counter);
    // mSendButtonMms = (TextView) findViewById(R.id.send_button_mms);
    if (MultiSimConfig.isMultiSimEnabled()) {

        // mSendButtonMms.setText(R.string.mms1);//010hide
    }
    // mSendButtonMms2 = (TextView) findViewById(R.id.send_button_mms2);
    mSendButtonMms2 = (ImageButton) findViewById(R.id.send_button_mms2);
    mSendButtonMms = (ImageButton) findViewById(R.id.send_button_mms);
    mSendButtonSms = (ImageButton) findViewById(R.id.send_button_sms);
    mSendButtonSms2 = (ImageButton) findViewById(R.id.send_button_sms2);
    mAddAttachment = (ImageButton) findViewById(R.id.compose_add_new_attachment);
    mAddAttachment.setOnClickListener(this);

    mSendButtonMms.setOnClickListener(this);
    mSendButtonMms2.setOnClickListener(this);
    mSendButtonSms.setOnClickListener(this);
    mSendButtonSms2.setOnClickListener(this);
    mTopPanel = findViewById(R.id.recipients_subject_linear);
    mTopPanel.setFocusable(false);
    mAttachmentEditor = (AttachmentEditor) findViewById(R.id.attachment_editor);
    mAttachmentEditor.setHandler(mAttachmentEditorHandler);
    mAttachmentEditorScrollView = findViewById(R.id.attachment_editor_scroll_view);
}
项目:android-aosp-mms    文件:ComposeMessageActivity.java   
/**
 * Initialize all UI elements from resources.
 */
private void initResourceRefs() {
    mMsgListView = (MessageListView) findViewById(R.id.history);
    mMsgListView.setDivider(null);      // no divider so we look like IM conversation.

    // called to enable us to show some padding between the message list and the
    // input field but when the message list is scrolled that padding area is filled
    // in with message content
    mMsgListView.setClipToPadding(false);

    mMsgListView.setOnSizeChangedListener(new OnSizeChangedListener() {
        public void onSizeChanged(int width, int height, int oldWidth, int oldHeight) {
            if (Log.isLoggable(LogTag.APP, Log.VERBOSE)) {
                Log.v(TAG, "onSizeChanged: w=" + width + " h=" + height +
                        " oldw=" + oldWidth + " oldh=" + oldHeight);
            }

            if (!mMessagesAndDraftLoaded && (oldHeight-height > SMOOTH_SCROLL_THRESHOLD)) {
                // perform the delayed loading now, after keyboard opens
                loadMessagesAndDraft(3);
            }


            // The message list view changed size, most likely because the keyboard
            // appeared or disappeared or the user typed/deleted chars in the message
            // box causing it to change its height when expanding/collapsing to hold more
            // lines of text.
            smoothScrollToEnd(false, height - oldHeight);
        }
    });

    mBottomPanel = findViewById(R.id.bottom_panel);
    mTextEditor = (EditText) findViewById(R.id.embedded_text_editor);
    mTextEditor.setOnEditorActionListener(this);
    mTextEditor.addTextChangedListener(mTextEditorWatcher);
    mTextEditor.setFilters(new InputFilter[] {
            new LengthFilter(MmsConfig.getMaxTextLimit())});
    mTextCounter = (TextView) findViewById(R.id.text_counter);
    mSendButtonMms = (TextView) findViewById(R.id.send_button_mms);
    mSendButtonSms = (ImageButton) findViewById(R.id.send_button_sms);
    mSendButtonMms.setOnClickListener(this);
    mSendButtonSms.setOnClickListener(this);
    mTopPanel = findViewById(R.id.recipients_subject_linear);
    mTopPanel.setFocusable(false);
    mAttachmentEditor = (AttachmentEditor) findViewById(R.id.attachment_editor);
    mAttachmentEditor.setHandler(mAttachmentEditorHandler);
    mAttachmentEditorScrollView = findViewById(R.id.attachment_editor_scroll_view);
}
项目:CreditCardForm    文件:CvvEditText.java   
/**
 * Sets the card type associated with the security code type. {@link CardType#AMEX} has a
 * different icon and length than other card types. Typically handled through
 * {@link com.thepinkandroid.cardform.view.CardEditText.OnCardTypeChangedListener#onCardTypeChanged(com.thepinkandroid.cardform.utils.CardType)}.
 *
 * @param cardType Type of card represented by the current value of card number input.
 */
public void setCardType(CardType cardType) {
    mCardType = cardType;
    InputFilter[] filters = {new LengthFilter(cardType.getSecurityCodeLength())};
    setFilters(filters);
    invalidate();
}