Merge pull request #202 from jonathan-caryl/leak_canary

Add LeakCanary for debug versions of the app
This commit is contained in:
Tibor Kaputa 2017-08-12 22:59:10 +02:00 committed by GitHub
commit 84e6a779ed
10 changed files with 42 additions and 2 deletions

View File

@ -33,9 +33,15 @@ android {
sourceSets { sourceSets {
main.java.srcDirs += 'src/main/kotlin' main.java.srcDirs += 'src/main/kotlin'
debug.java.srcDirs += 'src/debug/kotlin'
release.java.srcDirs += 'src/release/kotlin'
} }
} }
ext {
leakCanaryVersion = '1.5.2'
}
dependencies { dependencies {
compile 'com.simplemobiletools:commons:2.25.3' compile 'com.simplemobiletools:commons:2.25.3'
compile 'joda-time:joda-time:2.9.1' compile 'joda-time:joda-time:2.9.1'
@ -44,6 +50,8 @@ dependencies {
compile 'com.android.support:multidex:1.0.1' compile 'com.android.support:multidex:1.0.1'
compile 'com.google.code.gson:gson:2.8.0' compile 'com.google.code.gson:gson:2.8.0'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
debugCompile "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
releaseCompile "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"
} }
buildscript { buildscript {

View File

@ -0,0 +1,14 @@
package com.simplemobiletools.calendar
import com.squareup.leakcanary.LeakCanary
open class BuildVariantApplication : BaseApp() {
override fun onCreate() {
super.onCreate()
LeakCanary.install(this);
}
override fun shouldInit(): Boolean {
return !LeakCanary.isInAnalyzerProcess(this)
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="leak_canary_display_activity_label">Calendar Leaks</string>
</resources>

View File

@ -1,11 +1,13 @@
package com.simplemobiletools.calendar package com.simplemobiletools.calendar
import android.support.multidex.MultiDexApplication
import com.facebook.stetho.Stetho import com.facebook.stetho.Stetho
class App : MultiDexApplication() { class App : BuildVariantApplication() {
override fun onCreate() { override fun onCreate() {
super.onCreate() super.onCreate()
if (!shouldInit()) {
return
}
Stetho.initializeWithDefaults(this) Stetho.initializeWithDefaults(this)
} }
} }

View File

@ -0,0 +1,9 @@
package com.simplemobiletools.calendar
import android.support.multidex.MultiDexApplication
abstract class BaseApp : MultiDexApplication() {
open fun shouldInit(): Boolean {
return true
}
}

View File

@ -0,0 +1,3 @@
package com.simplemobiletools.calendar
open class BuildVariantApplication : BaseApp()