private int getTopItemScrollY() { if (mListView == null || mListView.getChildAt(0) == null) return 0; View topChild = mListView.getChildAt(0); return topChild.getTop(); } }
static boolean listIsAtTop(AbsListView listView) { return listView.getChildCount() == 0 || listView.getChildAt(0).getTop() == listView.getPaddingTop(); }
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(); }
@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; } }
/** * Returns the view in the specified list line * * @param absListView the ListView to use * @param index the index of the list. E.g. Index 1 if two lists are available * @param lineIndex the line index of the View * @return the View located at a specified list line */ private View getViewOnAbsListLine(AbsListView absListView, int index, int lineIndex){ final long endTime = SystemClock.uptimeMillis() + Timeout.getSmallTimeout(); View view = absListView.getChildAt(lineIndex); while(view == null){ final boolean timedOut = SystemClock.uptimeMillis() > endTime; if (timedOut){ Assert.fail("View is null and can therefore not be clicked!"); } sleeper.sleep(); absListView = (AbsListView) viewFetcher.getIdenticalView(absListView); if(absListView == null){ absListView = waiter.waitForAndGetView(index, AbsListView.class); } view = absListView.getChildAt(lineIndex); } return view; }
@Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { MonthView child = (MonthView) view.getChildAt(0); if (child == null) return; // Figure out where we are mPreviousScrollPosition = getFirstVisiblePosition() * child.getHeight() - child.getBottom(); mPreviousScrollState = mCurrentScrollState; }
public boolean canScrollUp(View view) { if (android.os.Build.VERSION.SDK_INT < 14) { if (view instanceof AbsListView) { final AbsListView absListView = (AbsListView) view; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView .getChildAt(0).getTop() < absListView.getPaddingTop()); } else { return view.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(view, -1); } }
/** * 判断目标View是否滑动到顶部-还能否继续滑动 * * @return */ public boolean isChildScrollToTop() { if (Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; return !(absListView.getChildCount() > 0 && (absListView .getFirstVisiblePosition() > 0 || absListView .getChildAt(0).getTop() < absListView.getPaddingTop())); } else { return !(mTarget.getScrollY() > 0); } } else { return !ViewCompat.canScrollVertically(mTarget, -1); } }
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { SimpleMonthView child = (SimpleMonthView) view.getChildAt(0); if (child == null) { return; } // Figure out where we are long currScroll = view.getFirstVisiblePosition() * child.getHeight() - child.getBottom(); mPreviousScrollPosition = currScroll; mPreviousScrollState = mCurrentScrollState; }
/** * @return Whether it is possible for the child view of this layout to * scroll up. Override this if the child view is a custom view. */ public boolean canChildScrollUp() { // //For make it can work when my recycler view is in Gone. // return false; if (android.os.Build.VERSION.SDK_INT < 14) { if (mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0) .getTop() < absListView.getPaddingTop()); } else { return ViewCompat.canScrollVertically(mTarget, -1) || mTarget.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTarget, -1); } }
/** * Updates the title and selected month if the view has moved to a new * month. */ @Override public void onScroll( AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { MonthView child = (MonthView) view.getChildAt(0); if (child == null) { return; } // Figure out where we are long currScroll = view.getFirstVisiblePosition() * child.getHeight() - child.getBottom(); mPreviousScrollPosition = currScroll; mPreviousScrollState = mCurrentScrollState; }
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(); } }
View convertView = lv.getChildAt(i); Number targetPacked = (Number) convertView.getTag(AQuery.TAG_NUM);
private boolean canChildScrollUp(View mTarget) { if (mTarget == null) { return false; } if (android.os.Build.VERSION.SDK_INT < 14 && mTarget instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTarget; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0) .getTop() < absListView.getPaddingTop()); } if (mTarget instanceof ViewGroup) { int childCount = ((ViewGroup) mTarget).getChildCount(); for (int i = 0; i < childCount; i++) { View child = ((ViewGroup) mTarget).getChildAt(i); if (canChildScrollUp(child)) { return true; } } } return ViewCompat.canScrollVertically(mTarget, -1); }
private void onDetectedListScroll(AbsListView absListView, int firstVisibleItem) { View view = absListView.getChildAt(0); int top = (view == null) ? 0 : view.getTop(); if (firstVisibleItem == oldFirstVisibleItem) { if (top > oldTop) { onDetectScrollListener.onUpScrolling(); } else if (top < oldTop) { onDetectScrollListener.onDownScrolling(); } } else { if (firstVisibleItem < oldFirstVisibleItem) { onDetectScrollListener.onUpScrolling(); } else { onDetectScrollListener.onDownScrolling(); } } oldTop = top; oldFirstVisibleItem = firstVisibleItem; }
/** * copy from {@link android.support.v4.widget.SwipeRefreshLayout#canChildScrollUp()} * * @return Whether it is possible for the child view of this layout to * scroll up. Override this if the child view is a custom view. */ protected boolean canChildScrollUp() { if (android.os.Build.VERSION.SDK_INT < 14) { if (mTargetView instanceof AbsListView) { final AbsListView absListView = (AbsListView) mTargetView; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0) .getTop() < absListView.getPaddingTop()); } else { return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mTargetView, -1); } }
/** * @return Whether it is possible for the child view of this layout to * scroll up. Override this if the child view is a custom view. */ public boolean canChildScrollUp() { if (mChildView == null) { return false; } if (Build.VERSION.SDK_INT < 14) { if (mChildView instanceof AbsListView) { final AbsListView absListView = (AbsListView) mChildView; return absListView.getChildCount() > 0 && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0) .getTop() < absListView.getPaddingTop()); } else { return ViewCompat.canScrollVertically(mChildView, -1) || mChildView.getScrollY() > 0; } } else { return ViewCompat.canScrollVertically(mChildView, -1); } }
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); } }