From b1a278f513fac9071b9c4c151910fb157035950f Mon Sep 17 00:00:00 2001 From: Steve Lhomme Date: Tue, 6 Aug 2013 12:42:45 +0200 Subject: [PATCH] Fix the pull happening when the top element is not shown --- .../library/PullToRefreshAdapterViewBase.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/library/src/com/handmark/pulltorefresh/library/PullToRefreshAdapterViewBase.java b/library/src/com/handmark/pulltorefresh/library/PullToRefreshAdapterViewBase.java index cfff83716..e0f3750da 100644 --- a/library/src/com/handmark/pulltorefresh/library/PullToRefreshAdapterViewBase.java +++ b/library/src/com/handmark/pulltorefresh/library/PullToRefreshAdapterViewBase.java @@ -388,9 +388,10 @@ private boolean isFirstItemVisible() { * now we'll just add one to account for it and rely on the inner * condition which checks getTop(). */ - if (mRefreshableView.getFirstVisiblePosition() <= 1) { + if ((null == mIndicatorIvTop && mRefreshableView.getFirstVisiblePosition() == 0) || + (null != mIndicatorIvTop && mRefreshableView.getFirstVisiblePosition() <= 1)) { final View firstVisibleChild = mRefreshableView.getChildAt(0); - if (firstVisibleChild != null) { + if (firstVisibleChild != null && firstVisibleChild != mIndicatorIvTop) { return firstVisibleChild.getTop() >= mRefreshableView.getTop(); } } @@ -423,10 +424,11 @@ private boolean isLastItemVisible() { * account for it and rely on the inner condition which checks * getBottom(). */ - if (lastVisiblePosition >= lastItemPosition - 1) { + if ((null == mIndicatorIvBottom && lastVisiblePosition == lastItemPosition) || + (null != mIndicatorIvBottom && lastVisiblePosition >= lastItemPosition - 1)) { final int childIndex = lastVisiblePosition - mRefreshableView.getFirstVisiblePosition(); final View lastVisibleChild = mRefreshableView.getChildAt(childIndex); - if (lastVisibleChild != null) { + if (lastVisibleChild != null && lastVisibleChild != mIndicatorIvBottom) { return lastVisibleChild.getBottom() <= mRefreshableView.getBottom(); } }