Skip to content

Commit 2828eec

Browse files
Refactor & remove tryStopRecording
1 parent 1c454a5 commit 2828eec

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

app/src/main/java/com/dp/logcatapp/activities/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class MainActivity : BaseActivityWithToolbar() {
8888
if (intent?.getBooleanExtra(STOP_RECORDING_EXTRA, false) == true) {
8989
val fragment = supportFragmentManager.findFragmentByTag(LogcatLiveFragment.TAG)
9090
if (fragment != null) {
91-
(fragment as LogcatLiveFragment).tryStopRecording()
91+
(fragment as LogcatLiveFragment).stopRecording()
9292
}
9393
}
9494
}

app/src/main/java/com/dp/logcatapp/fragments/logcatlive/LogcatLiveFragment.kt

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -617,19 +617,13 @@ class LogcatLiveFragment : BaseFragment(), ServiceConnection, LogsReceivedListen
617617
startActivity(intent)
618618
}
619619

620-
fun tryStopRecording() {
620+
fun stopRecording() {
621621
viewModel.stopRecording = true
622-
if (logcatService != null) {
623-
stopRecording()
624-
}
625-
}
626-
627-
private fun stopRecording() {
628-
logcatService.value?.let {
629-
if (it.recording) {
630-
it.updateNotification(false)
622+
logcatService.value?.let { service ->
623+
if (service.recording) {
624+
service.updateNotification(false)
631625
saveToFile(true)
632-
it.recording = false
626+
service.recording = false
633627
activity?.invalidateOptionsMenu()
634628
}
635629
}

0 commit comments

Comments
 (0)