Skip to content

Commit

Permalink
Fixed the timebox
Browse files Browse the repository at this point in the history
  • Loading branch information
soCallmeAdityaKumar authored and david-allison committed Aug 26, 2024
1 parent 92b4525 commit bc75f07
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions AnkiDroid/src/main/java/com/ichi2/anki/Reviewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ import com.ichi2.utils.tintOverflowMenuIcons
import com.ichi2.utils.title
import com.ichi2.widget.WidgetStatus.updateInBackground
import kotlinx.coroutines.launch
import kotlinx.coroutines.suspendCancellableCoroutine
import timber.log.Timber
import java.io.File
import kotlin.coroutines.resume

@Suppress("LeakingThis")
@KotlinCleanup("too many to count")
Expand Down Expand Up @@ -1082,20 +1084,27 @@ open class Reviewer :
}
}

private fun dealWithTimeBox(timebox: Collection.TimeboxReached) {
private suspend fun dealWithTimeBox(timebox: Collection.TimeboxReached) {
val nCards = timebox.reps
val nMins = timebox.secs / 60
val mins = resources.getQuantityString(R.plurals.in_minutes, nMins, nMins)
val timeboxMessage = resources.getQuantityString(R.plurals.timebox_reached, nCards, nCards, mins)
AlertDialog.Builder(this).show {
title(R.string.timebox_reached_title)
message(text = timeboxMessage)
positiveButton(R.string.dialog_continue) {}
negativeButton(text = CollectionManager.TR.studyingFinish()) {
finish()
}
cancelable(true)
setOnCancelListener { }
suspendCancellableCoroutine { coroutines ->
AlertDialog.Builder(this).show {
title(R.string.timebox_reached_title)
message(text = timeboxMessage)
positiveButton(R.string.dialog_continue) {
coroutines.resume(Unit)
}
negativeButton(text = CollectionManager.TR.studyingFinish()) {
coroutines.resume(Unit)
finish()
}
cancelable(true)
setOnCancelListener {
coroutines.resume(Unit)
}
}
}
}

Expand Down

0 comments on commit bc75f07

Please sign in to comment.