diff options
author | Gilles Debunne <debunne@google.com> | 2012-03-13 11:24:01 -0700 |
---|---|---|
committer | Gilles Debunne <debunne@google.com> | 2012-03-13 14:58:37 -0700 |
commit | 4ffb879f4866f7d51070bfc9d10e7a2fdac62d4c (patch) | |
tree | 1597882fbcd42b2af271798ffa0ba5880f8daad7 /core/java/android/text/TextLine.java | |
parent | dd4a464741a1f674e7e5f04c1694912810855719 (diff) | |
download | frameworks_base-4ffb879f4866f7d51070bfc9d10e7a2fdac62d4c.zip frameworks_base-4ffb879f4866f7d51070bfc9d10e7a2fdac62d4c.tar.gz frameworks_base-4ffb879f4866f7d51070bfc9d10e7a2fdac62d4c.tar.bz2 |
New SpanSet class extracted from TextLine.
Change-Id: I424dbd7ff0693fd465b6c83ebabba221b2eca6fe
Diffstat (limited to 'core/java/android/text/TextLine.java')
-rw-r--r-- | core/java/android/text/TextLine.java | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/core/java/android/text/TextLine.java b/core/java/android/text/TextLine.java index 1e8a2f7..0d2835a 100644 --- a/core/java/android/text/TextLine.java +++ b/core/java/android/text/TextLine.java @@ -30,8 +30,6 @@ import android.util.Log; import com.android.internal.util.ArrayUtils; -import java.lang.reflect.Array; - /** * Represents a line of styled text, for measuring in visual order and * for rendering. @@ -860,78 +858,6 @@ class TextLine { return runIsRtl ? -ret : ret; } - private static class SpanSet<E> { - int numberOfSpans; - E[] spans; - int[] spanStarts; - int[] spanEnds; - int[] spanFlags; - final Class<? extends E> classType; - - SpanSet(Class<? extends E> type) { - classType = type; - numberOfSpans = 0; - } - - @SuppressWarnings("unchecked") - public void init(Spanned spanned, int start, int limit) { - final E[] allSpans = spanned.getSpans(start, limit, classType); - final int length = allSpans.length; - - if (length > 0 && (spans == null || spans.length < length)) { - // These arrays may end up being too large because of empty spans - spans = (E[]) Array.newInstance(classType, length); - spanStarts = new int[length]; - spanEnds = new int[length]; - spanFlags = new int[length]; - } - - numberOfSpans = 0; - for (int i = 0; i < length; i++) { - final E span = allSpans[i]; - - final int spanStart = spanned.getSpanStart(span); - final int spanEnd = spanned.getSpanEnd(span); - if (spanStart == spanEnd) continue; - - final int spanFlag = spanned.getSpanFlags(span); - - spans[numberOfSpans] = span; - spanStarts[numberOfSpans] = spanStart; - spanEnds[numberOfSpans] = spanEnd; - spanFlags[numberOfSpans] = spanFlag; - - numberOfSpans++; - } - } - - public boolean hasSpansIntersecting(int start, int end) { - for (int i = 0; i < numberOfSpans; i++) { - // equal test is valid since both intervals are not empty by construction - if (spanStarts[i] >= end || spanEnds[i] <= start) continue; - return true; - } - return false; - } - - int getNextTransition(int start, int limit) { - for (int i = 0; i < numberOfSpans; i++) { - final int spanStart = spanStarts[i]; - final int spanEnd = spanEnds[i]; - if (spanStart > start && spanStart < limit) limit = spanStart; - if (spanEnd > start && spanEnd < limit) limit = spanEnd; - } - return limit; - } - - public void recycle() { - // The spans array is guaranteed to be not null when numberOfSpans is > 0 - for (int i = 0; i < numberOfSpans; i++) { - spans[i] = null; // prevent a leak: no reference kept when TextLine is recycled - } - } - } - /** * Utility function for handling a unidirectional run. The run must not * contain tabs or emoji but can contain styles. |