Skip to content

Commit

Permalink
升级leakcanary版本
Browse files Browse the repository at this point in the history
  • Loading branch information
xuexiangjys committed Apr 26, 2021
1 parent 7cd4b9e commit 1e85dd4
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 39 deletions.
8 changes: 3 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
15 changes: 0 additions & 15 deletions app/src/main/java/com/xuexiang/rxutil2demo/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,8 +60,6 @@ protected void initArgs() {
protected void onDestroy() {
mUnbinder.unbind();
super.onDestroy();
RefWatcher refWatcher = App.getRefWatcher();
refWatcher.watch(this);
}

/**
Expand All @@ -84,15 +80,10 @@ protected void onDestroy() {
*/
protected abstract void initListener();

protected <T extends View> T $(int id) {
return (T) findViewById(id);
}

protected void startActivity(Class<? extends Activity> clazz) {
startActivity(new Intent(this, clazz));
}


protected void toast(String msg) {
Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
}
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/java/com/xuexiang/rxutil2demo/base/BaseFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -100,11 +97,4 @@ protected void runOnUiThread(Runnable action) {
}
}


@Override
public void onDestroy() {
super.onDestroy();
RefWatcher refWatcher = App.getRefWatcher();
refWatcher.watch(this);
}
}

0 comments on commit 1e85dd4

Please sign in to comment.