@@ -714,12 +714,7 @@ class FileDisplayActivity :
714714 }
715715
716716 prepareFragmentBeforeCommit(showSortListGroup)
717- commitFragment(fragment) {
718- Log_OC .d(
719- TAG ,
720- " Left fragment committed: $it "
721- )
722- }
717+ commitFragment(fragment)
723718 }
724719
725720 private fun prepareFragmentBeforeCommit (showSortListGroup : Boolean ) {
@@ -732,20 +727,21 @@ class FileDisplayActivity :
732727 showSortListGroup(showSortListGroup)
733728 }
734729
735- private fun commitFragment (fragment : Fragment , callback : ( Boolean ) -> Unit ) {
730+ private fun commitFragment (fragment : Fragment ): Boolean {
736731 val fragmentManager = supportFragmentManager
737732 if (! isActive() || fragmentManager.isDestroyed || fragmentManager.isStateSaved) {
738- callback( false )
739- return
733+ Log_OC .d( TAG , " ${fragment.javaClass.simpleName} not committed, skipping " )
734+ return false
740735 }
741736
742- fragmentManager.beginTransaction().run {
743- addToBackStack(null )
744- replace(R .id.left_fragment_container, fragment, TAG_LIST_OF_FILES )
745- commit()
746- }
737+ fragmentManager.beginTransaction()
738+ .addToBackStack(null )
739+ .replace(R .id.left_fragment_container, fragment, TAG_LIST_OF_FILES )
740+ .commit()
741+
742+ Log_OC .d(TAG , " ${fragment.javaClass.simpleName} committed, pending transaction" )
747743
748- callback( true )
744+ return true
749745 }
750746
751747 private fun getOCFileListFragmentFromFile (transaction : TransactionInterface ) {
@@ -765,18 +761,9 @@ class FileDisplayActivity :
765761 val fm = supportFragmentManager
766762 if (! fm.isStateSaved && ! fm.isDestroyed) {
767763 prepareFragmentBeforeCommit(true )
768- commitFragment(listOfFiles) {
769- if (it) {
770- Log_OC .d(TAG , " OCFileListFragment committed, executing pending transaction" )
771- fm.executePendingTransactions()
772- transaction.onOCFileListFragmentComplete(listOfFiles)
773- } else {
774- Log_OC .d(
775- TAG ,
776- " OCFileListFragment not committed, skipping executing " +
777- " pending transaction"
778- )
779- }
764+ if (commitFragment(listOfFiles)) {
765+ fm.executePendingTransactions()
766+ transaction.onOCFileListFragmentComplete(listOfFiles)
780767 }
781768 }
782769 }
0 commit comments