title: Android - Get current position from recyclerview with listener when position changed
body: <p>I'm working with recyclerview with snaphelper.
  this is my recyclerview:</p>
  
  <pre><code>    final LinearLayoutManager lm = new LinearLayoutManager(getContext(), 
      LinearLayoutManager.HORIZONTAL, false);
  
      recyclerview.setLayoutManager(lm);
  
      final PagerSnapHelper snapHelper = new PagerSnapHelper();
      snapHelper.attachToRecyclerView(recyclerview);
  </code></pre>
  
  <p>when user scroll to another cell i need to do something with the new cell position.</p>
  
  <p>this is what i do to get the position:</p>
  
  <pre><code>        recyclerview.addOnScrollListener(new RecyclerView.OnScrollListener() {
          @Override
          public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
              if (newState != RecyclerView.SCROLL_STATE_IDLE) {
                  return;
              }
              if recyclerview == null) {
                  return;
              }
               //recyclerview.clearOnChildAttachStateChangeListeners();
              int firstVisible = ((LinearLayoutManager) viewerRv.getLayoutManager()).findFirstCompletelyVisibleItemPosition();
              if (firstVisible == RecyclerView.NO_POSITION) {
                  return;
              }
  
            doSomething(firstVisible);
         }
  </code></pre>
  
  <p>the problem is the firstVisible var not always give me the right position for example when i scroll from position 0 to 9 this can be the output:
  0,1,2,3,4,4,5,9</p>
  
  <p>there is another way to get the right current position?</p>
  
  <p>what are the best practices for that?</p>