Skip to content

Commit dddd271

Browse files
committed
refactor: simplify onViewCreated method to comply with LongMethod Detekt rule
1 parent a0ad310 commit dddd271

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

owncloudApp/src/main/java/com/owncloud/android/presentation/files/details/FileDetailsFragment.kt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,7 @@ class FileDetailsFragment : FileFragment() {
126126
super.onViewCreated(view, savedInstanceState)
127127
isMultiPersonal = requireArguments().getBoolean(ARG_IS_MULTIPERSONAL)
128128

129-
collectLatestLifecycleFlow(fileDetailsViewModel.currentFile) { ocFileWithSyncInfo: OCFileWithSyncInfo? ->
130-
if (ocFileWithSyncInfo != null) {
131-
file = ocFileWithSyncInfo.file
132-
updateDetails(ocFileWithSyncInfo)
133-
} else {
134-
requireActivity().onBackPressed()
135-
}
136-
}
129+
observeCurrentFile()
137130

138131
collectLatestLifecycleFlow(fileDetailsViewModel.appRegistryMimeType) { appRegistryMimeType ->
139132
if (appRegistryMimeType != null) {
@@ -602,6 +595,17 @@ class FileDetailsFragment : FileFragment() {
602595
fileOperationsViewModel.setLastUsageFile(fileWaitingToPreview)
603596
}
604597

598+
private fun observeCurrentFile() {
599+
collectLatestLifecycleFlow(fileDetailsViewModel.currentFile) { ocFileWithSyncInfo: OCFileWithSyncInfo? ->
600+
if (ocFileWithSyncInfo != null) {
601+
file = ocFileWithSyncInfo.file
602+
updateDetails(ocFileWithSyncInfo)
603+
} else {
604+
requireActivity().onBackPressed()
605+
}
606+
}
607+
}
608+
605609
override fun updateViewForSyncInProgress() {
606610
// Not yet implemented
607611
}

0 commit comments

Comments
 (0)