@@ -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