Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7b61b3a authored by Gilles Debunne's avatar Gilles Debunne Committed by The Android Automerger
Browse files

Handle non DynamicLayout in Editable draw method.

An Editable text will use a BoringLayout when the text is empty.
Fallback on the regular layout draw text method when the layout
does not support the block optimisation.

Change-Id: Ie4bdb4381f2f58b71d7c35b2f5734e544e3115ea
parent d72f88bc
Loading
Loading
Loading
Loading
+55 −54
Original line number Diff line number Diff line
@@ -11708,13 +11708,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            layout.drawBackground(canvas, highlight, mHighlightPaint, cursorOffsetVertical,
                    firstLine, lastLine);

            if (layout instanceof DynamicLayout) {
                if (mTextDisplayLists == null) {
                    mTextDisplayLists = new DisplayList[ArrayUtils.idealObjectArraySize(0)];
                }
            if (! (layout instanceof DynamicLayout)) {
                Log.e(LOG_TAG, "Editable TextView is not using a DynamicLayout");
                return;
            }

                DynamicLayout dynamicLayout = (DynamicLayout) layout;
                int[] blockEnds = dynamicLayout.getBlockEnds();
@@ -11768,6 +11765,10 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                    endOfPreviousBlock = blockEnd;
                }
                canvas.translate(-mScrollX, -mScrollY);
            } else {
                // Fallback on the layout method (a BoringLayout is used when the text is empty)
                layout.drawText(canvas, firstLine, lastLine);
            }
        }

        private int getAvailableDisplayListIndex(int[] blockIndices, int numberOfBlocks,