From f102d4266be803e16543c81df6f380bd4c447c86 Mon Sep 17 00:00:00 2001 From: Doris Liu Date: Tue, 30 Jun 2015 13:42:22 -0700 Subject: [PATCH] Allow null child view when checking whether divider should draw The beginning divider should draw before the first child that is not set to GONE. Incidentally, there needs to be a check for such a child, which involves checking the visibility of all the children with lower indices. This CL takes into account the scenarios where children with lower indices could be null, in which case we'll treat them as if they were GONE. Bug: 22199594 Change-Id: Iefc73ef87beec219898c967b9a3ccebd1e3b5b4c --- core/java/android/widget/LinearLayout.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/java/android/widget/LinearLayout.java b/core/java/android/widget/LinearLayout.java index 4dcc24283a4e6..b5e08ca5caa0d 100644 --- a/core/java/android/widget/LinearLayout.java +++ b/core/java/android/widget/LinearLayout.java @@ -659,7 +659,8 @@ public class LinearLayout extends ViewGroup { */ private boolean allViewsAreGoneBefore(int childIndex) { for (int i = childIndex - 1; i >= 0; i--) { - if (getVirtualChildAt(i).getVisibility() != GONE) { + View child = getVirtualChildAt(i); + if (child != null && child.getVisibility() != GONE) { return false; } }