Java 类android.text.SpanWatcher 实例源码

项目:Dashchan    文件:CommentTextView.java   
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();
}
项目:JotaTextEditor    文件:SpannableStringBuilder.java   
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);
    }
}
项目:JotaTextEditor    文件:SpannableStringBuilder.java   
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);
    }
}
项目:JotaTextEditor    文件:SpannableStringBuilder.java   
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);
    }
}