From b6b8e71ec4ca7ab9d0bce23e4f0592fbd9c5f722 Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 30 Nov 2017 00:07:30 +0100 Subject: [PATCH] adding LeakCanary and BaseSplashActivity --- app/build.gradle | 11 +++++++++++ .../kotlin/com/simplemobiletools/musicplayer/App.kt | 9 +++++++++ .../musicplayer/activities/SplashActivity.kt | 8 +++----- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index f64cc445..066d58f5 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -20,10 +20,14 @@ android { } buildTypes { + debug { + buildConfigField "boolean", "USE_LEAK_CANARY", "true" + } release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' signingConfig signingConfigs.release + buildConfigField "boolean", "USE_LEAK_CANARY", "false" } } @@ -37,10 +41,17 @@ android { } } +ext { + leakCanaryVersion = '1.5.4' +} + dependencies { implementation 'com.simplemobiletools:commons:3.0.3' implementation 'com.squareup:otto:1.3.8' implementation 'com.facebook.stetho:stetho:1.5.0' + + debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion" + releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion" } Properties props = new Properties() diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/App.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/App.kt index f9450777..82ee0680 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/App.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/App.kt @@ -2,10 +2,19 @@ package com.simplemobiletools.musicplayer import android.app.Application import com.facebook.stetho.Stetho +import com.simplemobiletools.musicplayer.BuildConfig.USE_LEAK_CANARY +import com.squareup.leakcanary.LeakCanary class App : Application() { override fun onCreate() { super.onCreate() + if (USE_LEAK_CANARY) { + if (LeakCanary.isInAnalyzerProcess(this)) { + return + } + LeakCanary.install(this) + } + Stetho.initializeWithDefaults(this) } } diff --git a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SplashActivity.kt b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SplashActivity.kt index 8e895fd1..d6ff1d28 100644 --- a/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SplashActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/musicplayer/activities/SplashActivity.kt @@ -1,12 +1,10 @@ package com.simplemobiletools.musicplayer.activities import android.content.Intent -import android.os.Bundle -import android.support.v7.app.AppCompatActivity +import com.simplemobiletools.commons.activities.BaseSplashActivity -class SplashActivity : AppCompatActivity() { - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) +class SplashActivity : BaseSplashActivity() { + override fun initActivity() { startActivity(Intent(this, MainActivity::class.java)) finish() }