diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseHomeTabFragment.kt b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseHomeTabFragment.kt index d30a9821de..698cbf2f1e 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseHomeTabFragment.kt +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseHomeTabFragment.kt @@ -273,6 +273,7 @@ class CourseHomeTabFragment : OfflineSupportBaseFragment(), CourseHomeAdapter.On false ) courseUnitDetailLauncher.launch(courseUnitDetailIntent) + arguments?.putString(Router.EXTRA_SCREEN_NAME, null) screenName = null } } diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseTabsDashboardFragment.kt b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseTabsDashboardFragment.kt index 33c580c31a..40bfb50266 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseTabsDashboardFragment.kt +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseTabsDashboardFragment.kt @@ -130,28 +130,7 @@ class CourseTabsDashboardFragment : BaseFragment() { private val fullscreenLoader: FullscreenLoaderDialogFragment? get() = getRetainedInstance(childFragmentManager) - private val courseTabItems: List - get() { - val screenName = arguments?.getString(Router.EXTRA_SCREEN_NAME) - val items = mutableListOf() - - items.add(createCourseOutlineItem(screenName)) - if (environment.config.isCourseVideosEnabled) { - items.add(createVideosItem()) - } - if (environment.config.isDiscussionsEnabled && - courseData.course.discussionUrl?.isNotEmpty() == true - ) { - items.add(createDiscussionsItem()) - } - if (environment.config.isCourseDatesEnabled) { - items.add(createDatesItem()) - } - items.add(createHandoutsItem()) - items.add(createAnnouncementsItem()) - - return items - } + private lateinit var courseTabItems: List private val onBackPressedCallback: OnBackPressedCallback = object : OnBackPressedCallback(true) { @@ -191,6 +170,7 @@ class CourseTabsDashboardFragment : BaseFragment() { binding = FragmentCourseTabsDashboardBinding.inflate(inflater, container, false) courseData = arguments?.serializableOrThrow(Router.EXTRA_COURSE_DATA) as EnrolledCoursesResponse + courseTabItems = getCourseTabItems() setHasOptionsMenu(courseData.course.coursewareAccess.hasAccess()) @@ -788,6 +768,28 @@ class CourseTabsDashboardFragment : BaseFragment() { }) } + private fun getCourseTabItems(): List { + val screenName = arguments?.getString(Router.EXTRA_SCREEN_NAME) + val items = mutableListOf() + + items.add(createCourseOutlineItem(screenName)) + if (environment.config.isCourseVideosEnabled) { + items.add(createVideosItem()) + } + if (environment.config.isDiscussionsEnabled && + courseData.course.discussionUrl?.isNotEmpty() == true + ) { + items.add(createDiscussionsItem()) + } + if (environment.config.isCourseDatesEnabled) { + items.add(createDatesItem()) + } + items.add(createHandoutsItem()) + items.add(createAnnouncementsItem()) + + return items + } + private fun createCourseOutlineItem(screenName: String?): FragmentItemModel { return FragmentItemModel( CourseHomeTabFragment::class.java,