From 1628ec56c23b3626c128b5fb38ee0c5a74ea7b65 Mon Sep 17 00:00:00 2001 From: LagradOst Date: Wed, 10 Nov 2021 23:37:44 +0100 Subject: [PATCH] mem leak fix --- app/build.gradle | 3 +++ .../lagradost/cloudstream3/ui/download/DownloadFragment.kt | 5 ++++- .../com/lagradost/cloudstream3/ui/player/PlayerFragment.kt | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index c4e25c46..67ad34e8 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -149,4 +149,7 @@ dependencies { // Util to skip the URI file fuckery 🙏 implementation "com.github.tachiyomiorg:unifile:17bec43" + + // debugImplementation because LeakCanary should only run in debug builds. + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7' } \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt index f0911bf3..b2f3d444 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt @@ -57,7 +57,10 @@ class DownloadFragment : Fragment() { } override fun onDestroy() { - downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent -= it } + if(downloadDeleteEventListener != null) { + VideoDownloadManager.downloadDeleteEvent -= downloadDeleteEventListener!! + downloadDeleteEventListener = null + } super.onDestroy() } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt index dea065c7..cd8d99cf 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerFragment.kt @@ -1719,6 +1719,7 @@ class PlayerFragment : Fragment() { } override fun onDestroy() { + MainActivity.playerEventListener = null /* val lp = activity?.window?.attributes