I have a RecyclerView.Adapter<MyViewHolder> that handles creation and binding of ViewHolders based on a backing data set. Whenever the view is scrolled ViewHolders are being recycled and rebound, calling first #onViewRecycled and #onBindViewHolder for each recycled element. However, since my ViewHolders also contain resources that need to be cleaned up upon recycling (running async operations and Bitmaps) I want #onViewRecycled only called when the view is going to be bound with a different element (that has a different identity).
Now there is the case where I want to refresh some already bound ViewHolder, for example when I want to visually highlight it. I'm already setting this highlight inside my adapter's #onBindViewHolder, as this is the place where the view is populated from my data. For me the solution on hand was to update the backing data and trigger an invalidation using adapter.notifyItemChanged(changedPosition). However, this will cause a call to #onViewRecycled for the specific item before rebinding, which will cause to release resources as well. What's the expected place to update such properties on my ViewHolder? Am I'm expected to handle view population without first recycling externally? -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/1c2c3525-5c1f-492c-af51-8728463cbdb0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

