use of cn.bingoogolapple.refreshlayout.BGAStickyNavLayout in project BGARefreshLayout-Android by bingoogolapple.
the class BGARefreshScrollingUtil method isAbsListViewToBottom.
public static boolean isAbsListViewToBottom(AbsListView absListView) {
if (absListView != null && absListView.getAdapter() != null && absListView.getChildCount() > 0 && absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1) {
View lastChild = absListView.getChildAt(absListView.getChildCount() - 1);
BGAStickyNavLayout stickyNavLayout = getStickyNavLayout(absListView);
if (stickyNavLayout != null) {
// 处理BGAStickyNavLayout中lastChild.getBottom() <= absListView.getMeasuredHeight()失效问题
// 0表示x,1表示y
int[] location = new int[2];
lastChild.getLocationOnScreen(location);
int lastChildBottomOnScreen = location[1] + lastChild.getMeasuredHeight();
stickyNavLayout.getLocationOnScreen(location);
int stickyNavLayoutBottomOnScreen = location[1] + stickyNavLayout.getMeasuredHeight();
return lastChildBottomOnScreen + absListView.getPaddingBottom() <= stickyNavLayoutBottomOnScreen;
} else {
return lastChild.getBottom() <= absListView.getMeasuredHeight();
}
}
return false;
}
use of cn.bingoogolapple.refreshlayout.BGAStickyNavLayout in project BGARefreshLayout-Android by bingoogolapple.
the class BGARefreshScrollingUtil method isRecyclerViewToBottom.
public static boolean isRecyclerViewToBottom(RecyclerView recyclerView) {
if (recyclerView != null) {
RecyclerView.LayoutManager manager = recyclerView.getLayoutManager();
if (manager == null || manager.getItemCount() == 0) {
return false;
}
if (manager instanceof LinearLayoutManager) {
// 处理item高度超过一屏幕时的情况
View lastVisibleChild = recyclerView.getChildAt(recyclerView.getChildCount() - 1);
if (lastVisibleChild != null && lastVisibleChild.getMeasuredHeight() >= recyclerView.getMeasuredHeight()) {
if (android.os.Build.VERSION.SDK_INT < 14) {
return !(ViewCompat.canScrollVertically(recyclerView, 1) || recyclerView.getScrollY() < 0);
} else {
return !ViewCompat.canScrollVertically(recyclerView, 1);
}
}
LinearLayoutManager layoutManager = (LinearLayoutManager) manager;
if (layoutManager.findLastCompletelyVisibleItemPosition() == layoutManager.getItemCount() - 1) {
BGAStickyNavLayout stickyNavLayout = getStickyNavLayout(recyclerView);
if (stickyNavLayout != null) {
// 处理BGAStickyNavLayout中findLastCompletelyVisibleItemPosition失效问题
View lastCompletelyVisibleChild = layoutManager.getChildAt(layoutManager.findLastCompletelyVisibleItemPosition());
if (lastCompletelyVisibleChild == null) {
return true;
} else {
// 0表示x,1表示y
int[] location = new int[2];
lastCompletelyVisibleChild.getLocationOnScreen(location);
int lastChildBottomOnScreen = location[1] + lastCompletelyVisibleChild.getMeasuredHeight();
stickyNavLayout.getLocationOnScreen(location);
int stickyNavLayoutBottomOnScreen = location[1] + stickyNavLayout.getMeasuredHeight();
return lastChildBottomOnScreen <= stickyNavLayoutBottomOnScreen;
}
} else {
return true;
}
}
} else if (manager instanceof StaggeredGridLayoutManager) {
StaggeredGridLayoutManager layoutManager = (StaggeredGridLayoutManager) manager;
int[] out = layoutManager.findLastCompletelyVisibleItemPositions(null);
int lastPosition = layoutManager.getItemCount() - 1;
for (int position : out) {
if (position == lastPosition) {
return true;
}
}
}
}
return false;
}
Aggregations