Java Code Examples for android.support.v7.widget.RecyclerView#OnScrollListener
The following examples show how to use
android.support.v7.widget.RecyclerView#OnScrollListener .
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: GankMeiziFragment.java From MoeQuest with Apache License 2.0 | 6 votes |
RecyclerView.OnScrollListener OnLoadMoreListener(StaggeredGridLayoutManager layoutManager) { return new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView rv, int dx, int dy) { boolean isBottom = mLayoutManager.findLastCompletelyVisibleItemPositions( new int[2])[1] >= mAdapter.getItemCount() - PRELOAD_SIZE; if (!mSwipeRefreshLayout.isRefreshing() && isBottom) { if (!mIsLoadMore) { mSwipeRefreshLayout.setRefreshing(true); page++; getGankMeizi(); } else { mIsLoadMore = false; } } } }; }
Example 2
Source File: PostListFragment.java From zhizhihu with Apache License 2.0 | 6 votes |
private RecyclerView.OnScrollListener getScrollToBottomListener(final LinearLayoutManager linearLayoutManager) { return new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { int lastItem = linearLayoutManager.findLastCompletelyVisibleItemPosition(); int count = mPostListAdapter.getItemCount() - 1; boolean isBottom = (lastItem == count); if (!mSwipeRefreshLayout.isRefreshing() && isBottom) { if (!mIsFirstTimeTouchBottom) { Log.e("onScrolled=>", "refresh.... "); mPresenter.loadNextPage(); } else { mIsFirstTimeTouchBottom = false; } } } }; }
Example 3
Source File: RecyclerViewHeader.java From RecyclerViewHeader with Apache License 2.0 | 5 votes |
public final void setOnScrollListener(RecyclerView.OnScrollListener onScrollListener) { clearOnScrollListener(); this.onScrollListener = onScrollListener; recyclerView.addOnScrollListener(this.onScrollListener); }
Example 4
Source File: HarvestRecyclerView.java From RefreshLoadMoreRecyclerView with MIT License | 5 votes |
/** * enable load more * * @param onLoadMoreListener */ private void enableLoadMore(final OnLoadMoreListener onLoadMoreListener) { if (mOnLoadMoreListener != null) recyclerView.removeOnScrollListener(mOnLoadMoreListener); if (adapter != null) adapter.setIsNeedLoadMore(true); final LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager(); mOnLoadMoreListener = new RecyclerView.OnScrollListener() { @Override public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (newState == RecyclerView.SCROLL_STATE_IDLE && mLastVisibleItemPosition + 1 == adapter.getItemCount()) { if (onLoadMoreListener != null) { onLoadMoreListener.onLoadMore(); } if (swipeRefreshLayout.isRefreshing()) swipeRefreshLayout.setRefreshing(false); } } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); mLastVisibleItemPosition = layoutManager.findLastVisibleItemPosition(); } }; recyclerView.addOnScrollListener(mOnLoadMoreListener); }
Example 5
Source File: FloatingActionButton.java From LLApp with Apache License 2.0 | 5 votes |
public void attachToRecyclerView(@NonNull RecyclerView recyclerView, ScrollDirectionListener scrollDirectionlistener, RecyclerView.OnScrollListener onScrollListener) { RecyclerViewScrollDetectorImpl scrollDetector = new RecyclerViewScrollDetectorImpl(); scrollDetector.setScrollDirectionListener(scrollDirectionlistener); scrollDetector.setOnScrollListener(onScrollListener); scrollDetector.setScrollThreshold(mScrollThreshold); recyclerView.setOnScrollListener(scrollDetector); }
Example 6
Source File: ContentRecyclerView.java From ScrollLayout with Apache License 2.0 | 5 votes |
@Override public void onScrollStateChanged(RecyclerView view, int scrollState) { List<RecyclerView.OnScrollListener> listeners = new ArrayList<RecyclerView.OnScrollListener>(scrollListenerList); for (RecyclerView.OnScrollListener listener : listeners) { listener.onScrollStateChanged(view, scrollState); } }
Example 7
Source File: RecyclerWidget.java From relight with Apache License 2.0 | 4 votes |
public RecyclerWidget<V> removeOnScrollListener(@NonNull RecyclerView.OnScrollListener listener) { view.removeOnScrollListener(listener); return self(); }
Example 8
Source File: YCRefreshView.java From YCRefreshView with Apache License 2.0 | 4 votes |
/** * 设置滚动监听 * @param listener OnScrollListener监听器 */ @Deprecated public void setOnScrollListener(RecyclerView.OnScrollListener listener) { mExternalOnScrollListener = listener; }
Example 9
Source File: SearchActivity.java From Nimingban with Apache License 2.0 | 4 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!handlerIntent(getIntent())) { finish(); return; } mNMBClient = NMBApplication.getNMBClient(this); setStatusBarColor(ResourcesUtils.getAttrColor(this, R.attr.colorPrimaryDark)); ToolbarActivityHelper.setContentView(this, R.layout.activity_search); setActionBarUpIndicator(DrawableManager.getDrawable(this, R.drawable.v_arrow_left_dark_x24)); mContentLayout = (ContentLayout) findViewById(R.id.content_layout); EasyRecyclerView recyclerView = mContentLayout.getRecyclerView(); mRecyclerView = recyclerView; mSearchHelper = new SearchHelper(); mSearchHelper.setEmptyString(getString(R.string.not_found)); mContentLayout.setHelper(mSearchHelper); if (Settings.getFastScroller()) { mContentLayout.showFastScroll(); } else { mContentLayout.hideFastScroll(); } mSearchAdapter = new SearchAdapter(); recyclerView.setAdapter(mSearchAdapter); recyclerView.setSelector(Ripple.generateRippleDrawable(this, ResourcesUtils.getAttrBoolean(this, R.attr.dark))); recyclerView.setDrawSelectorOnTop(true); recyclerView.setOnItemClickListener(this); recyclerView.hasFixedSize(); recyclerView.setClipToPadding(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(); } } }; recyclerView.addOnScrollListener(mOnScrollListener); 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); } mSearchHelper.firstRefresh(); Messenger.getInstance().register(Constants.MESSENGER_ID_FAST_SCROLLER, this); }
Example 10
Source File: AbsRecyclerViewAdapter.java From NHentai-android with GNU General Public License v3.0 | 4 votes |
public void addOnScrollListener(RecyclerView.OnScrollListener listener) { mListeners.add(listener); }
Example 11
Source File: BindingConfig.java From Android-MVVMFramework with Apache License 2.0 | 4 votes |
@BindingAdapter({"addOnScrollListener"}) public static void addOnScrollListener(RecyclerView view, RecyclerView.OnScrollListener listener) { if(listener!=null) view.setOnScrollListener(listener); }
Example 12
Source File: FloatingActionsMenu.java From TestChat with Apache License 2.0 | 4 votes |
public void setOnScrollListener(RecyclerView.OnScrollListener onScrollListener) { mOnScrollListener = onScrollListener; }
Example 13
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 14
Source File: RecyclerIView.java From MeiZiNews with MIT License | 4 votes |
/** * RecyclerView监听 * @param listener */ public void addOnScrollListener(RecyclerView.OnScrollListener listener) { recycler_list.addOnScrollListener(listener); }
Example 15
Source File: XRecyclerView.java From LazyRecyclerAdapter with MIT License | 4 votes |
/** * 滚动监听 */ public void setAddOnScrollListener(RecyclerView.OnScrollListener onScrollListener) { this.onScrollListener = onScrollListener; }
Example 16
Source File: EndlessAdapter.java From SteamGifts with MIT License | 2 votes |
/** * Get the scroll listener associated with this adapter. * * @return scroll listener to bind the view to */ public RecyclerView.OnScrollListener getScrollListener() { return scrollListener; }
Example 17
Source File: AbsRecyclerViewAdapter.java From MoeQuest with Apache License 2.0 | 2 votes |
public void addOnScrollListener(RecyclerView.OnScrollListener listener) { mListeners.add(listener); }
Example 18
Source File: EasyRecyclerView.java From fangzhuishushenqi with Apache License 2.0 | 2 votes |
/** * Set the scroll listener for the recycler * * @param listener */ public void setOnScrollListener(RecyclerView.OnScrollListener listener) { mExternalOnScrollListener = listener; }
Example 19
Source File: EasyRecyclerView.java From BookReader with Apache License 2.0 | 2 votes |
/** * Set the scroll listener for the recycler * * @param listener */ public void setOnScrollListener(RecyclerView.OnScrollListener listener) { mExternalOnScrollListener = listener; }
Example 20
Source File: RecyclerViewPageContainerInterface.java From Shield with MIT License | votes |
void addScrollListener(RecyclerView.OnScrollListener onScrollListener);