diff options
author | H. Lehmann <ByteHamster@users.noreply.github.com> | 2020-06-14 19:50:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-14 19:50:01 +0200 |
commit | 04099e7efa755307f853c740c064f7051f4adb27 (patch) | |
tree | b1cef84a48d44d1bbe403c725b07e45085992800 /app/src/main | |
parent | 51e17214f87c2513f2111d0a2faebf704a1a2103 (diff) | |
parent | d557621df953c72ffa525045e62d3840f1b93321 (diff) | |
download | AntennaPod-04099e7efa755307f853c740c064f7051f4adb27.zip |
Merge pull request #4231 from ByteHamster/garbage-collect
Fixed leaking fragments
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java | 13 | ||||
-rw-r--r-- | app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java | 2 |
2 files changed, 14 insertions, 1 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java b/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java index 7099d6f3a..8efc89c9a 100644 --- a/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java +++ b/app/src/main/java/de/danoeh/antennapod/adapter/EpisodeItemListAdapter.java @@ -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. diff --git a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java index 55a3d1130..902e5094b 100644 --- a/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java +++ b/app/src/main/java/de/danoeh/antennapod/view/viewholder/EpisodeItemViewHolder.java @@ -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; |