Food menu now splits up holiday messages; added documentation

This commit is contained in:
Deniz Düzgören
2019-10-01 10:38:41 +02:00
parent 56c7e8ba53
commit f6283c8221
7 changed files with 83 additions and 53 deletions
@@ -122,9 +122,9 @@ internal class DataFetcher(isPlan: Boolean, isMenu: Boolean, isJobService: Boole
foodRepository.deleteAll()
val indices = ArrayList<Int>()
val daysAndVon = arrayOf("Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "von")
val daysAndVon = arrayOf("montag", "dienstag", "mittwoch", "donnerstag", "freitag", "von", "wünschen")
for (i in 0 until foodElements.size) {
if (HelperFunctions.checkStringForArray(foodElements[i].text(), daysAndVon)) indices.add(i)
if (HelperFunctions.checkStringForArray(foodElements[i].text(), daysAndVon, true)) indices.add(i)
}
indices.add(foodElements.size)
@@ -47,8 +47,8 @@ internal object HelperFunctions {
"lavender", "carnation", "brown2", "pureBlack")
/**
* A list of all phrases used to describe that a course has been cancelled. Expand this
* if necessary. No further code changes required if this is expanded
* A lowercased list of all phrases used to describe that a course has been cancelled. Expand
* this if necessary. No further code changes required if this is expanded
*/
val cancellations = arrayOf("eigenverantwortliches arbeiten", "entfall", "entfällt", "fällt aus", "freisetzung", "vtr. ohne lehrer")
@@ -305,8 +305,9 @@ internal object HelperFunctions {
}
}
fun checkStringForArray(s: String, checking: Array<String>): Boolean {
checking.forEach { check ->
fun checkStringForArray(checkedString: String, checkingArray: Array<String>, lowerCased: Boolean): Boolean {
val s = if (lowerCased) checkedString.toLowerCase(Locale.ROOT) else checkedString
checkingArray.forEach { check ->
if (s.contains(check)) return true
}
return false
@@ -330,7 +331,7 @@ internal object HelperFunctions {
val a = group.substring(0, 2).toInt()
-a
}
checkStringForArray(group.substring(0, 1), juniors) -> -101
checkStringForArray(group.substring(0, 1), juniors, false) -> -101
else -> -100
}
} catch (e: Exception) {
@@ -2,7 +2,7 @@ package com.denizd.substitutionplan.data
/**
* Enum class for declaring Firebase Cloud Messaging topics without using the raw strings
* throughout the project
* throughout the project to avoid human error
*/
internal enum class Topic(val tag: String) {
ANDROID("substitutions-android"),