mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2024-12-25 08:21:59 +01:00
Fixed leaking fragments in recycledViewPool
This commit is contained in:
parent
a7b38bd152
commit
d557621df9
@ -86,6 +86,19 @@ public class EpisodeItemListAdapter extends RecyclerView.Adapter<EpisodeItemView
|
||||
protected void afterBindViewHolder(EpisodeItemViewHolder holder, int pos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRecycled(@NonNull EpisodeItemViewHolder holder) {
|
||||
super.onViewRecycled(holder);
|
||||
// Set all listeners to null. This is required to prevent leaking fragments that have set a listener.
|
||||
// Activity -> recycledViewPool -> EpisodeItemViewHolder -> Listener -> Fragment (can not be garbage collected)
|
||||
holder.itemView.setOnClickListener(null);
|
||||
holder.secondaryActionButton.setOnClickListener(null);
|
||||
holder.dragHandle.setOnTouchListener(null);
|
||||
holder.coverHolder.setOnTouchListener(null);
|
||||
holder.container.setOnCreateContextMenuListener(null);
|
||||
holder.container.setOnLongClickListener(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@link #notifyItemChanged(int)} is final, so we can not override.
|
||||
* Calling {@link #notifyItemChanged(int)} may bind the item to a new ViewHolder and execute a transition.
|
||||
|
@ -39,7 +39,7 @@ import de.danoeh.antennapod.view.CircularProgressBar;
|
||||
public class EpisodeItemViewHolder extends RecyclerView.ViewHolder {
|
||||
private static final String TAG = "EpisodeItemViewHolder";
|
||||
|
||||
private final View container;
|
||||
public final View container;
|
||||
public final ImageView dragHandle;
|
||||
private final TextView placeholder;
|
||||
private final ImageView cover;
|
||||
|
Loading…
Reference in New Issue
Block a user