Skip to content

Commit ba19d09

Browse files
Fix: open file from homescreen when app is closed
Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
1 parent 7952523 commit ba19d09

1 file changed

Lines changed: 15 additions & 21 deletions

File tree

app/src/main/java/com/owncloud/android/ui/activity/FileDisplayActivity.kt

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -683,33 +683,27 @@ class FileDisplayActivity :
683683

684684
val currentFragment = leftFragment
685685

686-
if (currentFragment == null) {
687-
Log_OC.e(TAG, "Can't open file intent, left fragment is null")
688-
return
689-
}
690-
691-
val fileListFragment: OCFileListFragment = when {
692-
currentFragment is OCFileListFragment && currentFragment !is GalleryFragment -> {
693-
currentFragment
686+
if (currentFragment !is OCFileListFragment || currentFragment is GalleryFragment) {
687+
val name = if (currentFragment == null) {
688+
"null"
689+
} else {
690+
currentFragment::class.simpleName
694691
}
695692

696-
else -> {
697-
Log_OC.w(
698-
TAG,
699-
"Left fragment is not a valid OCFileListFragment " +
700-
"(was ${currentFragment::class.simpleName}). " +
701-
"Replacing with OCFileListFragment."
702-
)
703-
val newFragment = OCFileListFragment()
704-
setLeftFragment(newFragment, false)
705-
setupHomeSearchToolbarWithSortAndListButtons()
706-
newFragment
707-
}
693+
Log_OC.w(
694+
TAG,
695+
"Left fragment is not a valid OCFileListFragment (was $name). " +
696+
"Replacing with OCFileListFragment."
697+
)
698+
val newFragment = OCFileListFragment()
699+
setLeftFragment(newFragment, false)
708700
}
709701

710702
// Post to main thread to ensure fragment is fully attached before interacting
711703
Handler(Looper.getMainLooper()).post {
712-
fileListFragment.onItemClicked(file)
704+
leftFragment = supportFragmentManager.findFragmentByTag(TAG_LIST_OF_FILES)
705+
setupHomeSearchToolbarWithSortAndListButtons()
706+
(leftFragment as OCFileListFragment).onItemClicked(file)
713707
}
714708
}
715709

0 commit comments

Comments
 (0)