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 Project: YiBo   Author: cattong   File: AddAccountActivity.java    License: 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 Project: SmsScheduler   Author: yeriomin   File: AddSmsActivity.java    License: 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 #3
Source Project: biermacht   Author: caseydavenport   File: AlertBuilder.java    License: 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 Project: edslite   Author: sovworks   File: EditableSecureBuffer.java    License: 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 #5
Source Project: edslite   Author: sovworks   File: EditableSecureBuffer.java    License: 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 #6
Source Project: edslite   Author: sovworks   File: EditableSecureBuffer.java    License: 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 #7
Source Project: letv   Author: JackChan1999   File: BasicActivity.java    License: 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 #8
Source Project: ans-android-sdk   Author: analysys   File: BaseViewVisitor.java    License: 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 #9
Source Project: ans-android-sdk   Author: analysys   File: BaseViewVisitor.java    License: 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 #10
Source Project: android_9.0.0_r45   Author: lulululbj   File: DialerFilter.java    License: Apache License 2.0 5 votes vote down vote up
public void setFilterWatcher(TextWatcher watcher) {
    if (mMode != DIGITS_ONLY) {
        setLettersWatcher(watcher);
    } else {
        setDigitsWatcher(watcher);
    }
}
 
Example #11
Source Project: android_9.0.0_r45   Author: lulululbj   File: DialerFilter.java    License: 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 Project: pandora   Author: whataa   File: ExtraEditTextView.java    License: 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 #13
Source Project: pandora   Author: whataa   File: ExtraEditTextView.java    License: 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 #14
Source Project: pandora   Author: whataa   File: ExtraEditTextView.java    License: 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 #15
Source Project: react-native-aztec   Author: wordpress-mobile   File: ReactAztecText.java    License: GNU General Public License v2.0 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 #16
Source Project: react-native-aztec   Author: wordpress-mobile   File: ReactAztecText.java    License: GNU General Public License v2.0 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 #17
Source Project: react-native-aztec   Author: wordpress-mobile   File: ReactAztecText.java    License: GNU General Public License v2.0 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 #18
Source Project: react-native-aztec   Author: wordpress-mobile   File: ReactAztecText.java    License: 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 #19
Source Project: react-native-aztec   Author: wordpress-mobile   File: ReactAztecText.java    License: 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 #20
Source Project: PowerFileExplorer   Author: PowerExplorer   File: SpannableStringBuilder.java    License: 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 #21
Source Project: PowerFileExplorer   Author: PowerExplorer   File: SpannableStringBuilder.java    License: 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 #22
Source Project: fingen   Author: YoshiOne   File: NumberTextWatcher.java    License: 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 #23
Source Project: react-native-GPay   Author: hellochirag   File: ReactEditText.java    License: 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 Project: react-native-GPay   Author: hellochirag   File: ReactEditText.java    License: 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 Project: react-native-GPay   Author: hellochirag   File: ReactEditText.java    License: 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 Project: react-native-GPay   Author: hellochirag   File: ReactEditText.java    License: 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 Project: litho   Author: facebook   File: TextInputSpec.java    License: 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 Project: litho   Author: facebook   File: TextInputSpec.java    License: 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 Project: moserp   Author: thomasletsch   File: OutgoingDeliveryViewModel.java    License: 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);
        }
    };
}
 
Example #30
Source Project: Spyglass   Author: linkedin   File: MentionsEditText.java    License: 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);
    }
}