Merge "Guarding against null pointer exception when setting view structure info for content capture" into sc-dev
This commit is contained in:
@@ -11854,23 +11854,28 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
|
|||||||
|
|
||||||
// Get the text and trim it to the range we are reporting.
|
// Get the text and trim it to the range we are reporting.
|
||||||
CharSequence text = getText();
|
CharSequence text = getText();
|
||||||
if (expandedTopChar > 0 || expandedBottomChar < text.length()) {
|
|
||||||
text = text.subSequence(expandedTopChar, expandedBottomChar);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) {
|
if (text != null) {
|
||||||
structure.setText(text);
|
if (expandedTopChar > 0 || expandedBottomChar < text.length()) {
|
||||||
} else {
|
text = text.subSequence(expandedTopChar, expandedBottomChar);
|
||||||
structure.setText(text, selStart - expandedTopChar, selEnd - expandedTopChar);
|
}
|
||||||
|
|
||||||
final int[] lineOffsets = new int[bottomLine - topLine + 1];
|
if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) {
|
||||||
final int[] lineBaselines = new int[bottomLine - topLine + 1];
|
structure.setText(text);
|
||||||
final int baselineOffset = getBaselineOffset();
|
} else {
|
||||||
for (int i = topLine; i <= bottomLine; i++) {
|
structure.setText(text,
|
||||||
lineOffsets[i - topLine] = layout.getLineStart(i);
|
selStart - expandedTopChar,
|
||||||
lineBaselines[i - topLine] = layout.getLineBaseline(i) + baselineOffset;
|
selEnd - expandedTopChar);
|
||||||
|
|
||||||
|
final int[] lineOffsets = new int[bottomLine - topLine + 1];
|
||||||
|
final int[] lineBaselines = new int[bottomLine - topLine + 1];
|
||||||
|
final int baselineOffset = getBaselineOffset();
|
||||||
|
for (int i = topLine; i <= bottomLine; i++) {
|
||||||
|
lineOffsets[i - topLine] = layout.getLineStart(i);
|
||||||
|
lineBaselines[i - topLine] = layout.getLineBaseline(i) + baselineOffset;
|
||||||
|
}
|
||||||
|
structure.setTextLines(lineOffsets, lineBaselines);
|
||||||
}
|
}
|
||||||
structure.setTextLines(lineOffsets, lineBaselines);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user