From c82a6103f16c1c46beeddbfce9e630f7a5768dcd Mon Sep 17 00:00:00 2001 From: zhangpan Date: Wed, 14 Aug 2019 16:47:21 +0800 Subject: [PATCH] Compile LeakCanary to detected Memory Leak,Fix a Memory Leak in NetworkBannerActivity --- app/build.gradle | 1 + .../main/java/com/example/zhpan/circleviewpager/App.java | 3 +++ .../circleviewpager/activity/NetworkBannerActivity.java | 6 ++++++ 3 files changed, 10 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index f2511bc2..dd67f848 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -60,5 +60,6 @@ dependencies { api 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0' api 'io.reactivex.rxjava2:rxandroid:2.1.0' api 'com.squareup.okhttp3:logging-interceptor:3.10.0' + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.0-beta-2' implementation project(path: ':ideahttp') } diff --git a/app/src/main/java/com/example/zhpan/circleviewpager/App.java b/app/src/main/java/com/example/zhpan/circleviewpager/App.java index 90d3a718..0183161c 100644 --- a/app/src/main/java/com/example/zhpan/circleviewpager/App.java +++ b/app/src/main/java/com/example/zhpan/circleviewpager/App.java @@ -6,6 +6,9 @@ import com.example.zhpan.circleviewpager.imageloader.ImageLoaderManager; import com.zhpan.idea.utils.Utils; +import leakcanary.AppWatcher; +import leakcanary.LeakCanary; + /** *
  *   Created by zhangpan on 2019-08-14.
diff --git a/app/src/main/java/com/example/zhpan/circleviewpager/activity/NetworkBannerActivity.java b/app/src/main/java/com/example/zhpan/circleviewpager/activity/NetworkBannerActivity.java
index cb138a11..ac8ae2f9 100644
--- a/app/src/main/java/com/example/zhpan/circleviewpager/activity/NetworkBannerActivity.java
+++ b/app/src/main/java/com/example/zhpan/circleviewpager/activity/NetworkBannerActivity.java
@@ -41,4 +41,10 @@ public void onSuccess(List response) {
             }
         });
     }
+
+    @Override
+    protected void onDestroy() {
+        super.onDestroy();
+        mBannerViewPager.stopLoop();
+    }
 }