Java Code Examples for android.support.v7.widget.RecyclerView#SCROLL_STATE_DRAGGING
The following examples show how to use
android.support.v7.widget.RecyclerView#SCROLL_STATE_DRAGGING .
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: FocusLayoutManager.java From FocusLayoutManager with Apache License 2.0 | 6 votes |
@Override public void onScrollStateChanged(int state) { super.onScrollStateChanged(state); switch (state) { case RecyclerView.SCROLL_STATE_DRAGGING: //当手指按下时,停止当前正在播放的动画 cancelAnimator(); break; case RecyclerView.SCROLL_STATE_IDLE: //当列表滚动停止后,判断一下自动选中是否打开 if (isAutoSelect) { //找到离目标落点最近的item索引 smoothScrollToPosition(findShouldSelectPosition()); } break; default: break; } }
Example 2
Source File: FastScroller.java From APlayer with GNU General Public License v3.0 | 6 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (isEnabled()) { switch (newState) { case RecyclerView.SCROLL_STATE_DRAGGING: getHandler().removeCallbacks(mScrollbarHider); cancelAnimation(mScrollbarAnimator); if (!isViewVisible(mScrollbar)) { showScrollbar(); } break; case RecyclerView.SCROLL_STATE_IDLE: if (mHideScrollbar && !mHandleView.isSelected()) { getHandler().postDelayed(mScrollbarHider, sScrollbarHideDelay); } break; } } }
Example 3
Source File: AbstractSnapperLLM.java From MultiView with Apache License 2.0 | 6 votes |
@Override public void onScrollStateChanged(int newState) { if (newState == RecyclerView.SCROLL_STATE_DRAGGING) { Log.d("onScrollStateChanged DRAGGING"); //reset adjusted adjusted = false; prevPos = lastPos; // prevPos = getCenterItemPosition(); } else if (newState == RecyclerView.SCROLL_STATE_SETTLING) { Log.d("onScrollStateChanged SETTLING"); } else if (newState == RecyclerView.SCROLL_STATE_IDLE) { Log.d("onScrollStateChanged IDLE"); //check if we still need to settle if (!adjusted) { adjust(); } } }
Example 4
Source File: PageDetectorSupport.java From Tangram-Android with MIT License | 6 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (!disable) { if (newState == RecyclerView.SCROLL_STATE_DRAGGING) { if (isAutoDetectIdle) { ((Application) recyclerView.getContext().getApplicationContext()) .registerActivityLifecycleCallbacks(mLifecycleCallbacks); startDetectPage(); } isDetectingFastScroll = true; disable = true; } } if (newState == RecyclerView.SCROLL_STATE_IDLE) { onScrollStateIdle(); } }
Example 5
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 6
Source File: HorizontalSnapHelper.java From Horizontal-Calendar with Apache License 2.0 | 6 votes |
@Override public View findSnapView(RecyclerView.LayoutManager layoutManager) { View snapView = super.findSnapView(layoutManager); if (calendarView.getScrollState() != RecyclerView.SCROLL_STATE_DRAGGING){ int selectedItemPosition; if (snapView == null){ // no snapping required selectedItemPosition = horizontalCalendar.getSelectedDatePosition(); } else { int[] snapDistance = calculateDistanceToFinalSnap(layoutManager, snapView); if ((snapDistance[0] != 0) || (snapDistance[1] != 0)){ return snapView; } selectedItemPosition = layoutManager.getPosition(snapView); } notifyCalendarListener(selectedItemPosition); } return snapView; }
Example 7
Source File: DiscreteScrollLayoutManager.java From XPlayer2 with Apache License 2.0 | 6 votes |
@Override public void onScrollStateChanged(int state) { if (currentScrollState == RecyclerView.SCROLL_STATE_IDLE && currentScrollState != state) { scrollStateListener.onScrollStart(); } if (state == RecyclerView.SCROLL_STATE_IDLE) { //Scroll is not finished until current view is centered boolean isScrollEnded = onScrollEnd(); if (isScrollEnded) { scrollStateListener.onScrollEnd(); } else { //Scroll continues and we don't want to set currentScrollState to STATE_IDLE, //because this will then trigger .scrollStateListener.onScrollStart() return; } } else if (state == RecyclerView.SCROLL_STATE_DRAGGING) { onDragStart(); } currentScrollState = state; }
Example 8
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 9
Source File: ScrollManager.java From Mover with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); switch (newState){ case RecyclerView.SCROLL_STATE_DRAGGING: mPicasso.pauseTag(WatchMeApplication.PICASSO_INSTANCE); break; case RecyclerView.SCROLL_STATE_IDLE: mPicasso.resumeTag(WatchMeApplication.PICASSO_INSTANCE); break; } }
Example 10
Source File: VegaLayoutManager.java From GankGirl with GNU Lesser General Public License v2.1 | 5 votes |
@Override public void onScrollStateChanged(int state) { if (state == RecyclerView.SCROLL_STATE_DRAGGING) { needSnap = true; } super.onScrollStateChanged(state); }
Example 11
Source File: CommentPage.java From Slide with GNU General Public License v3.0 | 5 votes |
public void resetScroll(boolean override) { if (toolbarScroll == null) { toolbarScroll = new ToolbarScrollHideHandler(toolbar, v.findViewById(R.id.header), v.findViewById(R.id.progress), SettingValues.commentAutoHide ? v.findViewById(R.id.commentnav) : null) { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); if (SettingValues.fabComments) { if (recyclerView.getScrollState() == RecyclerView.SCROLL_STATE_DRAGGING && !overrideFab) { diff += dy; } else if (!overrideFab) { diff = 0; } if (fab != null && !overrideFab) { if (dy <= 0 && fab.getId() != 0) { if (recyclerView.getScrollState() != RecyclerView.SCROLL_STATE_DRAGGING || diff < -fab.getHeight() * 2) { fab.show(); } } else { fab.hide(); } } } } }; rv.addOnScrollListener(toolbarScroll); } else { toolbarScroll.reset = true; } }
Example 12
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 13
Source File: SuggestionsMetrics.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (mFired) return; if (newState != RecyclerView.SCROLL_STATE_DRAGGING) return; RecordUserAction.record("Suggestions.ScrolledAfterOpen"); mFired = true; }
Example 14
Source File: PagerLayoutManager.java From DouYinWu with MIT License | 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: Log.e("=====", "滑动监听"); View viewIdle = mPagerSnapHelper.findSnapView(this); if (viewIdle != null) { int positionIdle = getPosition(viewIdle); if (mOnViewPagerListener != null && getChildCount() == 1) { mOnViewPagerListener.onPageSelected(positionIdle, positionIdle == getItemCount() - 1, viewIdle); } } break; case RecyclerView.SCROLL_STATE_DRAGGING: Log.e("=====", "滑动监听111"); View viewDrag = mPagerSnapHelper.findSnapView(this); if (viewDrag != null) { int positionDrag = getPosition(viewDrag); } break; case RecyclerView.SCROLL_STATE_SETTLING: Log.e("=====", "滑动监听222"); View viewSettling = mPagerSnapHelper.findSnapView(this); if (viewSettling != null) { int positionSettling = getPosition(viewSettling); } break; } }
Example 15
Source File: RecyclerViewScrollBehavior.java From mvp-helpers with MIT License | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { switch (newState) { case RecyclerView.SCROLL_STATE_SETTLING: case RecyclerView.SCROLL_STATE_DRAGGING: fab.hide(); break; case RecyclerView.SCROLL_STATE_IDLE: default: fab.show(); break; } super.onScrollStateChanged(recyclerView, newState); }
Example 16
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 17
Source File: OverScrollImpl.java From PullRefreshLoadRecyclerView with MIT License | 4 votes |
public void setLockOverScrollTop(int topDistance) { overScrollTopDistanceLock = topDistance; if (recyclerView.getScrollState() != RecyclerView.SCROLL_STATE_DRAGGING) { resetOverScroll(); } }
Example 18
Source File: PostFragment.java From Nimingban with Apache License 2.0 | 4 votes |
@Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup view = (ViewGroup) inflater.inflate(R.layout.activity_toolbar, container, false); ViewGroup contentPanel = (ViewGroup) view.findViewById(R.id.content_panel); ViewGroup contentView = (ViewGroup) inflater.inflate(R.layout.fragment_post, contentPanel, true); mToolbar = (Toolbar) view.findViewById(R.id.toolbar); // I like hardcode mToolbar.setSubtitle("A岛·adnmb.com"); if (mId != null) { mToolbar.setTitle(mSite.getPostTitle(getContext(), mId)); } else { mToolbar.setTitle(getString(R.string.thread)); } mToolbar.setNavigationIcon(DrawableManager.getDrawable(getContext(), R.drawable.v_arrow_left_dark_x24)); mToolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { getFragmentHost().finishFragment(PostFragment.this); } }); mToolbar.inflateMenu(R.menu.activity_post); mToolbar.setOnMenuItemClickListener(this); mContentLayout = (ContentLayout) contentView.findViewById(R.id.content_layout); mRecyclerView = mContentLayout.getRecyclerView(); mReplyHelper = new ReplyHelper(); mReplyHelper.setEmptyString(getString(R.string.not_found)); mContentLayout.setHelper(mReplyHelper); if (Settings.getFastScroller()) { mContentLayout.showFastScroll(); } else { mContentLayout.hideFastScroll(); } mReplyAdapter = new ReplyAdapter(); mRecyclerView.setAdapter(mReplyAdapter); mRecyclerView.setSelector(Ripple.generateRippleDrawable( getContext(), ResourcesUtils.getAttrBoolean(getContext(), R.attr.dark))); mRecyclerView.setLayoutManager(new LinearLayoutManager(getContext())); mRecyclerView.setOnItemClickListener(this); mRecyclerView.setOnItemLongClickListener(this); mRecyclerView.hasFixedSize(); mOnScrollListener = new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (RecyclerView.SCROLL_STATE_DRAGGING == newState) { pauseHolders(); } else if (RecyclerView.SCROLL_STATE_IDLE == newState) { resumeHolders(); } } }; mRecyclerView.addOnScrollListener(mOnScrollListener); mOpColor = getResources().getColor(R.color.colorAccent); // Refresh mReplyHelper.firstRefresh(); Messenger.getInstance().register(Constants.MESSENGER_ID_REPLY, this); Messenger.getInstance().register(Constants.MESSENGER_ID_FAST_SCROLLER, this); isLoaded = false; return view; }
Example 19
Source File: HTBaseRecyclerView.java From ht-refreshrecyclerview with MIT License | 4 votes |
/** * 禁止刷新的时候滑动列表 * 避免 RecyclerView Bug:IndexOutOfBoundsException: Inconsistency detected. Invalid item position */ /* private void setRecyclerViewOnTouchListener() { mRecyclerView.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return !mEnableScrollOnReFresh && mRefreshStatus == RefreshStatus.REFRESHING; } } ); }*/ private void setRecyclerViewOnScrollListener() { mInnerScrollListener = new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (newState == RecyclerView.SCROLL_STATE_IDLE && shouldHandleLoadMore()) { performLoadMore();//停止滚动后触发加载更多 } if (newState == RecyclerView.SCROLL_STATE_DRAGGING) { if (mRecyclerViewDragListener != null) { mRecyclerViewDragListener.onRecyclerViewScroll(); } } for (int i = mScrollListeners.size() - 1; i >= 0; i--) { OnScrollListener scrollListener = mScrollListeners.get(i); if (scrollListener != null) { scrollListener.onScrollStateChanged(recyclerView, newState); } } } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); for (int i = mScrollListeners.size() - 1; i >= 0; i--) { OnScrollListener scrollListener = mScrollListeners.get(i); if (scrollListener != null) { scrollListener.onScrolled(recyclerView, dx, dy); } } } }; mRecyclerView.addOnScrollListener(mInnerScrollListener); }
Example 20
Source File: FeedActivity.java From Nimingban with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mNMBClient = NMBApplication.getNMBClient(this); setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark)); ToolbarActivityHelper.setContentView(this, R.layout.activity_feed); setActionBarUpIndicator(DrawableManager.getDrawable(this, R.drawable.v_arrow_left_dark_x24)); mContentLayout = (ContentLayout) findViewById(R.id.content_layout); mRecyclerView = mContentLayout.getRecyclerView(); mFeedHelper = new FeedHelper(); mFeedHelper.setEmptyString(getString(R.string.no_feed)); mContentLayout.setHelper(mFeedHelper); if (Settings.getFastScroller()) { mContentLayout.showFastScroll(); } else { mContentLayout.hideFastScroll(); } // Layout Manager int interval = getResources().getDimensionPixelOffset(R.dimen.card_interval); if (getResources().getBoolean(R.bool.two_way)) { mRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)); MarginItemDecoration decoration = new MarginItemDecoration(interval, interval, interval, interval, interval); mRecyclerView.addItemDecoration(decoration); decoration.applyPaddings(mRecyclerView); mRecyclerView.setItemAnimator(new SlideInUpAnimator()); } else { int halfInterval = interval / 2; mRecyclerView.addItemDecoration(new RawMarginItemDecoration(0, halfInterval, 0, halfInterval)); mRecyclerView.setLayoutManager(new LinearLayoutManager(this)); mRecyclerView.setPadding(0, halfInterval, 0, halfInterval); } // touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running) mRecyclerViewTouchActionGuardManager = new RecyclerViewTouchActionGuardManager(); mRecyclerViewTouchActionGuardManager.setInterceptVerticalScrollingWhileAnimationRunning(true); mRecyclerViewTouchActionGuardManager.setEnabled(true); // swipe manager mRecyclerViewSwipeManager = new RecyclerViewSwipeManager(); mAdapter = new FeedAdapter(); mAdapter.setHasStableIds(true); mWrappedAdapter = mRecyclerViewSwipeManager.createWrappedAdapter(mAdapter); // wrap for swiping final GeneralItemAnimator animator = new SwipeDismissItemAnimator(); // Change animations are enabled by default since support-v7-recyclerview v22. // Disable the change animation in order to make turning back animation of swiped item works properly. animator.setSupportsChangeAnimations(false); mRecyclerView.hasFixedSize(); mRecyclerView.setAdapter(mWrappedAdapter); // requires *wrapped* adapter mRecyclerView.setItemAnimator(animator); mRecyclerView.setOnItemClickListener(this); mRecyclerView.setSelector(Ripple.generateRippleDrawable(this, ResourcesUtils.getAttrBoolean(this, R.attr.dark))); mRecyclerView.setDrawSelectorOnTop(true); mRecyclerView.setClipToPadding(false); mRecyclerView.setClipChildren(false); mOnScrollListener = new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (RecyclerView.SCROLL_STATE_DRAGGING == newState) { pauseHolders(); } else if (RecyclerView.SCROLL_STATE_IDLE == newState) { resumeHolders(); } } }; mRecyclerView.addOnScrollListener(mOnScrollListener); // NOTE: // The initialization order is very important! This order determines the priority of touch event handling. // // priority: TouchActionGuard > Swipe > DragAndDrop mRecyclerViewTouchActionGuardManager.attachRecyclerView(mRecyclerView); mRecyclerViewSwipeManager.attachRecyclerView(mRecyclerView); mFeedHelper.firstRefresh(); Messenger.getInstance().register(Constants.MESSENGER_ID_FAST_SCROLLER, this); }