Last active
January 11, 2017 10:20
-
-
Save deepak786/a935f5cc00cf66b524e7 to your computer and use it in GitHub Desktop.
Use of Recycler Listener on ListView when the listItem is Recycled for later use. For example you can use this to stop playing audio or video when listitem becomes invisible like Facebook, Instagram, Twitter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
yourListView.setRecyclerListener(new RecyclerListener() { | |
@Override | |
public void onMovedToScrapHeap(View view) { | |
// get the holder of the list item from where you can update ui, stop media player etc. | |
Holder holder = (Holder)view.getTag(); | |
if(holder.mp!=null && holder.mp.isPlaying()){ | |
holder.mp.pause(); | |
holder.imageViewPlay.setBackgroundResource(R.drawable.icon_play); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment