From 1e85dd4e49242da2a4ce66a04d9c24389d68f037 Mon Sep 17 00:00:00 2001 From: xuexiangjys Date: Tue, 27 Apr 2021 01:50:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8D=87=E7=BA=A7leakcanary=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/build.gradle | 8 +++----- .../main/java/com/xuexiang/rxutil2demo/App.java | 15 --------------- .../xuexiang/rxutil2demo/base/BaseActivity.java | 9 --------- .../xuexiang/rxutil2demo/base/BaseFragment.java | 10 ---------- 4 files changed, 3 insertions(+), 39 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 308301c..b984c47 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -38,11 +38,9 @@ dependencies { implementation deps.rxandroid implementation deps.rxbinding -// implementation project(':rxutil2') - implementation 'com.github.xuexiangjys:RxUtil2:1.2.0' + implementation project(':rxutil2') +// implementation 'com.github.xuexiangjys:RxUtil2:1.2.0' //leak - debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.6.3' - releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3' - testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.6.3' + debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.6' } diff --git a/app/src/main/java/com/xuexiang/rxutil2demo/App.java b/app/src/main/java/com/xuexiang/rxutil2demo/App.java index 35ceaf5..ff015d6 100644 --- a/app/src/main/java/com/xuexiang/rxutil2demo/App.java +++ b/app/src/main/java/com/xuexiang/rxutil2demo/App.java @@ -18,8 +18,6 @@ import android.app.Application; -import com.squareup.leakcanary.LeakCanary; -import com.squareup.leakcanary.RefWatcher; import com.xuexiang.rxutil2.logs.RxLog; import com.xuexiang.xutil.XUtil; @@ -29,26 +27,13 @@ */ public class App extends Application { - private static RefWatcher gRefWatcher; @Override public void onCreate() { super.onCreate(); XUtil.init(this); - initCanary(); - RxLog.debug(true); } - private void initCanary() { - if (LeakCanary.isInAnalyzerProcess(this)) { - return; - } - gRefWatcher = LeakCanary.install(this); - } - - public static RefWatcher getRefWatcher() { - return gRefWatcher; - } } diff --git a/app/src/main/java/com/xuexiang/rxutil2demo/base/BaseActivity.java b/app/src/main/java/com/xuexiang/rxutil2demo/base/BaseActivity.java index e9f6d9d..cfedda5 100644 --- a/app/src/main/java/com/xuexiang/rxutil2demo/base/BaseActivity.java +++ b/app/src/main/java/com/xuexiang/rxutil2demo/base/BaseActivity.java @@ -26,9 +26,7 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; -import com.squareup.leakcanary.RefWatcher; import com.xuexiang.rxutil2.lifecycle.RxLifecycle; -import com.xuexiang.rxutil2demo.App; import butterknife.ButterKnife; import butterknife.Unbinder; @@ -62,8 +60,6 @@ protected void initArgs() { protected void onDestroy() { mUnbinder.unbind(); super.onDestroy(); - RefWatcher refWatcher = App.getRefWatcher(); - refWatcher.watch(this); } /** @@ -84,15 +80,10 @@ protected void onDestroy() { */ protected abstract void initListener(); - protected T $(int id) { - return (T) findViewById(id); - } - protected void startActivity(Class clazz) { startActivity(new Intent(this, clazz)); } - protected void toast(String msg) { Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); } diff --git a/app/src/main/java/com/xuexiang/rxutil2demo/base/BaseFragment.java b/app/src/main/java/com/xuexiang/rxutil2demo/base/BaseFragment.java index 65795b5..7974120 100644 --- a/app/src/main/java/com/xuexiang/rxutil2demo/base/BaseFragment.java +++ b/app/src/main/java/com/xuexiang/rxutil2demo/base/BaseFragment.java @@ -25,9 +25,6 @@ import androidx.annotation.Nullable; import androidx.fragment.app.Fragment; -import com.squareup.leakcanary.RefWatcher; -import com.xuexiang.rxutil2demo.App; - import butterknife.ButterKnife; import butterknife.Unbinder; @@ -100,11 +97,4 @@ protected void runOnUiThread(Runnable action) { } } - - @Override - public void onDestroy() { - super.onDestroy(); - RefWatcher refWatcher = App.getRefWatcher(); - refWatcher.watch(this); - } }