forked from github/szkolny
[Grades] Disable counting grade value when custom values not specified.
This commit is contained in:
parent
715f536b23
commit
e05b483f5c
@ -40,7 +40,7 @@ class GradesManager(val app: App) : CoroutineScope {
|
|||||||
override val coroutineContext: CoroutineContext
|
override val coroutineContext: CoroutineContext
|
||||||
get() = job + Dispatchers.Default
|
get() = job + Dispatchers.Default
|
||||||
|
|
||||||
private val gradeRegex by lazy { """([0-6])([+-])?""".toRegex() }
|
private val gradeRegex by lazy { """([+-])?([0-6])([+-])?""".toRegex() }
|
||||||
private val format = DecimalFormat("#.##")
|
private val format = DecimalFormat("#.##")
|
||||||
|
|
||||||
val orderBy
|
val orderBy
|
||||||
@ -85,12 +85,16 @@ class GradesManager(val app: App) : CoroutineScope {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getGradeValue(grade: Grade): Float {
|
fun getGradeValue(grade: Grade): Float {
|
||||||
gradeRegex.find(grade.name)?.let {
|
if (plusValue == null && minusValue == null)
|
||||||
var value = it[1].toFloatOrNull() ?: return grade.value
|
return grade.value
|
||||||
if (it[2] == "+")
|
|
||||||
value += plusValue ?: return grade.value
|
gradeRegex.find(grade.name)?.let { it ->
|
||||||
if (it[2] == "-")
|
var value = it[2].toFloatOrNull() ?: return grade.value
|
||||||
value -= minusValue ?: return grade.value
|
when (it[1].notEmptyOrNull() ?: it[3]) {
|
||||||
|
"+" -> value += plusValue ?: return grade.value
|
||||||
|
"-" -> value -= minusValue ?: return grade.value
|
||||||
|
else -> return grade.value
|
||||||
|
}
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
return grade.value
|
return grade.value
|
||||||
|
Loading…
x
Reference in New Issue
Block a user