From 52f70aae018566be95aeb1714d284b0aec54c63b Mon Sep 17 00:00:00 2001 From: Omer Habib Date: Thu, 10 Sep 2020 12:56:36 +0500 Subject: [PATCH] Crash fix of null profile exception on CourseOutlineFragment.java - LEARNER-7917 --- .../java/org/edx/mobile/view/CourseOutlineFragment.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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 9c19e47125..9f8cc1bc01 100644 --- a/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseOutlineFragment.java +++ b/OpenEdXMobile/src/main/java/org/edx/mobile/view/CourseOutlineFragment.java @@ -52,6 +52,7 @@ import org.edx.mobile.logger.Logger; import org.edx.mobile.model.api.CourseUpgradeResponse; import org.edx.mobile.model.api.EnrolledCoursesResponse; +import org.edx.mobile.model.api.ProfileModel; import org.edx.mobile.model.course.BlockPath; import org.edx.mobile.model.course.CourseComponent; import org.edx.mobile.model.course.CourseStructureV1Model; @@ -234,11 +235,12 @@ private void trackAATestCourseOutline() { final FirebaseRemoteConfig firebaseRemoteConfig = FirebaseRemoteConfig.getInstance(); firebaseRemoteConfig.fetchAndActivate().addOnCompleteListener(task -> { final String group = firebaseRemoteConfig.getString(Analytics.Keys.AA_EXPERIMENT); - if (!TextUtils.isEmpty(group)) { + final ProfileModel profileModel = environment.getLoginPrefs().getCurrentUserProfile(); + if (!TextUtils.isEmpty(group) && profileModel != null) { final Map values = new HashMap<>(); values.put(Analytics.Keys.EXPERIMENT, Analytics.Keys.AA_EXPERIMENT); values.put(Analytics.Keys.GROUP, group); - values.put(Analytics.Keys.USER_ID, environment.getLoginPrefs().getCurrentUserProfile().id.toString()); + values.put(Analytics.Keys.USER_ID, profileModel.id.toString()); values.put(Analytics.Keys.COURSE_ID, courseData.getCourse().getId()); environment.getAnalyticsRegistry().trackExperimentParams(Analytics.Events.MOBILE_EXPERIMENT_EVALUATED, values); }