Merge "Basic renaming refactoring in Layout" into jb-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
64ac862f7b
@@ -45,8 +45,7 @@ public abstract class Layout {
|
|||||||
private static final ParagraphStyle[] NO_PARA_SPANS =
|
private static final ParagraphStyle[] NO_PARA_SPANS =
|
||||||
ArrayUtils.emptyArray(ParagraphStyle.class);
|
ArrayUtils.emptyArray(ParagraphStyle.class);
|
||||||
|
|
||||||
/* package */ static final EmojiFactory EMOJI_FACTORY =
|
/* package */ static final EmojiFactory EMOJI_FACTORY = EmojiFactory.newAvailableInstance();
|
||||||
EmojiFactory.newAvailableInstance();
|
|
||||||
/* package */ static final int MIN_EMOJI, MAX_EMOJI;
|
/* package */ static final int MIN_EMOJI, MAX_EMOJI;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -363,15 +362,15 @@ public abstract class Layout {
|
|||||||
// direction of the layout or line. XXX: Should they?
|
// direction of the layout or line. XXX: Should they?
|
||||||
// They are evaluated at each line.
|
// They are evaluated at each line.
|
||||||
if (mSpannedText) {
|
if (mSpannedText) {
|
||||||
if (lineBackgroundSpans == null) {
|
if (mLineBackgroundSpans == null) {
|
||||||
lineBackgroundSpans = new SpanSet<LineBackgroundSpan>(LineBackgroundSpan.class);
|
mLineBackgroundSpans = new SpanSet<LineBackgroundSpan>(LineBackgroundSpan.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
Spanned buffer = (Spanned) mText;
|
Spanned buffer = (Spanned) mText;
|
||||||
int textLength = buffer.length();
|
int textLength = buffer.length();
|
||||||
lineBackgroundSpans.init(buffer, 0, textLength);
|
mLineBackgroundSpans.init(buffer, 0, textLength);
|
||||||
|
|
||||||
if (lineBackgroundSpans.numberOfSpans > 0) {
|
if (mLineBackgroundSpans.numberOfSpans > 0) {
|
||||||
int previousLineBottom = getLineTop(firstLine);
|
int previousLineBottom = getLineTop(firstLine);
|
||||||
int previousLineEnd = getLineStart(firstLine);
|
int previousLineEnd = getLineStart(firstLine);
|
||||||
ParagraphStyle[] spans = NO_PARA_SPANS;
|
ParagraphStyle[] spans = NO_PARA_SPANS;
|
||||||
@@ -392,17 +391,18 @@ public abstract class Layout {
|
|||||||
if (start >= spanEnd) {
|
if (start >= spanEnd) {
|
||||||
// These should be infrequent, so we'll use this so that
|
// These should be infrequent, so we'll use this so that
|
||||||
// we don't have to check as often.
|
// we don't have to check as often.
|
||||||
spanEnd = lineBackgroundSpans.getNextTransition(start, textLength);
|
spanEnd = mLineBackgroundSpans.getNextTransition(start, textLength);
|
||||||
// All LineBackgroundSpans on a line contribute to its background.
|
// All LineBackgroundSpans on a line contribute to its background.
|
||||||
spansLength = 0;
|
spansLength = 0;
|
||||||
// Duplication of the logic of getParagraphSpans
|
// Duplication of the logic of getParagraphSpans
|
||||||
if (start != end || start == 0) {
|
if (start != end || start == 0) {
|
||||||
// Equivalent to a getSpans(start, end), but filling the 'spans' local
|
// Equivalent to a getSpans(start, end), but filling the 'spans' local
|
||||||
// array instead to reduce memory allocation
|
// array instead to reduce memory allocation
|
||||||
for (int j = 0; j < lineBackgroundSpans.numberOfSpans; j++) {
|
for (int j = 0; j < mLineBackgroundSpans.numberOfSpans; j++) {
|
||||||
// equal test is valid since both intervals are not empty by construction
|
// equal test is valid since both intervals are not empty by
|
||||||
if (lineBackgroundSpans.spanStarts[j] >= end ||
|
// construction
|
||||||
lineBackgroundSpans.spanEnds[j] <= start) continue;
|
if (mLineBackgroundSpans.spanStarts[j] >= end ||
|
||||||
|
mLineBackgroundSpans.spanEnds[j] <= start) continue;
|
||||||
if (spansLength == spans.length) {
|
if (spansLength == spans.length) {
|
||||||
// The spans array needs to be expanded
|
// The spans array needs to be expanded
|
||||||
int newSize = ArrayUtils.idealObjectArraySize(2 * spansLength);
|
int newSize = ArrayUtils.idealObjectArraySize(2 * spansLength);
|
||||||
@@ -410,7 +410,7 @@ public abstract class Layout {
|
|||||||
System.arraycopy(spans, 0, newSpans, 0, spansLength);
|
System.arraycopy(spans, 0, newSpans, 0, spansLength);
|
||||||
spans = newSpans;
|
spans = newSpans;
|
||||||
}
|
}
|
||||||
spans[spansLength++] = lineBackgroundSpans.spans[j];
|
spans[spansLength++] = mLineBackgroundSpans.spans[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -423,7 +423,7 @@ public abstract class Layout {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lineBackgroundSpans.recycle();
|
mLineBackgroundSpans.recycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
// There can be a highlight even without spans if we are drawing
|
// There can be a highlight even without spans if we are drawing
|
||||||
@@ -1687,7 +1687,7 @@ public abstract class Layout {
|
|||||||
* styles that are already applied to the buffer will apply to text that
|
* styles that are already applied to the buffer will apply to text that
|
||||||
* is inserted into it.
|
* is inserted into it.
|
||||||
*/
|
*/
|
||||||
/* package */ static <T> T[] getParagraphSpans(Spanned text, int start, int end, Class<T> type) {
|
/* package */static <T> T[] getParagraphSpans(Spanned text, int start, int end, Class<T> type) {
|
||||||
if (start == end && start > 0) {
|
if (start == end && start > 0) {
|
||||||
return ArrayUtils.emptyArray(type);
|
return ArrayUtils.emptyArray(type);
|
||||||
}
|
}
|
||||||
@@ -1857,7 +1857,7 @@ public abstract class Layout {
|
|||||||
private static final Rect sTempRect = new Rect();
|
private static final Rect sTempRect = new Rect();
|
||||||
private boolean mSpannedText;
|
private boolean mSpannedText;
|
||||||
private TextDirectionHeuristic mTextDir;
|
private TextDirectionHeuristic mTextDir;
|
||||||
private SpanSet<LineBackgroundSpan> lineBackgroundSpans;
|
private SpanSet<LineBackgroundSpan> mLineBackgroundSpans;
|
||||||
|
|
||||||
public static final int DIR_LEFT_TO_RIGHT = 1;
|
public static final int DIR_LEFT_TO_RIGHT = 1;
|
||||||
public static final int DIR_RIGHT_TO_LEFT = -1;
|
public static final int DIR_RIGHT_TO_LEFT = -1;
|
||||||
|
|||||||
Reference in New Issue
Block a user