@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if (view.getAdapter() != null && ((firstVisibleItem + visibleItemCount) >= totalItemCount) && totalItemCount != mPrevTotalItemCount) { Log.v(TAG, "onListEnd, extending list"); mPrevTotalItemCount = totalItemCount; mAdapter.addMoreData(); } }
ListAdapter la = lv.getAdapter();
ListAdapter adapter = ((AbsListView) view).getAdapter(); while (adapter instanceof WrapperListAdapter) { adapter = ((WrapperListAdapter) adapter).getWrappedAdapter();
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); } }
} else if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; int count = absListView.getAdapter().getCount(); int fristPos = absListView.getFirstVisiblePosition(); if (fristPos == 0
public boolean shouldHandleAbsListViewLoadingMore(AbsListView absListView) { if (mIsLoadingMore || mCurrentRefreshStatus == RefreshStatus.REFRESHING || mLoadMoreFooterView == null || mDelegate == null || absListView == null || absListView.getAdapter() == null || absListView.getAdapter().getCount() == 0) { return false; } return BGARefreshScrollingUtil.isAbsListViewToBottom(absListView); }
public static void scrollToBottom(final AbsListView absListView) { if (absListView != null) { if (absListView.getAdapter() != null && absListView.getAdapter().getCount() > 0) { absListView.post(new Runnable() { @Override public void run() { absListView.setSelection(absListView.getAdapter().getCount() - 1); } }); } } }
@Override public void run() { absListView.setSelection(absListView.getAdapter().getCount() - 1); } });
/** * get AbsListView height according to every children * * @param view * @return */ public static int getAbsListViewHeightBasedOnChildren(AbsListView view) { ListAdapter adapter; if (view == null || (adapter = view.getAdapter()) == null) { return 0; } int height = 0; for (int i = 0; i < adapter.getCount(); i++) { View item = adapter.getView(i, null, view); if (item instanceof ViewGroup) { item.setLayoutParams(new LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); } item.measure(0, 0); height += item.getMeasuredHeight(); } height += view.getPaddingTop() + view.getPaddingBottom(); return height; }
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; }
private boolean isFirstItemVisible() { final Adapter adapter = mRefreshableView.getAdapter(); if (null == adapter || adapter.isEmpty()) { 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; }
/** * 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); } }
private boolean isLastItemVisible() { final Adapter adapter = mRefreshableView.getAdapter();
} else if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; int count = absListView.getAdapter().getCount(); int fristPos = absListView.getFirstVisiblePosition(); if (fristPos == 0
public boolean shouldHandleAbsListViewLoadingMore(AbsListView absListView) { if (mIsLoadingMore || mCurrentRefreshStatus == RefreshStatus.REFRESHING || mLoadMoreFooterView == null || mDelegate == null || absListView == null || absListView.getAdapter() == null || absListView.getAdapter().getCount() == 0) { return false; } return RefreshScrollingUtil.isAbsListViewToBottom(absListView); }
public static void scrollToBottom(final AbsListView absListView) { if (absListView != null) { if (absListView.getAdapter() != null && absListView.getAdapter().getCount() > 0) { absListView.post(new Runnable() { @Override public void run() { absListView.setSelection(absListView.getAdapter().getCount() - 1); } }); } } }
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { if(mTimeLineText.getVisibility() == View.VISIBLE) { int index = firstVisibleItem + 1 == view.getAdapter().getCount() ? view.getAdapter().getCount() - 1 : firstVisibleItem + 1; ImageInfo imageInfo = (ImageInfo) view.getAdapter().getItem(index); if (imageInfo != null) { mTimeLineText.setText(TimeUtils.formatPhotoDate(imageInfo.path)); } } } });
@Override public void run() { absListView.setSelection(absListView.getAdapter().getCount() - 1); } });
private void setEmptyText() { getView().findViewById(R.id.newProject).setVisibility(View.GONE); getView().findViewById(R.id.no_saved_project).setVisibility(View.GONE); getView().findViewById(R.id.no_saved_apks).setVisibility(View.GONE); if (mListView.getAdapter().getCount() == 0) { getView().findViewById(R.id.no_saved_drafts).setVisibility(View.VISIBLE); } else { getView().findViewById(R.id.no_saved_drafts).setVisibility(View.GONE); } }
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); return lastChild.getBottom() <= absListView.getMeasuredHeight(); } return false; }