Java Code Examples for android.support.v7.widget.RecyclerView#SCROLL_STATE_SETTLING
The following examples show how to use
android.support.v7.widget.RecyclerView#SCROLL_STATE_SETTLING .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CenterScrollListener.java From CarouselLayoutManager with Apache License 2.0 | 6 votes |
@Override public void onScrollStateChanged(final RecyclerView recyclerView, final int newState) { super.onScrollStateChanged(recyclerView, newState); final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); if (!(layoutManager instanceof CarouselLayoutManager)) { mAutoSet = true; return; } final CarouselLayoutManager lm = (CarouselLayoutManager) layoutManager; if (!mAutoSet) { if (RecyclerView.SCROLL_STATE_IDLE == newState) { final int scrollNeeded = lm.getOffsetCenterView(); if (CarouselLayoutManager.HORIZONTAL == lm.getOrientation()) { recyclerView.smoothScrollBy(scrollNeeded, 0); } else { recyclerView.smoothScrollBy(0, scrollNeeded); } mAutoSet = true; } } if (RecyclerView.SCROLL_STATE_DRAGGING == newState || RecyclerView.SCROLL_STATE_SETTLING == newState) { mAutoSet = false; } }
Example 2
Source File: RecyclerViewPauseOnScrollListener.java From talk-android with MIT License | 6 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); switch (newState) { case RecyclerView.SCROLL_STATE_IDLE: mImageLoader.resume(); break; case RecyclerView.SCROLL_STATE_DRAGGING: if (mPauseOnScroll) { mImageLoader.pause(); } break; case RecyclerView.SCROLL_STATE_SETTLING: if (mPauseOnSettling) { mImageLoader.pause(); } break; } if (mListener != null) { mListener.onScrollStateChanged(recyclerView, newState); } }
Example 3
Source File: VerticalLayoutFragment.java From RecyclerViewPager with Apache License 2.0 | 6 votes |
private void updateState(int scrollState) { String stateName = "Undefined"; switch (scrollState) { case RecyclerView.SCROLL_STATE_IDLE: stateName = "Idle"; break; case RecyclerView.SCROLL_STATE_DRAGGING: stateName = "Dragging"; break; case RecyclerView.SCROLL_STATE_SETTLING: stateName = "Flinging"; break; } mStateText.setText(stateName); }
Example 4
Source File: PauseOnScrollListener.java From ForPDA with GNU General Public License v3.0 | 6 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { switch (newState) { case RecyclerView.SCROLL_STATE_IDLE: imageLoader.resume(); break; case RecyclerView.SCROLL_STATE_DRAGGING: if (pauseOnScroll) { imageLoader.pause(); } break; case RecyclerView.SCROLL_STATE_SETTLING: if (pauseOnSettling) { imageLoader.pause(); } break; } }
Example 5
Source File: RecyclerToListViewScrollListener.java From AndroidBase with Apache License 2.0 | 6 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { int listViewState; switch (newState) { case RecyclerView.SCROLL_STATE_DRAGGING: listViewState = ListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL; break; case RecyclerView.SCROLL_STATE_IDLE: listViewState = ListView.OnScrollListener.SCROLL_STATE_IDLE; break; case RecyclerView.SCROLL_STATE_SETTLING: listViewState = ListView.OnScrollListener.SCROLL_STATE_FLING; break; default: listViewState = UNKNOWN_SCROLL_STATE; } scrollListener.onScrollStateChanged(null /*view*/, listViewState); }
Example 6
Source File: RecyclerToListViewScrollListener.java From FastAndroid with Apache License 2.0 | 6 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { int listViewState; switch (newState) { case RecyclerView.SCROLL_STATE_DRAGGING: listViewState = ListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL; break; case RecyclerView.SCROLL_STATE_IDLE: listViewState = ListView.OnScrollListener.SCROLL_STATE_IDLE; break; case RecyclerView.SCROLL_STATE_SETTLING: listViewState = ListView.OnScrollListener.SCROLL_STATE_FLING; break; default: listViewState = UNKNOWN_SCROLL_STATE; } scrollListener.onScrollStateChanged(null /*view*/, listViewState); }
Example 7
Source File: RecyclerToListViewScrollListener.java From glide-support with The Unlicense | 6 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { int listViewState; switch (newState) { case RecyclerView.SCROLL_STATE_DRAGGING: listViewState = ListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL; break; case RecyclerView.SCROLL_STATE_IDLE: listViewState = ListView.OnScrollListener.SCROLL_STATE_IDLE; break; case RecyclerView.SCROLL_STATE_SETTLING: listViewState = ListView.OnScrollListener.SCROLL_STATE_FLING; break; default: listViewState = UNKNOWN_SCROLL_STATE; } scrollListener.onScrollStateChanged(null /*view*/, listViewState); }
Example 8
Source File: PathLayoutManager.java From PathLayoutManager with Apache License 2.0 | 6 votes |
@Override public void onScrollStateChanged(int state) { isFlinging = state == RecyclerView.SCROLL_STATE_SETTLING; switch (state) { case RecyclerView.SCROLL_STATE_DRAGGING: stopFixingAnimation(); break; case RecyclerView.SCROLL_STATE_IDLE: if (isAutoSelect) { smoothScrollToPosition(findClosestPosition()); } break; default: break; } }
Example 9
Source File: OnRVLoadMoreScrollListener.java From RecyclerViewAdapter with Apache License 2.0 | 6 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); currentScrollState = newState; RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); int visibleItemCount = layoutManager.getChildCount(); int totalItemCount = layoutManager.getItemCount(); if (!recyclerView.canScrollVertically(1) && visibleItemCount > 0 && currentScrollState == RecyclerView.SCROLL_STATE_IDLE && (lastVisibleItemPosition) >= totalItemCount - 1) { rvStartLoadMore(); } if (newState == RecyclerView.SCROLL_STATE_DRAGGING || newState == RecyclerView.SCROLL_STATE_SETTLING) { onGlideShouldPauseRequests(); } else if (newState == RecyclerView.SCROLL_STATE_IDLE) { onGlideShouldResumeRequests(); } }
Example 10
Source File: GravityDelegate.java From Orin with GNU General Public License v3.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_SETTLING) { snapping = false; } if (newState == RecyclerView.SCROLL_STATE_IDLE && snapping && listener != null) { int position = getSnappedPosition(recyclerView); if (position != RecyclerView.NO_POSITION) { listener.onSnap(position); } snapping = false; } }
Example 11
Source File: ScrollListener.java From Expandable-Action-Button with MIT License | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, final int newState) { super.onScrollStateChanged(recyclerView, newState); if (RecyclerView.SCROLL_STATE_IDLE == newState || RecyclerView.SCROLL_STATE_SETTLING == newState) { if (Math.abs(offsetY) >= LIMIT) { if (expandableButton.getState() == ExpandableButtonView.State.FINISHED) { expandableButton.removeBottomToolbar(); expandableButton.setState(State.IDLE); hasStopped = false; } else if (hasStopped && expandableButton.getState() == State.IDLE) { if (expandableButton.getScaleX() > 0f) { expandableButton.setClickable(false); expandableButton.animate().setInterpolator(new AccelerateInterpolator()) .scaleY(0.f).scaleX(0.f).setDuration(FADE_IN_OUT_DURATION).start(); } } if (!hasStopped) { hasStopped = (newState == RecyclerView.SCROLL_STATE_IDLE) || (Math.abs(offsetY) >= 8 * LIMIT); } offsetY = 0; } if (newState == RecyclerView.SCROLL_STATE_IDLE) { if (expandableButton.getScaleX() < 1.f) { expandableButton.setClickable(true); expandableButton.animate().scaleX(1.f).setListener(null). setInterpolator(new DecelerateInterpolator()).scaleY(1.f). setDuration(FADE_IN_OUT_DURATION / 2).start(); } } } }
Example 12
Source File: CenterScrollListener.java From RecyclerBanner with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); final OverFlyingLayoutManager.OnPageChangeListener onPageChangeListener = ((OverFlyingLayoutManager) layoutManager).onPageChangeListener; if (onPageChangeListener != null) { onPageChangeListener.onPageScrollStateChanged(newState); } if (newState == RecyclerView.SCROLL_STATE_IDLE) { if (mAutoSet) { if (onPageChangeListener != null) { onPageChangeListener.onPageSelected(((OverFlyingLayoutManager) layoutManager).getCurrentPosition()); } mAutoSet = false; } else { final int delta; delta = ((OverFlyingLayoutManager) layoutManager).getOffsetToCenter(); if (delta != 0) { if (((OverFlyingLayoutManager) layoutManager).getOrientation() == OverFlyingLayoutManager.VERTICAL) recyclerView.smoothScrollBy(0, delta); else recyclerView.smoothScrollBy(delta, 0); mAutoSet = true; } else { if (onPageChangeListener != null) { onPageChangeListener.onPageSelected(((OverFlyingLayoutManager) layoutManager).getCurrentPosition()); } mAutoSet = false; } } } else if (newState == RecyclerView.SCROLL_STATE_DRAGGING || newState == RecyclerView.SCROLL_STATE_SETTLING) { mAutoSet = false; } }
Example 13
Source File: OnRVScrollListener.java From RecyclerViewAdapter with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_DRAGGING || newState == RecyclerView.SCROLL_STATE_SETTLING) { Glide.with(context).pauseRequests(); } else if (newState == RecyclerView.SCROLL_STATE_IDLE) { Glide.with(context).resumeRequests(); } }
Example 14
Source File: OnCardsScrollListener.java From Puff-Android with MIT License | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState){ int first; switch (newState){ case RecyclerView.SCROLL_STATE_IDLE: // EventBus.getDefault() // .post(new ItemUIEvent(ItemUIEvent.LIST_SCROLLED, recyclerView.getScrollY())); break; case RecyclerView.SCROLL_STATE_DRAGGING: break; case RecyclerView.SCROLL_STATE_SETTLING: break; } }
Example 15
Source File: JazzyRecyclerViewScrollListener.java From JazzyListView with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { switch (newState) { case RecyclerView.SCROLL_STATE_SETTLING: // fall through case RecyclerView.SCROLL_STATE_DRAGGING: mHelper.setScrolling(true); break; case RecyclerView.SCROLL_STATE_IDLE: mHelper.setScrolling(false); break; default: break; } notifyAdditionalOnScrollStateChangedListener(recyclerView, newState); }
Example 16
Source File: SmoothScrollEventHelper.java From Shield with MIT License | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); hasStateChanged = (newState == RecyclerView.SCROLL_STATE_SETTLING); if (newState != RecyclerView.SCROLL_STATE_SETTLING && hasScrollingStopped) { recyclerView.removeOnScrollListener(this); resetSignals(); dispatchStopScrollEvent(); } }
Example 17
Source File: PagerLayoutManager.java From YCRefreshView with Apache License 2.0 | 5 votes |
/** * 滑动状态的改变 * 缓慢拖拽-> SCROLL_STATE_DRAGGING * 快速滚动-> SCROLL_STATE_SETTLING * 空闲状态-> SCROLL_STATE_IDLE * @param state 状态 */ @Override public void onScrollStateChanged(int state) { switch (state) { case RecyclerView.SCROLL_STATE_IDLE: View viewIdle = mPagerSnapHelper.findSnapView(this); int positionIdle = 0; if (viewIdle != null) { positionIdle = getPosition(viewIdle); } int childCount = getChildCount(); if (mOnViewPagerListener != null && childCount == 1) { mOnViewPagerListener.onPageSelected(positionIdle, positionIdle == childCount - 1); } break; case RecyclerView.SCROLL_STATE_DRAGGING: View viewDrag = mPagerSnapHelper.findSnapView(this); if (viewDrag != null) { int positionDrag = getPosition(viewDrag); } break; case RecyclerView.SCROLL_STATE_SETTLING: View viewSettling = mPagerSnapHelper.findSnapView(this); if (viewSettling != null) { int positionSettling = getPosition(viewSettling); } break; default: break; } }
Example 18
Source File: CenterScrollListener.java From CarouselBanner with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); final RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); if (!(layoutManager instanceof CoolBannerLayoutManager)) { mAutoSet = true; return; } final CoolBannerLayoutManager.OnPageChangeListener onPageChangeListener = ((CoolBannerLayoutManager) layoutManager).onPageChangeListener; if (onPageChangeListener != null) { onPageChangeListener.onPageScrollStateChanged(newState); } if (newState == RecyclerView.SCROLL_STATE_IDLE) { if (mAutoSet) { if (onPageChangeListener != null) { onPageChangeListener.onPageSelected(((CoolBannerLayoutManager) layoutManager).getCurrentPosition()); } mAutoSet = false; } else { final int delta; delta = ((CoolBannerLayoutManager) layoutManager).getOffsetToCenter(); if (delta != 0) { if (((CoolBannerLayoutManager) layoutManager).getOrientation() == CoolBannerLayoutManager.VERTICAL) recyclerView.smoothScrollBy(0, delta); else recyclerView.smoothScrollBy(delta, 0); mAutoSet = true; } else { if (onPageChangeListener != null) { onPageChangeListener.onPageSelected(((CoolBannerLayoutManager) layoutManager).getCurrentPosition()); } mAutoSet = false; } } } else if (newState == RecyclerView.SCROLL_STATE_DRAGGING || newState == RecyclerView.SCROLL_STATE_SETTLING) { mAutoSet = false; } }
Example 19
Source File: AbstractPagerLLM.java From MultiView with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(int newState) { if (newState == RecyclerView.SCROLL_STATE_DRAGGING) { isIdle = false; Log.d("onScrollStateChanged DRAGGING"); //reset adjusted gdx = 0; gdy = 0; adjusted = false; //just in case adjustOnScroll = false; prevPos = getCurrentPage(); View currView = findViewByPosition(prevPos); if (currView != null) { vx = currView.getWidth(); vy = currView.getHeight(); } } else if (newState == RecyclerView.SCROLL_STATE_SETTLING) { isIdle = false; Log.d("onScrollStateChanged SETTLING"); adjust(); } else if (newState == RecyclerView.SCROLL_STATE_IDLE) { isIdle = true; Log.d("onScrollStateChanged IDLE"); adjust(); } }
Example 20
Source File: PagerLayoutManager.java From YCScrollPager with Apache License 2.0 | 5 votes |
/** * 滑动状态的改变 * 缓慢拖拽-> SCROLL_STATE_DRAGGING * 快速滚动-> SCROLL_STATE_SETTLING * 空闲状态-> SCROLL_STATE_IDLE * @param state 状态 */ @Override public void onScrollStateChanged(int state) { switch (state) { case RecyclerView.SCROLL_STATE_IDLE: View viewIdle = mPagerSnapHelper.findSnapView(this); int positionIdle = 0; if (viewIdle != null) { positionIdle = getPosition(viewIdle); } int childCount = getChildCount(); if (mOnViewPagerListener != null && childCount == 1) { mOnViewPagerListener.onPageSelected(positionIdle, positionIdle == childCount - 1); } break; case RecyclerView.SCROLL_STATE_DRAGGING: View viewDrag = mPagerSnapHelper.findSnapView(this); if (viewDrag != null) { int positionDrag = getPosition(viewDrag); } break; case RecyclerView.SCROLL_STATE_SETTLING: View viewSettling = mPagerSnapHelper.findSnapView(this); if (viewSettling != null) { int positionSettling = getPosition(viewSettling); } break; default: break; } }