Java Code Examples for android.support.v7.widget.RecyclerView#SCROLL_STATE_IDLE
The following examples show how to use
android.support.v7.widget.RecyclerView#SCROLL_STATE_IDLE .
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: OnRcvScrollListener.java From CommonAdapter with Apache License 2.0 | 6 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); int visibleItemCount = layoutManager.getChildCount(); int totalItemCount = layoutManager.getItemCount(); int bottomCount = totalItemCount - 1 - mOffset; if (bottomCount < 0) { bottomCount = totalItemCount - 1; } if (visibleItemCount > 0 && newState == RecyclerView.SCROLL_STATE_IDLE && mLastVisibleItemPosition >= bottomCount && !mIsScrollDown) { onBottom(); } }
Example 2
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 3
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 4
Source File: BasePageIndicator.java From GridPagerSnapHelper with Apache License 2.0 | 6 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); onPageScrollStateChanged(newState); if (newState == RecyclerView.SCROLL_STATE_IDLE) { RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager(); int position = 0; if (layoutManager instanceof GridLayoutManager) { GridLayoutManager gridLayoutManager = (GridLayoutManager) layoutManager; position = gridLayoutManager.findFirstVisibleItemPosition(); int row = gridLayoutManager.getSpanCount(); position = position / (row * mPageColumn); } else if (layoutManager instanceof LinearLayoutManager) { LinearLayoutManager linearLayoutManager = (LinearLayoutManager) layoutManager; position = linearLayoutManager.findFirstVisibleItemPosition(); } onPageSelected(position); } }
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: NavigationFragment.java From Awesome-WanAndroid with Apache License 2.0 | 5 votes |
/** * Right recyclerView linkage left tabLayout * SCROLL_STATE_IDLE just call once * * @param newState RecyclerView new scroll state */ private void rightLinkageLeft(int newState) { if (newState == RecyclerView.SCROLL_STATE_IDLE) { if (isClickTab) { isClickTab = false; return; } int firstPosition = mManager.findFirstVisibleItemPosition(); if (index != firstPosition) { index = firstPosition; setChecked(index); } } }
Example 7
Source File: SwipeItemTouchListener.java From Tangram-Android with MIT License | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (RecyclerView.SCROLL_STATE_IDLE == newState && recyclerView != null && lastMotionEvent != null) { updateCurrCard(); } }
Example 8
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 9
Source File: WMXZFragment.java From Girls with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_IDLE && lastVisibleItem + 1 == mAdapter.getItemCount() ) { mCurrentPage++; mPersenter.startGetImageList(mType, mCurrentPage); } }
Example 10
Source File: MyRecyclerView.java From IdeaTrackerPlus with MIT License | 5 votes |
@Override public void onScrollStateChanged(int state) { int tab = mAdapter.getTabNumber(); switch (tab) { case 1: //Tab NOW stateChangedIdea(state); break; case 2: //Tab LATER stateChangedOther(state); break; case 3: //Tab DONE stateChangedOther(state); break; case 4: //Tab SEARCH //Notify search tab if necessary if (state == RecyclerView.SCROLL_STATE_IDLE && needSearchNotify) { SearchListAdapter.getInstance(getContext(), false).notifyDataSetChanged(); needSearchNotify = false; return; } stateChangedSearch(state); } }
Example 11
Source File: RecyclerViewHandler.java From CommonPullToRefresh with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(android.support.v7.widget.RecyclerView recyclerView, int newState) { if (newState == RecyclerView.SCROLL_STATE_IDLE && isScollBottom(recyclerView)) { if (onScrollBottomListener != null) { onScrollBottomListener.onScorllBootom(); } } }
Example 12
Source File: MultiImagePickerFragment.java From YImagePicker with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_IDLE) { if (mTvTime.getVisibility() == View.VISIBLE) { mTvTime.setVisibility(View.GONE); mTvTime.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.picker_fade_out)); } } else { if (mTvTime.getVisibility() == View.GONE) { mTvTime.setVisibility(View.VISIBLE); mTvTime.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.picker_fade_in)); } } }
Example 13
Source File: TvRecyclerView.java From TvRecyclerView with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(int state) { super.onScrollStateChanged(state); //用来微调位置 if (RecyclerView.SCROLL_STATE_IDLE == state) { mOffset = -1; boolean result = mOnItemListener.onReviseFocusFollow(this, getFocusedChild(), getChildLayoutPosition(getFocusedChild())); if (!result) { mRecyclerViewEffect.setFocusView(getFocusedChild(), mScale); System.out.println("onScrollStateChanged"); } } }
Example 14
Source File: LoadMoreRecycleView.java From BlockExplorer with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(int state) { super.onScrollStateChanged(state); if (!mIsLoadingMore && mOnLoadMoreListener != null && state == RecyclerView.SCROLL_STATE_IDLE && mAdapter != null && lastVisibleItem + 1 == mAdapter.getItemCount()) { mIsLoadingMore = true; mOnLoadMoreListener.loadMore(); } }
Example 15
Source File: LoadMoreScrollerListener.java From CoordinatorLayoutExample with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState != RecyclerView.SCROLL_STATE_IDLE) return; // LUtils.w("down:" + mDown); if (mDown && mLoadingListener != null && isLastItem(recyclerView.getLayoutManager())) { mLoadingListener.onLoadMore(); // Log.w("LoadMoreScrollerListener", "onScrollStateChanged:"); } }
Example 16
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 17
Source File: NewFragment.java From Girls with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_IDLE && lastVisibleItem + 1 == mAdapter.getItemCount() ) { mCurrentPage++; mPersenter.startGetImageList(mType, mCurrentPage); } }
Example 18
Source File: EBookListFragment.java From MaterialHome with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { super.onScrollStateChanged(recyclerView, newState); if (newState == RecyclerView.SCROLL_STATE_IDLE && lastVisibleItem + 1 == mListAdapter.getItemCount()) { onLoadMore(); } }
Example 19
Source File: FooterLoadMoreAdapterWrapper.java From NoListAdapter with Apache License 2.0 | 4 votes |
public boolean isReachBottom(RecyclerView recyclerView, int newState) { return recyclerView != null && newState == RecyclerView.SCROLL_STATE_IDLE && ((LinearLayoutManager) recyclerView.getLayoutManager()).findLastCompletelyVisibleItemPosition() == recyclerView.getAdapter().getItemCount() - 1; }
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); }