From fd21986c1d60b91f34d6fb76469a5d3e17a943a7 Mon Sep 17 00:00:00 2001 From: Farhan Arshad Date: Mon, 15 Aug 2022 20:15:44 +0500 Subject: [PATCH] fix: `CourseUnitNavigationActivity` resume crashes after free up resources. - App crashes when the user resumes the app when memory is low and the user tries to change the unit/component through the next/previous buttons or swipe left/right, to fix these issues store state using `onSaveInstanceState`, and restore state on `onRestoreInstanceState` to make sure the availability of data. fixes: - LEARNER-8984 - LEARNER-8985 --- .../src/main/java/org/edx/mobile/view/CourseBaseActivity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseBaseActivity.java b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseBaseActivity.java index ee979d64c8..abeb8a40da 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseBaseActivity.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseBaseActivity.java @@ -100,6 +100,7 @@ public void onSaveInstanceState(Bundle outState) { } protected void restore(Bundle savedInstanceState) { + blocksApiVersion = config.getApiUrlVersionConfig().getBlocksApiVersion(); if (savedInstanceState != null) { courseData = (EnrolledCoursesResponse) savedInstanceState.getSerializable(Router.EXTRA_COURSE_DATA); courseUpgradeData = savedInstanceState.getParcelable(Router.EXTRA_COURSE_UPGRADE_DATA); @@ -115,7 +116,6 @@ protected void restore(Bundle savedInstanceState) { * Method to force update the course structure from server. */ protected void updateCourseStructure(String courseId, String componentId) { - blocksApiVersion = config.getApiUrlVersionConfig().getBlocksApiVersion(); getHierarchyCall = courseApi.getCourseStructureWithoutStale(blocksApiVersion, courseId); getHierarchyCall.enqueue(new CourseAPI.GetCourseStructureCallback(this, courseId, new ProgressViewController(binding.loadingIndicator.loadingIndicator), errorNotification,