diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/event/MyCoursesRefreshEvent.kt b/OpenEdXMobile/src/main/java/org/edx/mobile/event/MyCoursesRefreshEvent.kt new file mode 100644 index 0000000000..96fc667795 --- /dev/null +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/event/MyCoursesRefreshEvent.kt @@ -0,0 +1,8 @@ +package org.edx.mobile.event + +/** + * The event to fire through [EventBus][org.greenrobot.eventbus.EventBus] whenever some screen state + * needs to refresh on [MyCoursesListFragment][org.edx.mobile.view.MyCoursesListFragment] after in-app + * purchase. + */ +class MyCoursesRefreshEvent diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/AccountFragment.kt b/OpenEdXMobile/src/main/java/org/edx/mobile/view/AccountFragment.kt index a94bb72dfd..c7845d0f7b 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/AccountFragment.kt +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/AccountFragment.kt @@ -22,8 +22,8 @@ import org.edx.mobile.deeplink.Screen import org.edx.mobile.deeplink.ScreenDef import org.edx.mobile.event.AccountDataLoadedEvent import org.edx.mobile.event.IAPFlowEvent -import org.edx.mobile.event.MainDashboardRefreshEvent import org.edx.mobile.event.MediaStatusChangeEvent +import org.edx.mobile.event.MyCoursesRefreshEvent import org.edx.mobile.event.ProfilePhotoUpdatedEvent import org.edx.mobile.exception.ErrorMessage import org.edx.mobile.extenstion.isVisible @@ -545,7 +545,7 @@ class AccountFragment : BaseFragment() { @SuppressWarnings("unused") fun onEventMainThread(event: IAPFlowEvent) { if (this.isResumed && event.flowAction == IAPFlowData.IAPAction.PURCHASE_FLOW_COMPLETE) { - EventBus.getDefault().post(MainDashboardRefreshEvent()) + EventBus.getDefault().post(MyCoursesRefreshEvent()) requireActivity().finish() } } diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseOutlineFragment.java b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseOutlineFragment.java index 9c04c572f6..a7c4d0bc08 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseOutlineFragment.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseOutlineFragment.java @@ -45,8 +45,8 @@ import org.edx.mobile.event.CourseUpgradedEvent; import org.edx.mobile.event.IAPFlowEvent; import org.edx.mobile.event.LogoutEvent; -import org.edx.mobile.event.MainDashboardRefreshEvent; import org.edx.mobile.event.MediaStatusChangeEvent; +import org.edx.mobile.event.MyCoursesRefreshEvent; import org.edx.mobile.event.NetworkConnectivityChangeEvent; import org.edx.mobile.exception.CourseContentNotValidException; import org.edx.mobile.exception.ErrorMessage; @@ -1061,7 +1061,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) { // Update the User CourseEnrollments & Dates banner if after user // Purchase course from Locked Component courseDateViewModel.fetchCourseDatesBannerInfo(courseData.getCourseId(), true); - EventBus.getDefault().post(new MainDashboardRefreshEvent()); + EventBus.getDefault().post(new MyCoursesRefreshEvent()); } } else { final CourseComponent outlineComp = courseManager.getComponentByIdFromAppLevelCache( @@ -1138,7 +1138,7 @@ public void onEventMainThread(@NonNull IAPFlowEvent event) { case PURCHASE_FLOW_COMPLETE: { courseData.setMode(EnrollmentMode.VERIFIED.toString()); getCourseComponentFromServer(false, true); - EventBus.getDefault().post(new MainDashboardRefreshEvent()); + EventBus.getDefault().post(new MyCoursesRefreshEvent()); break; } } diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseUnitNavigationActivity.java b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseUnitNavigationActivity.java index 7a162c7b2b..7c6687ba22 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseUnitNavigationActivity.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseUnitNavigationActivity.java @@ -27,7 +27,7 @@ import org.edx.mobile.event.CourseUpgradedEvent; import org.edx.mobile.event.FileSelectionEvent; import org.edx.mobile.event.IAPFlowEvent; -import org.edx.mobile.event.MainDashboardRefreshEvent; +import org.edx.mobile.event.MyCoursesRefreshEvent; import org.edx.mobile.event.VideoPlaybackEvent; import org.edx.mobile.exception.ErrorMessage; import org.edx.mobile.http.callback.ErrorHandlingCallback; @@ -496,7 +496,7 @@ public void onEventMainThread(IAPFlowEvent event) { break; } case PURCHASE_FLOW_COMPLETE: { - EventBus.getDefault().post(new MainDashboardRefreshEvent()); + EventBus.getDefault().post(new MyCoursesRefreshEvent()); break; } } diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/MyCoursesListFragment.kt b/OpenEdXMobile/src/main/java/org/edx/mobile/view/MyCoursesListFragment.kt index b7c8e90176..b07a905991 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/MyCoursesListFragment.kt +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/MyCoursesListFragment.kt @@ -20,6 +20,7 @@ import org.edx.mobile.event.EnrolledInCourseEvent import org.edx.mobile.event.IAPFlowEvent import org.edx.mobile.event.MainDashboardRefreshEvent import org.edx.mobile.event.MoveToDiscoveryTabEvent +import org.edx.mobile.event.MyCoursesRefreshEvent import org.edx.mobile.event.NetworkConnectivityChangeEvent import org.edx.mobile.exception.ErrorMessage import org.edx.mobile.extenstion.setVisibility @@ -401,6 +402,12 @@ class MyCoursesListFragment : OfflineSupportBaseFragment(), RefreshListener { courseViewModel.fetchEnrolledCourses(type = CoursesRequestType.LIVE) } + @Subscribe(sticky = true) + @Suppress("UNUSED_PARAMETER") + fun onEvent(event: MyCoursesRefreshEvent) { + courseViewModel.fetchEnrolledCourses(type = CoursesRequestType.LIVE) + } + override fun onRevisit() { super.onRevisit() if (NetworkUtil.isConnected(activity)) {