Skip to content

Commit ad426b1

Browse files
authored
courses: smoother exam dispatcher providing (fixes #13089) (#13022)
1 parent 526d551 commit ad426b1

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ android {
1212
applicationId "org.ole.planet.myplanet"
1313
minSdk = 26
1414
targetSdk = 36
15-
versionCode = 5363
16-
versionName = "0.53.63"
15+
versionCode = 5364
16+
versionName = "0.53.64"
1717
ndkVersion = '26.3.11579264'
1818
vectorDrawables.useSupportLibrary = true
1919
}

app/src/main/java/org/ole/planet/myplanet/ui/exam/ExamTakingFragment.kt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ class ExamTakingFragment : BaseExamFragment(), View.OnClickListener, CompoundBut
6565

6666
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
6767
super.onViewCreated(view, savedInstanceState)
68+
initializeExamData()
69+
setupListeners()
70+
}
71+
72+
private fun initializeExamData() {
6873
viewLifecycleOwner.lifecycleScope.launch {
6974
user = userSessionManager.getUserModel()
7075
initExam()
@@ -94,7 +99,7 @@ class ExamTakingFragment : BaseExamFragment(), View.OnClickListener, CompoundBut
9499
val examCourseIdValue = exam?.courseId
95100
val userIdValue = user?.id
96101

97-
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
102+
viewLifecycleOwner.lifecycleScope.launch(dispatcherProvider.io) {
98103
try {
99104
submissionsRepository.deleteExamSubmissions(
100105
examIdValue ?: id ?: "", examCourseIdValue, userIdValue
@@ -103,7 +108,7 @@ class ExamTakingFragment : BaseExamFragment(), View.OnClickListener, CompoundBut
103108
e.printStackTrace()
104109
}
105110

106-
withContext(Dispatchers.Main) {
111+
withContext(dispatcherProvider.main) {
107112
answerCache.clear()
108113
clearAnswer()
109114
ans = ""
@@ -116,7 +121,7 @@ class ExamTakingFragment : BaseExamFragment(), View.OnClickListener, CompoundBut
116121
val newSub = submissionsRepository.createExamSubmission(
117122
user?.id, user?.dob, user?.gender, currentExam, type, if (isTeam) teamId else null
118123
)
119-
withContext(Dispatchers.Main) {
124+
withContext(dispatcherProvider.main) {
120125
sub = newSub
121126
startExam(questions?.get(currentIndex))
122127
updateNavButtons()
@@ -142,7 +147,9 @@ class ExamTakingFragment : BaseExamFragment(), View.OnClickListener, CompoundBut
142147
Snackbar.make(binding.tvQuestionCount, R.string.no_questions_available, Snackbar.LENGTH_LONG).show()
143148
}
144149
}
150+
}
145151

152+
private fun setupListeners() {
146153
binding.btnBack.setOnClickListener {
147154
saveCurrentAnswer()
148155
lifecycleScope.launch {

0 commit comments

Comments
 (0)