Implemented null check for cookies to prevent app crash, tweaked HelperFunctions#assignRanking to prepare for future years

This commit is contained in:
Deniz Düzgören
2019-09-27 21:49:39 +02:00
parent 2e4f423586
commit 54acd982dc
7 changed files with 38 additions and 14 deletions
@@ -323,15 +323,15 @@ internal object HelperFunctions {
* @return the ranking as an integer
*/
fun assignRanking(group: String, isPSA: Boolean): Int {
if (isPSA) return -31
if (isPSA) return -102
return try {
when {
checkStringForArray(group.substring(0, 1), juniors) -> -30
group.substring(0, 1) == "1" || group.substring(0, 1) == "2" -> {
val a = group.substring(1, 2).toInt()
a - (a * 2)
group.substring(0, 2).toIntOrNull() != null -> {
val a = group.substring(0, 2).toInt()
-a
}
else -> -29
checkStringForArray(group.substring(0, 1), juniors) -> -101
else -> -100
}
} catch (e: Exception) {
0