Java Code Examples for android.widget.TextView#removeTextChangedListener()

The following examples show how to use android.widget.TextView#removeTextChangedListener() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: decoro   File: FormatWatcher.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param textView     an observable text view which content text will be formatted using
 *                     {@link
 *                     Mask}
 * @param initWithMask this flags defines whether hardcoded head of the mask (e.g "+7 ") will
 *                     fill the initial text of the {@code textView}.
 */
protected void installOn(final TextView textView, final boolean initWithMask) {
    if (textView == null) {
        throw new IllegalArgumentException("text view cannot be null");
    }

    this.textView = textView;
    this.initWithMask = initWithMask;

    // try to remove us from listeners (useful in case user's trying to install the formatter twice on a same TextView)
    textView.removeTextChangedListener(this);

    textView.addTextChangedListener(this);

    this.mask = null;
    refreshMask();
}
 
Example 2
@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 3
@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 4
Source Project: AndroidProject   File: InputTextHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 移除 TextView 监听,避免内存泄露
 */
public void removeViews(TextView... views) {
    if (mViewSet != null && mViewSet.size() > 0) {
        for (TextView view : views) {
            view.removeTextChangedListener(this);
            mViewSet.remove(view);
        }
        // 触发一次监听
        notifyChanged();
    }
}
 
Example 5
Source Project: AndroidProject   File: InputTextHelper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 移除所有 TextView 监听,避免内存泄露
 */
public void removeAllViews() {
    if (mViewSet == null) {
        return;
    }

    for (TextView view : mViewSet) {
        view.removeTextChangedListener(this);
    }
    mViewSet.clear();
    mViewSet = null;
}
 
Example 6
private void setPhoneNumberWatcherToTextView(TextView textView, String countryNameCode) {
  if (!mIsEnablePhoneNumberWatcher) return;

  if (mPhoneNumberWatcher == null) {
    mPhoneNumberWatcher = new PhoneNumberWatcher(countryNameCode);
    textView.addTextChangedListener(mPhoneNumberWatcher);
  } else {
    if (!mPhoneNumberWatcher.getPreviousCountryCode().equalsIgnoreCase(countryNameCode)) {
      textView.removeTextChangedListener(mPhoneNumberWatcher);
      mPhoneNumberWatcher = new PhoneNumberWatcher(countryNameCode);
      textView.addTextChangedListener(mPhoneNumberWatcher);
    }
  }
}
 
Example 7
Source Project: ScalableLayout   File: ScalableLayout.java    License: Apache License 2.0 5 votes vote down vote up
private void refreshTextChangedListener(TextView pTextView) {
    LayoutParams lSLLP = getChildLayoutParams(pTextView);

    try {
        pTextView.removeTextChangedListener(mTextWatcher);
    } catch (Throwable e) {
        ex(e);
    }
    if(lSLLP.mTextView_WrapContent_Direction != TextView_WrapContent_Direction.None) {
        pTextView.addTextChangedListener(mTextWatcher);
    }
}
 
Example 8
/**
 * Default modifier for removing text change listener
 * @param textView - related text view.
 * @param watcher - text watcher which has to be removed.
 */
static void removeTextChangedListener(TextView textView, TextWatcher watcher) {
    textView.removeTextChangedListener(watcher);
}