title: CoordinatorLayout with RecyclerView: onScroll
body: <p>I have a RecyclerView where I have added different actions that can be performed on the list items. Particularly, <code>DragDrop</code> and <code>SwipeDismiss</code>. <code>DragDrop</code> is initiated by long-press, and <code>SwipeDismiss</code> is initiated by swiping. I have to watch for scroll events to block those actions from happening. It is annoying to be scrolling then it suddenly switched to dragging. Before I would add an <code>OnScrollListener</code> to handle this. </p>
  
  <p><strong>This is what I did before:</strong></p>
  
  <pre><code>@Override
  public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
      super.onScrollStateChanged(recyclerView, newState);
      if(newState == RecyclerView.SCROLL_STATE_IDLE){
          drag.setCurrentAction(IDLE);
      } else {
          drag.setCurrentAction(SCROLL);
      }
  }
  </code></pre>
  
  <hr>
  
  <p><strong>No longer will work</strong></p>
  
  <p>I recently added <a href="http://android-developers.blogspot.com/2015/05/android-design-support-library.html" rel="noreferrer">CoordinatorLayout for collapsable toolbars</a>. Now when scrolling up, <code>drag</code> wont get set to <code>SCROLL</code> until the toolbar has been collapsed. I tried to create my own behavior, but that would replace my current behavior I am using; <code>@string/appbar_scrolling_view_behavior</code>. This removed the behaviors I wanted for the toolbar and didn't work to notify my <code>drag</code> state.</p>
  
  <hr>
  
  <p><strong>What I have tried:</strong></p>
  
  <pre><code>@Override
  public boolean onStartNestedScroll(CoordinatorLayout cl, CollapsingToolbarLayout child, View directTargetChild,
          View target, int nestedScrollAxes) {
  
      if (nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL) {
          if (drag.getCurrentAction().ordinal() &lt; SCROLL.ordinal()) {
              /* No actions have started and we are scrolling. set the new action */
              drag.setCurrentAction(SCROLL);
          }
          return true;
      }
      return super.onStartNestedScroll(cl, child, directTargetChild, target, nestedScrollAxes);
  }
  
  @Override
  public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, CollapsingToolbarLayout child, View target) {
      super.onStopNestedScroll(coordinatorLayout, child, target);
      if (drag.getCurrentAction() == SCROLL) {
          drag.setCurrentAction(INVALID);
      }
  }
  </code></pre>
  
  <p><strong>So my question</strong></p>
  
  <p>How do I listen for those scroll changes on my recycler view that are being intercepted by the <code>CoordinatorLayout</code>? Is a Behavior the correct way? </p>