android.text.TextWatcher Java Examples

The following examples show how to use android.text.TextWatcher. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AddAccountActivity.java    From YiBo with Apache License 2.0 6 votes vote down vote up
private void bindEvent() {
	Button btnBack = (Button) this.findViewById(R.id.btnBack);
	btnBack.setOnClickListener(new GoBackClickListener(R.anim.slide_in_right));

	spServiceProvider.setAdapter(new ServiceProviderSpinnerAdapter(this));
	OnItemSelectedListener spItemListener = new AddAccountSpItemSelectedListener(this);
	spServiceProvider.setOnItemSelectedListener(spItemListener);
	
	
	spConfigApp.setAdapter(new ConfigAppSpinnerAdapter(this));
	OnItemSelectedListener configAppItemSelectedListener = null;
	configAppItemSelectedListener = new AddAccountConfigAppItemSelectedListener(this);
	spConfigApp.setOnItemSelectedListener(configAppItemSelectedListener);
	
	TextWatcher editTextWatcher = new AddAccountTextWatcher(this);
	etUsername.addTextChangedListener(editTextWatcher);
	etPassword.addTextChangedListener(editTextWatcher);
	etRestProxy.addTextChangedListener(editTextWatcher);
	etSearchProxy.addTextChangedListener(editTextWatcher);

	AddAccountAuthorizeClickListener authorizeClickListener = null;
	authorizeClickListener = new AddAccountAuthorizeClickListener(this);
	btnAuthorize.setOnClickListener(authorizeClickListener);

}
 
Example #2
Source File: BasicActivity.java    From letv with Apache License 2.0 6 votes vote down vote up
protected void beautyEditText(final EditText mEditText, String hintStr, TextWatcher mTextWatcher) {
    mEditText.setHint(hintStr);
    mEditText.setHintTextColor(Color.parseColor("#1e0d0d0d"));
    mEditText.setTextColor(Color.parseColor("#0d0d0d"));
    SDKUtils.setBackground(mEditText, this.crMgmt.getDrawable("uac_input", true));
    mEditText.setTextSize(16.0f);
    if (mTextWatcher != null) {
        mEditText.addTextChangedListener(mTextWatcher);
    }
    mEditText.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mEditText.setSelection(mEditText.length());
            mEditText.requestFocus();
            mEditText.setFocusable(true);
        }
    });
}
 
Example #3
Source File: AlertBuilder.java    From biermacht with Apache License 2.0 6 votes vote down vote up
public <T> AlertDialog.Builder searchableListAlert(final TextView text, final TextView title, final ArrayAdapter<T> adapter,
                                                   final ArrayList<T> list, final OnItemClickListener listener, TextWatcher textWatcher) {
  LayoutInflater factory = LayoutInflater.from(context);
  final LinearLayout alertView = (LinearLayout) factory.inflate(R.layout.alert_view_searchable_list, null);
  final EditText editText = (EditText) alertView.findViewById(R.id.edit_text);
  final ListView listView = (ListView) alertView.findViewById(R.id.list);
  listView.setOnItemClickListener(listener);
  listView.setAdapter(adapter);

  // Search text watcher.
  editText.addTextChangedListener(textWatcher);
  textWatcher.onTextChanged("", 0, 0, 0);

  return new AlertDialog.Builder(context)
          .setTitle(title.getText().toString())
          .setView(alertView)
          .setNegativeButton(R.string.cancel, null);
}
 
Example #4
Source File: EditableSecureBuffer.java    From edslite with GNU General Public License v2.0 6 votes vote down vote up
private void sendAfterTextChanged(TextWatcher[] watchers) {
    if(VERBOSE_LOG) Logger.debug(TAG + ": in sendAfterTextChanged");
    int n = watchers.length;

    mTextWatcherDepth++;
    for (int i = 0; i < n; i++) {
        try
        {
            watchers[i].afterTextChanged(this);
        }
        catch (Throwable e)
        {
            Logger.log(e);
        }
    }
    mTextWatcherDepth--;
}
 
Example #5
Source File: AddSmsActivity.java    From SmsScheduler with GNU General Public License v2.0 6 votes vote down vote up
private void buildForm() {
    EditText formMessage = findViewById(R.id.form_input_message);
    AutoCompleteTextView formContact = findViewById(R.id.form_input_contact);
    TextWatcher watcherEmptiness = new EmptinessTextWatcher(this, formContact, formMessage);
    formContact.addTextChangedListener(watcherEmptiness);
    formMessage.addTextChangedListener(watcherEmptiness);

    new BuilderMessage().setView(formMessage).setSms(sms).build();
    new BuilderContact().setView(formContact).setSms(sms).setActivity(this).build();

    new BuilderSimCard().setActivity(this).setView(findViewById(R.id.form_sim_card)).setSms(sms).build();
    new BuilderRecurringMode()
        .setRecurringDayView((Spinner) findViewById(R.id.form_recurring_day))
        .setRecurringMonthView((Spinner) findViewById(R.id.form_recurring_month))
        .setDateView((DatePicker) findViewById(R.id.form_date))
        .setActivity(this)
        .setView(findViewById(R.id.form_recurring_mode))
        .setSms(sms)
        .build()
    ;

    new BuilderTime().setActivity(this).setView(findViewById(R.id.form_time)).setSms(sms).build();
    new BuilderDate().setActivity(this).setView(findViewById(R.id.form_date)).setSms(sms).build();

    new BuilderCancel().setView(findViewById(R.id.button_cancel)).setSms(sms).build();
}
 
Example #6
Source File: EditableSecureBuffer.java    From edslite with GNU General Public License v2.0 6 votes vote down vote up
private void sendTextChanged(TextWatcher[] watchers, int start, int before, int after) {
    if(VERBOSE_LOG) Logger.debug(TAG + ": in sendTextChanged");
    int n = watchers.length;

    mTextWatcherDepth++;
    for (int i = 0; i < n; i++) {
        try
        {
            watchers[i].onTextChanged(this, start, before, after);
        }
        catch (Throwable e)
        {
            Logger.log(e);
        }
    }
    mTextWatcherDepth--;
}
 
Example #7
Source File: EditableSecureBuffer.java    From edslite with GNU General Public License v2.0 6 votes vote down vote up
private void sendBeforeTextChanged(TextWatcher[] watchers, int start, int before, int after) {
    int n = watchers.length;

    mTextWatcherDepth++;
    for (int i = 0; i < n; i++) {
        try
        {
            watchers[i].beforeTextChanged(this, start, before, after);
        }
        catch (Throwable e)
        {
            Logger.log(e);
        }
    }
    mTextWatcherDepth--;
}
 
Example #8
Source File: ExtraEditTextView.java    From pandora with Apache License 2.0 5 votes vote down vote up
@Override
public void removeTextChangedListener(TextWatcher watcher) {
    if (mListeners != null) {
        int i = mListeners.indexOf(watcher);
        if (i >= 0) {
            mListeners.remove(i);
        }
    }

    super.removeTextChangedListener(watcher);
}
 
Example #9
Source File: SpannableStringBuilder.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
private TextWatcher[] sendTextWillChange(int start, int before, int after) {
    TextWatcher[] recip = getSpans(start, start + before, TextWatcher.class);
    int n = recip.length;

    for (int i = 0; i < n; i++) {
        recip[i].beforeTextChanged(this, start, before, after);
    }

    return recip;
}
 
Example #10
Source File: ReactAztecText.java    From react-native-aztec with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void afterTextChanged(Editable s) {
    if (!mIsSettingTextFromJS && mListeners != null) {
        for (TextWatcher listener : mListeners) {
            listener.afterTextChanged(s);
        }
    }
}
 
Example #11
Source File: DialerFilter.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void removeFilterWatcher(TextWatcher watcher) {
    Spannable text;
    if (mMode != DIGITS_ONLY) {
        text = mLetters.getText();
    } else {
        text = mDigits.getText();
    }
    text.removeSpan(watcher);
}
 
Example #12
Source File: FormattedEditText.java    From FormatEditText with MIT License 5 votes vote down vote up
private void sendOnTextChanged(CharSequence s, int start, int before, int count) {
    final List<TextWatcher> list = mWatchers;
    if (list != null) {
        final int size = list.size();
        for (int i = 0; i < size; i++) {
            list.get(i).onTextChanged(s, start, before, count);
        }
    }
}
 
Example #13
Source File: MentionsEditText.java    From Spyglass with Apache License 2.0 5 votes vote down vote up
/**
 * Allows a class to watch for text changes. Note that adding this class to itself will add it
 * to the super class. Other instances of {@link TextWatcher} will be notified by this class
 * as appropriate (helps prevent infinite loops when text keeps changing).
 *
 * @param watcher the {@link TextWatcher} to add
 */
@Override
public void addTextChangedListener(@NonNull TextWatcher watcher) {
    if (watcher == mInternalTextWatcher) {
        if (!mIsWatchingText) {
            super.addTextChangedListener(mInternalTextWatcher);
            mIsWatchingText = true;
        }
    } else {
        mExternalTextWatchers.add(watcher);
    }
}
 
Example #14
Source File: ExtraEditTextView.java    From pandora with Apache License 2.0 5 votes vote down vote up
@Override
public void addTextChangedListener(TextWatcher watcher) {
    if (mListeners == null) {
        mListeners = new ArrayList<>();
    }
    mListeners.add(watcher);

    super.addTextChangedListener(watcher);
}
 
Example #15
Source File: FormattedEditText.java    From FormatEditText with MIT License 5 votes vote down vote up
private void sendAfterTextChanged(Editable s) {
    final List<TextWatcher> list = mWatchers;
    if (list != null) {
        final int size = list.size();
        for (int i = 0; i < size; i++) {
            list.get(i).afterTextChanged(s);
        }
    }
}
 
Example #16
Source File: ContainsEmojiEditText.java    From MissZzzReader with Apache License 2.0 5 votes vote down vote up
@Override
public void addTextChangedListener(TextWatcher watcher)
{
    if (mListeners == null)
    {
        mListeners = new ArrayList<TextWatcher>();
    }
    mListeners.add(watcher);

    super.addTextChangedListener(watcher);
}
 
Example #17
Source File: BaseViewVisitor.java    From ans-android-sdk with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void cleanup() {
    for (final Map.Entry<TextView, TextWatcher> entry : mWatching.entrySet()) {
        final TextView v = entry.getKey();
        final TextWatcher watcher = entry.getValue();
        v.removeTextChangedListener(watcher);
    }

    mWatching.clear();
}
 
Example #18
Source File: BaseViewVisitor.java    From ans-android-sdk with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void accumulate(View found) {
    if (found instanceof TextView) {
        final TextView foundTextView = (TextView) found;
        final TextWatcher watcher = new TrackingTextWatcher(foundTextView);
        final TextWatcher oldWatcher = mWatching.get(foundTextView);
        if (null != oldWatcher) {
            foundTextView.removeTextChangedListener(oldWatcher);
        }
        foundTextView.addTextChangedListener(watcher);
        mWatching.put(foundTextView, watcher);
    }
}
 
Example #19
Source File: ExtraEditTextView.java    From pandora with Apache License 2.0 5 votes vote down vote up
public void clearTextChangedListeners() {
    if (mListeners != null) {
        for (TextWatcher watcher : mListeners) {
            super.removeTextChangedListener(watcher);
        }

        mListeners.clear();
        mListeners = null;
    }
}
 
Example #20
Source File: SpannableStringBuilder.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
private void sendTextHasChanged(TextWatcher[] recip) {
    int n = recip.length;

    for (int i = 0; i < n; i++) {
        recip[i].afterTextChanged(this);
    }
}
 
Example #21
Source File: NumberTextWatcher.java    From fingen with Apache License 2.0 5 votes vote down vote up
public NumberTextWatcher(EditText et, TextWatcher textWatcher) {
    mTextWatcher = textWatcher;
    DecimalFormatSymbols symbols = new DecimalFormatSymbols();
    symbols.setDecimalSeparator('.');
    symbols.setGroupingSeparator(' ');
    df = new DecimalFormat("#,###.##");
    df.setDecimalSeparatorAlwaysShown(true);
    df.setDecimalFormatSymbols(symbols);
    dfnd = new DecimalFormat("#,###");
    dfnd.setDecimalFormatSymbols(symbols);
    this.et = et;
    hasFractionalPart = false;
}
 
Example #22
Source File: ReactAztecText.java    From react-native-aztec with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
    if (!mIsSettingTextFromJS && mListeners != null) {
        for (TextWatcher listener : mListeners) {
            listener.onTextChanged(s, start, before, count);
        }
    }

    onContentSizeChange();
}
 
Example #23
Source File: ReactEditText.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public void addTextChangedListener(TextWatcher watcher) {
  if (mListeners == null) {
    mListeners = new ArrayList<>();
    super.addTextChangedListener(getTextWatcherDelegator());
  }

  mListeners.add(watcher);
}
 
Example #24
Source File: ReactEditText.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public void removeTextChangedListener(TextWatcher watcher) {
  if (mListeners != null) {
    mListeners.remove(watcher);

    if (mListeners.isEmpty()) {
      mListeners = null;
      super.removeTextChangedListener(getTextWatcherDelegator());
    }
  }
}
 
Example #25
Source File: ReactEditText.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  if (!mIsSettingTextFromJS && mListeners != null) {
    for (TextWatcher listener : mListeners) {
      listener.beforeTextChanged(s, start, count, after);
    }
  }
}
 
Example #26
Source File: ReactEditText.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
  if (!mIsSettingTextFromJS && mListeners != null) {
    for (TextWatcher listener : mListeners) {
      listener.onTextChanged(s, start, before, count);
    }
  }

  onContentSizeChange();
}
 
Example #27
Source File: TextInputSpec.java    From litho with Apache License 2.0 5 votes vote down vote up
@OnBind
static void onBind(
    final ComponentContext c,
    EditTextWithEventHandlers editText,
    @Prop(optional = true, varArg = "textWatcher") List<TextWatcher> textWatchers) {
  editText.attachWatchers(textWatchers);

  editText.setComponentContext(c);
  editText.setTextChangedEventHandler(TextInput.getTextChangedEventHandler(c));
  editText.setSelectionChangedEventHandler(TextInput.getSelectionChangedEventHandler(c));
  editText.setKeyUpEventHandler(TextInput.getKeyUpEventHandler(c));
  editText.setKeyPreImeEventEventHandler(TextInput.getKeyPreImeEventHandler(c));
  editText.setEditorActionEventHandler(TextInput.getEditorActionEventHandler(c));
  editText.setInputConnectionEventHandler(TextInput.getInputConnectionEventHandler(c));
}
 
Example #28
Source File: TextInputSpec.java    From litho with Apache License 2.0 5 votes vote down vote up
void attachWatchers(@Nullable List<TextWatcher> textWatchers) {
  if (textWatchers != null && textWatchers.size() > 0) {
    mTextWatcher =
        textWatchers.size() == 1 ? textWatchers.get(0) : new CompositeTextWatcher(textWatchers);
    addTextChangedListener(mTextWatcher);
  }
}
 
Example #29
Source File: ContainsEmojiEditText.java    From MissZzzReader with Apache License 2.0 5 votes vote down vote up
public void clearTextChangedListeners()
{
    if(mListeners != null)
    {
        for(TextWatcher watcher : mListeners)
        {
            super.removeTextChangedListener(watcher);
        }

        mListeners.clear();
        mListeners = null;
    }
}
 
Example #30
Source File: OutgoingDeliveryViewModel.java    From moserp with Apache License 2.0 5 votes vote down vote up
public TextWatcher getQuantityWatcher() {
    return new BaseTextWatcher() {
        public void onTextChanged(String text) {
            quantity = Quantity.convertStringToQuantity(text);
        }
    };
}