title: Detect animation finish in Android's RecyclerView
body: <p>The <code>RecyclerView</code>, unlike to <code>ListView</code>, doesn't have a simple way to set an empty view to it, so one has to manage it manually, making empty view visible in case of adapter's item count is 0.</p>
  
  <p>Implementing this, at first I tried to call empty view logic right after modifying underlaying structure (<code>ArrayList</code> in my case), for example:</p>
  
  <pre><code>btnRemoveFirst.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
          devices.remove(0); // remove item from ArrayList
          adapter.notifyItemRemoved(0); // notify RecyclerView's adapter
          updateEmptyView();
      }
  });
  </code></pre>
  
  <p>It does the thing, but has a drawback: when the last element is being removed, empty view <strong>appears before animation</strong> of removing is finished, immediately after removal. So I decided to wait until end of animation and then update UI.</p>
  
  <p>To my surprise, I couldn't find a good way to listen for animation events in RecyclerView. First thing coming to mind is to use <code>isRunning</code> method like this:</p>
  
  <pre><code>btnRemoveFirst.setOnClickListener(new View.OnClickListener() {
      @Override
      public void onClick(View view) {
          devices.remove(0); // remove item from ArrayList
          adapter.notifyItemRemoved(0); // notify RecyclerView's adapter
          recyclerView.getItemAnimator().isRunning(new RecyclerView.ItemAnimator.ItemAnimatorFinishedListener() {
              @Override
              public void onAnimationsFinished() {
                  updateEmptyView();
              }
          });
      }
  });
  </code></pre>
  
  <p>Unfortunately, callback in this case runs immediately, because at that moment inner <code>ItemAnimator</code> still isn't in the "running" state. So, the questions are: <strong>how to properly use ItemAnimator.isRunning() method</strong> and is there a better way to achieve the desired result, i.e. <strong>show empty view after removal animation of the single element is finished</strong>?</p>