@Override public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case OnScrollListener.SCROLL_STATE_IDLE: imageLoader.resume(); break; case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: if (pauseOnScroll) { imageLoader.pause(); } break; case OnScrollListener.SCROLL_STATE_FLING: if (pauseOnFling) { imageLoader.pause(); } break; } if (externalListener != null) { externalListener.onScrollStateChanged(view, scrollState); } }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case OnScrollListener.SCROLL_STATE_IDLE: bitmapUtils.resumeTasks(); LogUtils.i("当前ListView停止滚动,加载图片开始......................"); break; case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: if (pauseOnScroll) { bitmapUtils.pauseTasks(); LogUtils.i("当前ListView被触摸滚动,暂停加载......................"); } break; case OnScrollListener.SCROLL_STATE_FLING: if (pauseOnFling) { bitmapUtils.pauseTasks(); LogUtils.i("当前ListView被手势离开滚动,暂停加载......................"); } break; } if (externalListener != null) { externalListener.onScrollStateChanged(view, scrollState); } }
public final void onScrollStateChanged(final AbsListView view, final int state) { /** * Check that the scrolling has stopped, and that the last item is * visible. */ if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) { if (isLoadAvailable()) { setLoadAvailable(false); mOnLastItemVisibleListener.onLastItemVisible(); } } if (null != mOnScrollListener) { mOnScrollListener.onScrollStateChanged(view, state); } }
public static void addScrollListener(ListView listview, OnScrollListener listener){ if (listview == null || listener == null) { return; } OnScrollListener originListener = getScrollListenerFromListView(listview); if (originListener instanceof MultiScrollListener) { (((MultiScrollListener)originListener)).addListener(listener); } else { MultiScrollListener multiScrollListener = new MultiScrollListener(); if (originListener != null) { multiScrollListener.addListener(originListener); } multiScrollListener.addListener(listener); listview.setOnScrollListener(multiScrollListener); } }
public static void removeScrollListener(ListView listview, OnScrollListener listener) { if (listview == null || listener == null) { return; } OnScrollListener originListener = getScrollListenerFromListView(listview); if (originListener == listener) { listview.setOnScrollListener(null); } else { if (originListener instanceof MultiScrollListener) { MultiScrollListener multiScrollListener = (MultiScrollListener)originListener; multiScrollListener.removeListener(listener); if (multiScrollListener.isEmpty()) { listview.setOnScrollListener(null); } } } }
private void setScrollViewScrollListener() { if (child instanceof XScrollView) { XScrollView scrollView = (XScrollView) child; scrollView.setOnScrollListener(mParent, new XScrollView.OnScrollListener() { @Override public void onScrollStateChanged(ScrollView view, int scrollState, boolean arriveBottom) { if (scrollState == SCROLL_STATE_IDLE && arriveBottom) { if (mSilenceLoadMore) { if (mRefreshViewListener != null) { mRefreshViewListener.onLoadMore(true); } } else if (mContainer != null && !hasLoadCompleted()) { mContainer.invokeLoadMore(); } } } @Override public void onScroll(int l, int t, int oldl, int oldt) { } }); } else { throw new RuntimeException("please use XScrollView instead of ScrollView!"); } }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case OnScrollListener.SCROLL_STATE_FLING: adapter.lock(); break; case OnScrollListener.SCROLL_STATE_IDLE: adapter.unlock(); break; case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: adapter.lock(); break; default: break; } }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case OnScrollListener.SCROLL_STATE_IDLE: magic.magicEngine.resume(); break; case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: if (pauseOnScroll) { magic.magicEngine.pause(); } break; case OnScrollListener.SCROLL_STATE_FLING: if (pauseOnFling) { magic.magicEngine.pause(); } break; } if (externalListener != null) { externalListener.onScrollStateChanged(view, scrollState); } }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (isScrollLoadEnabled() && hasMoreData()) { if (scrollState == OnScrollListener.SCROLL_STATE_IDLE || scrollState == OnScrollListener.SCROLL_STATE_FLING) { if (isReadyForPullUp()) { startLoading(); } } } if (mListView instanceof SlideListView) ((SlideListView) mListView).onScrollStateChanged(view, scrollState); if (null != mScrollListener) { mScrollListener.onScrollStateChanged(view, scrollState); } }
private String getScrollStateString(int flag) { String str = ""; switch (flag) { case OnScrollListener.SCROLL_STATE_IDLE: str = "SCROLL_STATE_IDLE"; break; case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: str = "SCROLL_STATE_TOUCH_SCROLL"; break; case OnScrollListener.SCROLL_STATE_FLING: str = "SCROLL_STATE_FLING"; break; default: str = "wrong state"; } return str; }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { switch (scrollState) { case OnScrollListener.SCROLL_STATE_IDLE: taskHandler.resume(); break; case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL: if (pauseOnScroll) { taskHandler.pause(); } break; case OnScrollListener.SCROLL_STATE_FLING: if (pauseOnFling) { taskHandler.pause(); } break; } if (externalListener != null) { externalListener.onScrollStateChanged(view, scrollState); } }
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; } }
public final void onScrollStateChanged(final AbsListView view, final int state) { /** * Check that the scrolling has stopped, and that the last item is * visible. */ if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) { mOnLastItemVisibleListener.onLastItemVisible(); } if (null != mOnScrollListener) { mOnScrollListener.onScrollStateChanged(view, state); } }
public final void onScrollStateChanged(final AbsListView view, final int state) { /** * Check that the scrolling has stopped, and that the last item is * visible. */ if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLastItemVisibleListener && mLastItemVisible) { mOnLastItemVisibleListener.onLastItemVisible(); } if (state == OnScrollListener.SCROLL_STATE_IDLE && null != mOnLoadMoreListener) { int lastPosition = getRefreshableView().getLastVisiblePosition(); int total = getRefreshableView().getCount() - 1; if (total - lastPosition < mLoadMoreRemainCount) { mOnLoadMoreListener.onLoadMore(); } } if (null != mOnScrollListener) { mOnScrollListener.onScrollStateChanged(view, state); } }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { if (mScrollListener != null) { mScrollListener.onScrollStateChanged(view, scrollState); } if (scrollState == OnScrollListener.SCROLL_STATE_IDLE) { if (mEnableAutoLoad && getLastVisiblePosition() == getCount() - 1) { startLoadMore(); } } }
public void postSetSelection(final int position) { clearFocus(); post(new Runnable() { @Override public void run() { setSelection(position); } }); onScrollStateChanged(this, OnScrollListener.SCROLL_STATE_IDLE); }
@Override public void run() { mCurrentScrollState = mNewState; if (Log.isLoggable(TAG, Log.DEBUG)) { Log.d(TAG, "new scroll state: " + mNewState + " old state: " + mPreviousScrollState); } // Fix the position after a scroll or a fling ends if (mNewState == OnScrollListener.SCROLL_STATE_IDLE && mPreviousScrollState != OnScrollListener.SCROLL_STATE_IDLE && mPreviousScrollState != OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) { mPreviousScrollState = mNewState; int i = 0; View child = getChildAt(i); while (child != null && child.getBottom() <= 0) { child = getChildAt(++i); } if (child == null) { // The view is no longer visible, just return return; } int firstPosition = getFirstVisiblePosition(); int lastPosition = getLastVisiblePosition(); boolean scroll = firstPosition != 0 && lastPosition != getCount() - 1; final int top = child.getTop(); final int bottom = child.getBottom(); final int midpoint = getHeight() / 2; if (scroll && top < LIST_TOP_OFFSET) { if (bottom > midpoint) { smoothScrollBy(top, GOTO_SCROLL_DURATION); } else { smoothScrollBy(bottom, GOTO_SCROLL_DURATION); } } } else { mPreviousScrollState = mNewState; } }
public PauseOnScrollListener(ImageLoader imageLoader, boolean pauseOnScroll, boolean pauseOnFling, OnScrollListener customListener) { this.imageLoader = imageLoader; this.pauseOnScroll = pauseOnScroll; this.pauseOnFling = pauseOnFling; this.externalListener = customListener; }
public void setOnScrollListener(OnScrollListener listener) { if (listener == this.mOnScrollListener) { super.setOnScrollListener(listener); } else { this.mDelegateOnScrollListener = listener; } }
public void onScrollStateChanged(AbsListView arg0, int arg1) { switch(arg1){ case AbsListView.OnScrollListener.SCROLL_STATE_IDLE://空闲状态 UdeskUtil.imageResume(); break; case AbsListView.OnScrollListener.SCROLL_STATE_FLING://滚动状态 UdeskUtil.imagePause(); break; case AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL://触摸后滚动 break; } }
private void setRecyclerViewScrollListener() { layoutManagerType = null; final RecyclerView recyclerView = (RecyclerView) child; if (recyclerView.getAdapter() == null) { return; } if (!(recyclerView.getAdapter() instanceof BaseRecyclerAdapter)) { // throw new RuntimeException("Recylerview的adapter请继承 BaseRecyclerAdapter"); LogUtils.w(RECYCLERVIEW_ADAPTER_WARIN); return; } final BaseRecyclerAdapter adapter = (BaseRecyclerAdapter) recyclerView.getAdapter(); adapter.insideEnableFooter(mParent.getPullLoadEnable()); recyclerView.removeOnScrollListener(mOnScrollListener); mOnScrollListener = new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (mRecyclerViewScrollListener != null) { mRecyclerViewScrollListener.onScrollStateChanged(recyclerView, newState); } } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { onRecyclerViewScrolled(recyclerView, adapter, dx, dy, false); } }; recyclerView.addOnScrollListener(mOnScrollListener); RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); if (layoutManager != null && layoutManager instanceof GridLayoutManager) { GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager; gridLayoutManager.setSpanSizeLookup(new XSpanSizeLookup(adapter, gridLayoutManager.getSpanCount())); } initFooterCallBack(adapter, mParent); }
@Override public void onScrollStateChanged(AbsListView view, int scrollState) { /******解决abslistview数据不满一屏的时候,会重复加载更多的问题 start ******/ if (mParent.isStopLoadMore() && scrollState == OnScrollListener.SCROLL_STATE_FLING) { isForbidLoadMore = true; } if (isForbidLoadMore) { if (!mParent.isStopLoadMore() && scrollState == OnScrollListener.SCROLL_STATE_IDLE) { isForbidLoadMore = false; } return; } /******解决abslistview数据不满一屏的时候,会重复加载更多的问题 end ******/ if (mSilenceLoadMore) { if (mRefreshViewListener != null && !hasLoadCompleted() && !mIsLoadingMore && mTotalItemCount - 1 <= view.getLastVisiblePosition() + mPreLoadCount) { mRefreshViewListener.onLoadMore(true); mIsLoadingMore = true; } } else if (mContainer != null && !hasLoadCompleted() && scrollState == OnScrollListener.SCROLL_STATE_IDLE) { if (mPreLoadCount == 0) { if (isBottom()) { if (!mIsLoadingMore) { mIsLoadingMore = mContainer.invokeLoadMore(); } } } else { if (mTotalItemCount - 1 <= view.getLastVisiblePosition() + mPreLoadCount) { if (!mIsLoadingMore) { mIsLoadingMore = mContainer.invokeLoadMore(); } } } } if (mAbsListViewScrollListener != null) { mAbsListViewScrollListener.onScrollStateChanged(view, scrollState); } }