Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.

Commit 564d540

Browse files
authored
Merge pull request #73 from amardeshbd/69-fix-activity-memory-leak
[NOFIX] [#69] Unable to find the activity leak.
2 parents 8280b07 + 108cb4c commit 564d540

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

app/src/main/java/com/hossainkhan/android/demo/layoutpreview/LayoutPreviewBaseActivity.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ open class LayoutPreviewBaseActivity : AppCompatActivity() {
7878

7979
setContentView(layoutResourceId)
8080

81-
viewModel = ViewModelProvider(this, viewModelFactory)
82-
.get(LayoutInfoViewModel::class.java)
81+
viewModel = ViewModelProvider(this, viewModelFactory).get(LayoutInfoViewModel::class.java)
8382
viewModel.init(layoutResourceId)
8483

8584
supportActionBar?.setDisplayHomeAsUpEnabled(true)
@@ -92,6 +91,12 @@ open class LayoutPreviewBaseActivity : AppCompatActivity() {
9291
})
9392
}
9493

94+
override fun onStop() {
95+
super.onStop()
96+
flashbar?.dismiss()
97+
flashbar = null
98+
}
99+
95100
private fun updateActionBar(layoutInformation: LayoutInformation) {
96101
supportActionBar?.title = layoutInformation.title
97102
}
@@ -144,7 +149,7 @@ open class LayoutPreviewBaseActivity : AppCompatActivity() {
144149
builder.setShowTitle(false)
145150
.addDefaultShareMenuItem()
146151
val customTabsIntent = builder.build()
147-
customTabsIntent.launchUrl(this, Uri.parse(viewModel.layoutUrl))
152+
customTabsIntent.launchUrl(applicationContext, Uri.parse(viewModel.layoutUrl))
148153
}
149154

150155

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ ext {
107107
daggerVersion = '2.15' // https://github.com/google/dagger
108108
timberLibraryVersion = '4.7.1' // https://github.com/JakeWharton/timber
109109
leakcanaryLibraryVersion = '1.6.3' // https://github.com/square/leakcanary/releases
110-
flashBarVersion = '1.0.2' // https://github.com/aritraroy/Flashbar/releases
110+
flashBarVersion = '1.0.3' // https://github.com/aritraroy/Flashbar/releases
111111
}
112112

113113
//

0 commit comments

Comments
 (0)