android.text.SpanWatcher Java Examples

The following examples show how to use android.text.SpanWatcher. 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: EditableSecureBuffer.java    From edslite with GNU General Public License v2.0 6 votes vote down vote up
private void sendSpanAdded(Object what, int start, int end) {
    if(VERBOSE_LOG) Logger.debug(TAG + ": in sendSpanAdded");
    SpanWatcher[] recip = getSpans(start, end, SpanWatcher.class);
    int n = recip.length;

    for (int i = 0; i < n; i++) {
        try
        {
            recip[i].onSpanAdded(this, what, start, end);
        }
        catch (Throwable e)
        {
            Logger.log(e);
        }
    }
}
 
Example #2
Source File: EditableSecureBuffer.java    From edslite with GNU General Public License v2.0 6 votes vote down vote up
private void sendSpanRemoved(Object what, int start, int end) {
    if(VERBOSE_LOG) Logger.debug(TAG + ": in sendSpanRemoved");
    SpanWatcher[] recip = getSpans(start, end, SpanWatcher.class);
    int n = recip.length;

    for (int i = 0; i < n; i++) {
        try
        {
            recip[i].onSpanRemoved(this, what, start, end);
        }
        catch (Throwable e)
        {
            Logger.log(e);
        }
    }
}
 
Example #3
Source File: EditableSecureBuffer.java    From edslite with GNU General Public License v2.0 6 votes vote down vote up
private void sendSpanChanged(Object what, int oldStart, int oldEnd, int start, int end) {
    if(VERBOSE_LOG) Logger.debug(TAG + ": in sendSpanChanged");
    // The bounds of a possible SpanWatcher are guaranteed to be set before this method is
    // called, so that the order of the span does not affect this broadcast.
    SpanWatcher[] spanWatchers = getSpans(Math.min(oldStart, start),
            Math.min(Math.max(oldEnd, end), length()), SpanWatcher.class);
    int n = spanWatchers.length;
    for (int i = 0; i < n; i++) {
        try
        {
            spanWatchers[i].onSpanChanged(this, what, oldStart, oldEnd, start, end);
        }
        catch (Throwable e)
        {
            Logger.log(e);
        }
    }
}
 
Example #4
Source File: CommentTextView.java    From Dashchan with Apache License 2.0 6 votes vote down vote up
private void invalidateSpanToClick() {
	if (spanToClick == null) {
		return;
	}
	CharSequence text = getText();
	if (text instanceof Spannable) {
		Spannable spannable = (Spannable) text;
		int start = spannable.getSpanStart(spanToClick);
		int end = spannable.getSpanEnd(spanToClick);
		if (start >= 0 && end >= start) {
			SpanWatcher[] watchers = spannable.getSpans(0, spannable.length(), SpanWatcher.class);
			if (watchers != null && watchers.length >= 1) {
				for (SpanWatcher watcher : watchers) {
					if (watcher.getClass().getName().equals("android.widget.TextView$ChangeWatcher")) {
						// Notify span changed to redraw it
						watcher.onSpanChanged(spannable, spanToClick, start, end, start, end);
					}
				}
			}
		}
	}
	invalidate();
}
 
Example #5
Source File: SpannableStringBuilder.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
private void sendSpanAdded(Object what, int start, int end) {
    SpanWatcher[] recip = getSpans(start, end, SpanWatcher.class);
    int n = recip.length;

    for (int i = 0; i < n; i++) {
        recip[i].onSpanAdded(this, what, start, end);
    }
}
 
Example #6
Source File: SpannableStringBuilder.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
private void sendSpanRemoved(Object what, int start, int end) {
    SpanWatcher[] recip = getSpans(start, end, SpanWatcher.class);
    int n = recip.length;

    for (int i = 0; i < n; i++) {
        recip[i].onSpanRemoved(this, what, start, end);
    }
}
 
Example #7
Source File: SpannableStringBuilder.java    From PowerFileExplorer with GNU General Public License v3.0 5 votes vote down vote up
private void sendSpanChanged(Object what, int s, int e, int st, int en) {
    SpanWatcher[] recip = getSpans(Math.min(s, st), Math.max(e, en),
                              SpanWatcher.class);
    int n = recip.length;

    for (int i = 0; i < n; i++) {
        recip[i].onSpanChanged(this, what, s, e, st, en);
    }
}
 
Example #8
Source File: SpannableStringBuilder.java    From JotaTextEditor with Apache License 2.0 5 votes vote down vote up
private void sendSpanAdded(Object what, int start, int end) {
    SpanWatcher[] recip = getSpans(start, end, SpanWatcher.class);
    int n = recip.length;

    for (int i = 0; i < n; i++) {
        recip[i].onSpanAdded(this, what, start, end);
    }
}
 
Example #9
Source File: SpannableStringBuilder.java    From JotaTextEditor with Apache License 2.0 5 votes vote down vote up
private void sendSpanRemoved(Object what, int start, int end) {
    SpanWatcher[] recip = getSpans(start, end, SpanWatcher.class);
    int n = recip.length;

    for (int i = 0; i < n; i++) {
        recip[i].onSpanRemoved(this, what, start, end);
    }
}
 
Example #10
Source File: SpannableStringBuilder.java    From JotaTextEditor with Apache License 2.0 5 votes vote down vote up
private void sendSpanChanged(Object what, int s, int e, int st, int en) {
    SpanWatcher[] recip = getSpans(Math.min(s, st), Math.max(e, en),
                              SpanWatcher.class);
    int n = recip.length;

    for (int i = 0; i < n; i++) {
        recip[i].onSpanChanged(this, what, s, e, st, en);
    }
}