Skip to content

Commit

Permalink
Follow up on #1341 (#1343)
Browse files Browse the repository at this point in the history
Making the intent creator a property using the application instance.
  • Loading branch information
pyricau authored May 8, 2019
1 parent ffd14c0 commit 919320c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
11 changes: 3 additions & 8 deletions leakcanary-android-core/src/main/java/leakcanary/LeakCanary.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package leakcanary

import android.app.Application
import android.content.Context
import android.content.Intent
import leakcanary.AndroidExcludedRefs.Companion.exclusionsFactory
import leakcanary.internal.InternalLeakCanary
import leakcanary.internal.activity.LeakActivity

typealias AnalysisResultListener = (Application, HeapAnalysis) -> Unit

Expand Down Expand Up @@ -54,10 +52,7 @@ object LeakCanary {
@Volatile
var config: Config = Config()

/**
* @return a new [Intent] that can be used to programmatically launch the leak display activity.
*/
fun createLeakDisplayActivityIntent(context: Context): Intent {
return LeakActivity.createIntent(context)
}
/** [Intent] that can be used to programmatically launch the leak display activity. */
val leakDisplayActivityIntent
get() = InternalLeakCanary.leakDisplayActivityIntent
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import leakcanary.CanaryLog
import leakcanary.GcTrigger
import leakcanary.LeakCanary
import leakcanary.LeakSentry
import leakcanary.internal.activity.LeakActivity

internal object InternalLeakCanary : LeakSentryListener {

Expand All @@ -31,6 +32,9 @@ internal object InternalLeakCanary : LeakSentryListener {
LeakDirectoryProvider(application)
}

val leakDisplayActivityIntent: Intent
get() = LeakActivity.createIntent(application)

override fun onLeakSentryInstalled(application: Application) {
this.application = application

Expand Down Expand Up @@ -137,7 +141,7 @@ internal object InternalLeakCanary : LeakSentryListener {
return
}

val intent = LeakCanary.createLeakDisplayActivityIntent(application)
val intent = leakDisplayActivityIntent
intent.action = "Dummy Action because Android is stupid"
val shortcut = Builder(application, DYNAMIC_SHORTCUT_ID)
.setLongLabel(longLabel)
Expand Down

0 comments on commit 919320c

Please sign in to comment.