소스 검색

Merge pull request #179 from teslacoil/master

Additional fix for vibrating windows
Aidan Follestad 10 년 전
부모
커밋
92343c044d
1개의 변경된 파일16개의 추가작업 그리고 3개의 파일을 삭제
  1. 16 3
      library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

+ 16 - 3
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -573,9 +573,22 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener {
         /* Force it to layout it's children */
         if (lv.getLastVisiblePosition() == -1)
             return false;
-        /* We scroll if the last item is not visible */
-        final boolean lastItemVisible = lv.getLastVisiblePosition() == lv.getCount() - 1;
-        return !lastItemVisible || lv.getChildAt(lv.getChildCount() - 1).getBottom() > lv.getHeight() - lv.getPaddingBottom();
+
+        /* We can scroll if the first or last item is not visible */
+        boolean firstItemVisible = lv.getFirstVisiblePosition() == 0;
+        boolean lastItemVisible = lv.getLastVisiblePosition() == lv.getCount() - 1;
+
+        if (firstItemVisible && lastItemVisible) {
+            /* Or the first item's top is above or own top */
+            if (lv.getChildAt(0).getTop() < lv.getPaddingTop())
+                return true;
+
+            /* or the last item's bottom is beyond our own bottom */
+            return lv.getChildAt(lv.getChildCount() - 1).getBottom() >
+                    lv.getHeight() - lv.getPaddingBottom();
+        }
+
+        return true;
     }
 
     private boolean canListViewScroll() {