Browse Source

Crash fix, resolves #439

Aidan Follestad 10 năm trước cách đây
mục cha
commit
cd8c277f0a

+ 3 - 2
library/src/main/java/com/afollestad/materialdialogs/internal/MDRootLayout.java

@@ -502,7 +502,8 @@ public class MDRootLayout extends ViewGroup {
      */
     @Nullable
     private static View getBottomView(ViewGroup viewGroup) {
-        if (viewGroup == null) return null;
+        if (viewGroup == null || viewGroup.getChildCount() == 0)
+            return null;
         View bottomView = null;
         for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) {
             View child = viewGroup.getChildAt(i);
@@ -516,7 +517,7 @@ public class MDRootLayout extends ViewGroup {
 
     @Nullable
     private static View getTopView(ViewGroup viewGroup) {
-        if (viewGroup == null)
+        if (viewGroup == null || viewGroup.getChildCount() == 0)
             return null;
         View topView = null;
         for (int i = viewGroup.getChildCount() - 1; i >= 0; i--) {