public static boolean canScrollDown(@NonNull View targetView) { if (android.os.Build.VERSION.SDK_INT < 14) { if (targetView instanceof AbsListView) { final ViewGroup viewGroup = (ViewGroup) targetView; final AbsListView absListView = (AbsListView) targetView; final int childCount = viewGroup.getChildCount(); return childCount > 0 && (absListView.getLastVisiblePosition() < childCount - 1 || viewGroup.getChildAt(childCount - 1).getBottom() > targetView.getPaddingBottom()); } else { return targetView.getScrollY() < 0; } } else { return targetView.canScrollVertically(1); } }
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { //leave this empty } @Override public void onScrollStateChanged(AbsListView listView, int scrollState) { if (scrollState == SCROLL_STATE_IDLE) { if (listView.getLastVisiblePosition() >= listView.getCount() - 1 - threshold) { currentPage++; //load more list items: loadElements(currentPage); } } }
public static boolean canScrollRight(@NonNull View targetView) { if (android.os.Build.VERSION.SDK_INT < 14) { if (targetView instanceof AbsListView) { final ViewGroup viewGroup = (ViewGroup) targetView; final AbsListView absListView = (AbsListView) targetView; final int childCount = viewGroup.getChildCount(); return childCount > 0 && (absListView.getLastVisiblePosition() < childCount - 1 || viewGroup.getChildAt(childCount - 1).getBottom() > targetView.getPaddingBottom()); } else { return targetView.getScrollY() < 0; } } else { return targetView.canScrollHorizontally(1); } }
private void checkScrolledBottom(AbsListView view, int scrollState){ int cc = view.getCount(); int last = view.getLastVisiblePosition(); if(scrollState == OnScrollListener.SCROLL_STATE_IDLE && cc == last + 1){ if(last != lastBottom){ lastBottom = last; invoke(view, scrollState); } }else{ lastBottom = -1; } }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_IDLE) { if (view.getLastVisiblePosition() == view.getCount() - 1 && !ViewCompat.canScrollVertically(view, 1)) { swipeToLoadLayout.setLoadingMore(true); } } }
@Override public void onScrollStateChanged(AbsListView listView, int scrollState) { // TODO: Try change to RecyclerView as currently gets stuck a lot when using scrollbar on right of ListView // Start rendering the question & answer every time the user stops scrolling if (scrollState == SCROLL_STATE_IDLE) { int startIdx = listView.getFirstVisiblePosition(); int numVisible = listView.getLastVisiblePosition() - startIdx; DeckTask.launchDeckTask(DeckTask.TASK_TYPE_RENDER_BROWSER_QA, mRenderQAHandler, new DeckTask.TaskData(new Object[]{getCards(), startIdx - 5, 2 * numVisible + 5})); } } }
int last = lv.getLastVisiblePosition();
private void fillByListView(final List<ImageView> originImageList) { AbsListView absListView = transConfig.getListView(); int childCount = absListView.getChildCount(); for (int i = 0; i < childCount; i++) { ImageView originImage = ((ImageView) absListView.getChildAt(i) .findViewById(transConfig.getImageId())); originImageList.add(originImage); } int firstPos = absListView.getFirstVisiblePosition(); int lastPos = absListView.getLastVisiblePosition(); int totalCount = absListView.getCount(); fillPlaceHolder(originImageList, totalCount, firstPos, lastPos); }
public boolean canChildScrollDown() { if (mChildView == null) { return false; } if (android.os.Build.VERSION.SDK_INT < 14) { if (mChildView instanceof AbsListView) { final AbsListView absListView = (AbsListView) mChildView; if (absListView.getChildCount() > 0) { int lastChildBottom = absListView.getChildAt(absListView.getChildCount() - 1).getBottom(); return absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1 && lastChildBottom <= absListView.getMeasuredHeight(); } else { return false; } } else { return ViewCompat.canScrollVertically(mChildView, 1) || mChildView.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mChildView, 1); } }
/** * Whether it is possible for the child view of this layout to * scroll down. Override this if the child view is a custom view. * * @return */ protected boolean canChildScrollDown() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTargetView instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTargetView; return absListView.getChildCount() > 0 && (absListView.getLastVisiblePosition() < absListView.getChildCount() - 1 || absListView.getChildAt(absListView.getChildCount() - 1).getBottom() > absListView.getPaddingBottom()); } else { return ViewCompat.canScrollVertically(mTargetView, 1) || mTargetView.getScrollY() < 0; } } else { return ViewCompat.canScrollVertically(mTargetView, 1); } }
return false; int lastPos = absListView.getLastVisiblePosition(); if (lastPos > 0 && count > 0 && lastPos == count - 1) { return true;
int lastVisiblePosition = absListView.getLastVisiblePosition(); return false; int lastVisiblePosition = absListView.getLastVisiblePosition();
/** * Whether child view can scroll down * @return */ public boolean canChildScrollDown() { if (mTargetView == null) { return false; } if (Build.VERSION.SDK_INT < 14) { if (mTargetView instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTargetView; if (absListView.getChildCount() > 0) { int lastChildBottom = absListView.getChildAt(absListView.getChildCount() - 1) .getBottom(); return absListView.getLastVisiblePosition() == absListView.getAdapter().getCount() - 1 && lastChildBottom <= absListView.getMeasuredHeight(); } else { return false; } } else { return ViewCompat.canScrollVertically(mTargetView, 1) || mTargetView.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTargetView, 1); } }
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; }
} else { final int lastItemPosition = mRefreshableView.getCount() - 1; final int lastVisiblePosition = mRefreshableView.getLastVisiblePosition();
if (mRefreshViewListener != null && !hasLoadCompleted() && !mIsLoadingMore && mTotalItemCount - 1 <= view.getLastVisiblePosition() + mPreLoadCount) { mRefreshViewListener.onLoadMore(true); mIsLoadingMore = true; if (mTotalItemCount - 1 <= view.getLastVisiblePosition() + mPreLoadCount) { if (!mIsLoadingMore) { mIsLoadingMore = mContainer.invokeLoadMore();
return false; int lastPos = absListView.getLastVisiblePosition(); if (lastPos > 0 && count > 0 && lastPos == count - 1) { return true;
public boolean canChildPullUp() { if (child instanceof AbsListView) { AbsListView absListView = (AbsListView) child; return canScrollVertically(child, 1) || absListView.getLastVisiblePosition() != mTotalItemCount - 1; } else if (child instanceof WebView) { WebView webview = (WebView) child; if (webview instanceof XWebView) { return !((XWebView) webview).isBottom(); } else { float left = webview.getContentHeight() * webview.getScale(); int right = webview.getHeight() + webview.getScrollY(); return left != right; } } else if (child instanceof ScrollView) { ScrollView scrollView = (ScrollView) child; View childView = scrollView.getChildAt(0); if (childView != null) { return canScrollVertically(child, 1) || scrollView.getScrollY() < childView.getHeight() - scrollView.getHeight(); } } else { return canScrollVertically(child, 1); } return true; }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if(scrollState == OnScrollListener.SCROLL_STATE_IDLE){ if(cursor != null){ int lasPos = view.getLastVisiblePosition(); if(hasMoreData && !isLoading && lasPos == listView.getCount()-1){ loadAndShowData(); } } } }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if(scrollState == OnScrollListener.SCROLL_STATE_IDLE){ if(listView.getCount() != 0){ int lasPos = view.getLastVisiblePosition(); if(hasMoreData && !isLoading && lasPos == listView.getCount()-1){ loadAndShowData(); } } } }