Skip to content
This repository has been archived by the owner on Oct 15, 2018. It is now read-only.

fix the bug when there is only header in pulltorefreshListView #243

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,36 @@ public final Orientation getPullToRefreshScrollDirection() {
return Orientation.VERTICAL;
}

@Override
protected boolean isFirstItemVisible() {
final Adapter adapter = mRefreshableView.getAdapter();

if ((null == adapter || adapter.isEmpty()) && !(getRefreshableView().getHeaderViewsCount() > 1)) {
if (DEBUG) {
Log.d(LOG_TAG, "isFirstItemVisible. Empty View.");
}
return true;

} else {

/**
* This check should really just be:
* mRefreshableView.getFirstVisiblePosition() == 0, but PtRListView
* internally use a HeaderView which messes the positions up. For
* now we'll just add one to account for it and rely on the inner
* condition which checks getTop().
*/
if (mRefreshableView.getFirstVisiblePosition() <= 1) {
final View firstVisibleChild = mRefreshableView.getChildAt(0);
if (firstVisibleChild != null) {
return firstVisibleChild.getTop() >= mRefreshableView.getTop();
}
}
}

return false;
}

@Override
protected void onRefreshing(final boolean doScroll) {
/**
Expand Down