Refine search
static boolean listIsAtTop(AbsListView listView) { return listView.getChildCount() == 0 || listView.getChildAt(0).getTop() == listView.getPaddingTop(); }
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); }
private void onScrollStateChanged2(AbsListView lv, int scrollState){ lv.setTag(AQuery.TAG_NUM, scrollState); int first = lv.getFirstVisiblePosition(); int last = lv.getLastVisiblePosition(); ListAdapter la = lv.getAdapter(); View convertView = lv.getChildAt(i); Number targetPacked = (Number) convertView.getTag(AQuery.TAG_NUM); convertView.setTag(AQuery.TAG_NUM, null); }else{
@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 boolean canScrollListDown() { // Ported from AbsListView#canScrollList() which isn't compatible to all API levels final int childCount = mView.getChildCount(); final int itemsCount = mView.getCount(); final int firstPosition = mView.getFirstVisiblePosition(); final int lastPosition = firstPosition + childCount; final int lastBottom = mView.getChildAt(childCount - 1).getBottom(); return lastPosition < itemsCount || lastBottom > mView.getHeight() - mView.getListPaddingBottom(); } }
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 int getScrollY(AbsListView lv) { View c = lv.getChildAt(0); if (c == null) { return 0; int firstVisiblePosition = lv.getFirstVisiblePosition(); int scrollY = -(c.getTop()); sListViewItemHeights.put(lv.getFirstVisiblePosition(), c.getHeight());
} else if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; int count = absListView.getAdapter().getCount(); int fristPos = absListView.getFirstVisiblePosition(); if (fristPos == 0 && absListView.getChildAt(0).getTop() >= absListView .getPaddingTop()) { return false; int lastPos = absListView.getLastVisiblePosition(); if (lastPos > 0 && count > 0 && lastPos == count - 1) { return true; .getChildAt(scrollView.getChildCount() - 1); if (view != null) { int diff = (view.getBottom() - (scrollView.getHeight() + scrollView .getScrollY())); if (diff == 0) {
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); } }
/** * 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 boolean canChildScrollDown() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; View lastChild = absListView.getChildAt(absListView.getChildCount() - 1); if (lastChild != null) { return (absListView.getLastVisiblePosition() == (absListView.getCount() - 1)) && lastChild.getBottom() > absListView.getPaddingBottom(); } else { return false; } } else { return mTarget.getHeight() - mTarget.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTarget, 1); } }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case OnScrollListener.SCROLL_STATE_IDLE: if (scrolling){ // get first visible item View itemView = view.getChildAt(0); int top = Math.abs(itemView.getTop()); // top is a negative value int bottom = Math.abs(itemView.getBottom()); if (top >= bottom){ ((ListView)view).setSelectionFromTop(view.getFirstVisiblePosition()+1, 0); } else { ((ListView)view).setSelectionFromTop(view.getFirstVisiblePosition(), 0); } } scrolling = false; break; case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: case OnScrollListener.SCROLL_STATE_FLING: Log.i("TEST", "SCROLLING"); scrolling = true; break; } }
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; }
public void updateSingleRow(AbsListView listView, int viewId) { if (listView != null) { int start = listView.getFirstVisiblePosition(); for (int i = start, j = listView.getLastVisiblePosition(); i <= j; i++) if (viewId == ((View)listView.getItemAtPosition(i)).getId()) { View view = listView.getChildAt(i - start); getView(i, view, listView); break; } } }
public static boolean canScrollUp(@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; return viewGroup.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || viewGroup.getChildAt(0).getTop() < targetView.getPaddingTop()); } else { return targetView.getScrollY() > 0; } } else { return targetView.canScrollVertically(-1); } }
public static boolean canScrollLeft(@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; return viewGroup.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || viewGroup.getChildAt(0).getTop() < targetView.getPaddingTop()); } else { return targetView.getScrollY() > 0; } } else { return targetView.canScrollHorizontally(-1); } }
@Override public boolean canOverStart() { if (absListView.getCount() == 0) { return true; } else if (absListView.getFirstVisiblePosition() == 0 && absListView.getChildAt(0).getTop() >= absListView.getPaddingTop()) { return true; } return false; }
@Override public void run() { mIsLoadingMore = false; mRefreshViewHolder.onEndLoadingMore(); mLoadMoreFooterView.setVisibility(GONE); if (mAbsListView != null) { if (mAbsListView.getAdapter() != null && mAbsListView.getAdapter().getCount() > 0) { mAbsListView.scrollBy(0, -mLoadMoreFooterViewHeight); } } } };
public boolean canScrollListUp() { // Ported from AbsListView#canScrollList() which isn't compatible to all API levels final int firstTop = mView.getChildAt(0).getTop(); final int firstPosition = mView.getFirstVisiblePosition(); return firstPosition > 0 || firstTop < mView.getListPaddingTop(); }
/** * 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); } }