title: Weird scrolling behaviour in both ListView and RecyclerView on hiding Action Bar
body: <p>I am getting a very weird behaviour on scrolling the views. Fragment "A" uses the RecyclerView and Fragment "B" uses the listView.</p>
  
  <p>For recycler view, I am using the following code:</p>
  
  <pre><code>list.setOnScrollListener(new RecyclerView.OnScrollListener() {
          int mLastFirstVisibleItem = 0;
  
          @Override
          public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
          }
  
          @Override
          public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
              super.onScrolled(recyclerView, dx, dy);
              final int currentFirstVisibleItem = linearLayoutManager.findFirstVisibleItemPosition();
  
              if (currentFirstVisibleItem &gt; this.mLastFirstVisibleItem) {
                  ((AppCompatActivity)getActivity()).getSupportActionBar().hide();
              } else if (currentFirstVisibleItem &lt; this.mLastFirstVisibleItem) {
                  ((AppCompatActivity)getActivity()).getSupportActionBar().show();
              }
  
              this.mLastFirstVisibleItem = currentFirstVisibleItem;
          }
      });
  </code></pre>
  
  <p>For ListView, I am using the following code:</p>
  
  <pre><code>list.setOnScrollListener(new AbsListView.OnScrollListener() {
          int mLastFirstVisibleItem = 0;
  
          @Override
          public void onScrollStateChanged(AbsListView view, int scrollState) {   }
  
          @Override
          public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
              if (view.getId() == list.getId()) {
                  final int currentFirstVisibleItem = list.getFirstVisiblePosition();
  
                  if (currentFirstVisibleItem &gt; mLastFirstVisibleItem) {
                      // getSherlockActivity().getSupportActionBar().hide();
                      ((AppCompatActivity)getActivity()).getSupportActionBar().hide();
                  } else if (currentFirstVisibleItem &lt; mLastFirstVisibleItem) {
                      // getSherlockActivity().getSupportActionBar().show();
                      ((AppCompatActivity)getActivity()).getSupportActionBar().show();
                  }
  
                  mLastFirstVisibleItem = currentFirstVisibleItem;
              }
          }
      });
  </code></pre>
  
  <p>Following are the GIFs, So, basically, I scroll and hold it right there and don't release my finger and I get the following behaviour.</p>
  
  <p><a href="https://i.stack.imgur.com/tukCs.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tukCs.gif" alt="enter image description here"></a></p>
  
  <p><a href="https://i.stack.imgur.com/sXiBe.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sXiBe.gif" alt="enter image description here"></a></p>