title: Playing and Releasing audio in RecyclerView
body: <p>I'm learning android and currently RecyclerView, so in this example I'm playing a specific raw sound file when clicking a play button and then releasing it when it's done. 
  I could seriously use some pointers on what is the best practice however as I have a few issues and questions:</p>
  
  <ul>
  <li>I have a problem with transiting states so if I press play very quickly I'll get an <em>IllegalStateException</em>, probably from trying to release an already released player.</li>
  <li>I should apparently also nullify after release and do a <em>null</em> check prior but since I'm using it in a nested scope it has to be declared final and can't be nulled which is confusing, I've obviously missed something.</li>
  <li>setting the clickListner on an item in <em>onBindViewHolder</em> also seems significantly slower and less responsive than adding a clickListner on the entire row in the <em>viewHolder</em> class.</li>
  </ul>
  
  <p><strong>What is the best practice for setting up your mediaPlayer and managing your resources correctly with RecyclerView and what am I doing wrong that would cause crashes and "slowness"?</strong></p>
  
  <p>//ViewHolder</p>
  
  <pre><code>public static class myHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
  
  
      ImageView playBtn;
  
      public myHolder(View v){
          super(v);
          playBtn = (ImageView) v.findViewById(R.id.playBtn);
          v.setOnClickListener(this);
      }
  
      @Override
      public void onClick(View v) {
      }
  
  }
  </code></pre>
  
  <p>//onBindViewHolder / onCompletionListener</p>
  
  <pre><code>  @Override
  public void onBindViewHolder(myHolder holder, int position) {
      myClass item = itemList.get(position);
      final MediaPlayer mediaPlayer = MediaPlayer.create(holder.itemView.getContext(), item.getAudioSource());
  
     holder.playBtn.setOnClickListener(new View.OnClickListener(){
          @Override
          public void onClick(View v) {
  
              mediaPlayer.start();
              mediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
                  @Override
                  public void onCompletion(MediaPlayer mp) {
                      mp.release();
                  }
              });
          }
      });
  }
  </code></pre>