Java Code Examples for android.support.v7.widget.RecyclerView#canScrollVertically()

The following examples show how to use android.support.v7.widget.RecyclerView#canScrollVertically() . 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: OnRVLoadMoreScrollListener.java    From RecyclerViewAdapter with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: ImportFragment.java    From apkextractor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);
    if(adapter==null)return;
    boolean isMultiSelectMode=adapter.getIsMultiSelectMode();
    if (!recyclerView.canScrollVertically(-1)) {
        // onScrolledToTop();
    } else if (!recyclerView.canScrollVertically(1)) {
        // onScrolledToBottom();
        if(isMultiSelectMode){
            if(isScrollable&&card_multi_select.getVisibility()!= View.GONE)
                setViewVisibilityWithAnimation(card_multi_select,View.GONE);
        }
    } else if (dy < 0) {
        // onScrolledUp();
        if(isMultiSelectMode){
            if(isScrollable&&card_multi_select.getVisibility()!=View.VISIBLE){
                setViewVisibilityWithAnimation(card_multi_select,View.VISIBLE);
            }
        }
    } else if (dy > 0) {
        // onScrolledDown();
        isScrollable=true;
        if(isMultiSelectMode){
            if(card_multi_select.getVisibility()!= View.GONE)
                setViewVisibilityWithAnimation(card_multi_select,View.GONE);
        }
    }
}
 
Example 3
Source File: AppFragment.java    From apkextractor with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);
    if(getActivity()==null)return;
    if(adapter==null)return;
    if(card_normal==null||card_multi_select==null)return;
    boolean isMultiSelectMode=adapter.getIsMultiSelectMode();
    if (!recyclerView.canScrollVertically(-1)) {
        // onScrolledToTop();
    } else if (!recyclerView.canScrollVertically(1)) {
        // onScrolledToBottom();
        if(isMultiSelectMode){
            if(isScrollable&&card_multi_select.getVisibility()!= View.GONE)
                setViewVisibilityWithAnimation(card_multi_select,View.GONE);
        }else if(isScrollable&&card_normal.getVisibility()!=View.GONE&&!isSearchMode)
            setViewVisibilityWithAnimation(card_normal,View.GONE);
    } else if (dy < 0) {
        // onScrolledUp();
        if(isMultiSelectMode){
            if(isScrollable&&card_multi_select.getVisibility()!=View.VISIBLE)
                setViewVisibilityWithAnimation(card_multi_select,View.VISIBLE);
        }else if(isScrollable&&card_normal.getVisibility()!=View.VISIBLE&&!isSearchMode)
            setViewVisibilityWithAnimation(card_normal,View.VISIBLE);
    } else if (dy > 0) {
        // onScrolledDown();
        isScrollable=true;
        if(isMultiSelectMode){
            if(card_multi_select.getVisibility()!= View.GONE)
                setViewVisibilityWithAnimation(card_multi_select,View.GONE);
        }else if(card_normal.getVisibility()!=View.GONE&&!isSearchMode)
            setViewVisibilityWithAnimation(card_normal,View.GONE);
    }
}
 
Example 4
Source File: BaseContentView.java    From AndroidUtilCode with Apache License 2.0 5 votes vote down vote up
private void attachRefresh(RecyclerView rv) {
    rv.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
            super.onScrollStateChanged(recyclerView, newState);
            mRefreshEnabled = newState == RecyclerView.SCROLL_STATE_IDLE && !recyclerView.canScrollVertically(-1);
            mFloatView.setRefreshEnabled(mRefreshEnabled);
        }
    });
    mRefreshEnabled = !rv.canScrollVertically(-1);
    mFloatView.setRefreshEnabled(mRefreshEnabled);
}