Merge "Prevent ArrayList allocation for prefer keep clear areas" into tm-dev

This commit is contained in:
Robert Horvath
2022-03-25 13:57:41 +00:00
committed by Android (Google) Code Review

View File

@@ -11939,13 +11939,22 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
@NonNull
List<Rect> collectPreferKeepClearRects() {
ListenerInfo info = mListenerInfo;
final List<Rect> list = new ArrayList<>();
boolean keepBoundsClear =
(info != null && info.mPreferKeepClear) || mPreferKeepClearForFocus;
boolean hasCustomKeepClearRects = info != null && info.mKeepClearRects != null;
if ((info != null && info.mPreferKeepClear) || mPreferKeepClearForFocus) {
if (!keepBoundsClear && !hasCustomKeepClearRects) {
return Collections.emptyList();
} else if (keepBoundsClear && !hasCustomKeepClearRects) {
return Collections.singletonList(new Rect(0, 0, getWidth(), getHeight()));
}
final List<Rect> list = new ArrayList<>();
if (keepBoundsClear) {
list.add(new Rect(0, 0, getWidth(), getHeight()));
}
if (info != null && info.mKeepClearRects != null) {
if (hasCustomKeepClearRects) {
list.addAll(info.mKeepClearRects);
}