2023-04-08 11:41:02 +02:00
|
|
|
package com.denizk0461.studip.data
|
|
|
|
|
|
2023-04-25 15:38:30 +02:00
|
|
|
import android.content.res.Resources
|
|
|
|
|
import android.util.TypedValue
|
|
|
|
|
import androidx.annotation.AttrRes
|
|
|
|
|
import com.denizk0461.studip.R
|
|
|
|
|
|
2023-04-23 11:57:03 +02:00
|
|
|
/**
|
|
|
|
|
* Miscellaneous functions and variables that don't belong into any specific class.
|
|
|
|
|
*/
|
2023-04-24 15:43:42 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Converts a time stamp string to its numeric value in minutes.
|
|
|
|
|
* Example: 13:20. (20 minutes) + (13 hours * 60 minutes) = 800 minutes.
|
|
|
|
|
*
|
|
|
|
|
* @return minute value of the string
|
|
|
|
|
*/
|
|
|
|
|
fun String.parseToMinutes(): Int {
|
|
|
|
|
val parts = split(":")
|
|
|
|
|
return (parts[0].toInt() * 60) + parts[1].toInt()
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-25 15:38:30 +02:00
|
|
|
/**
|
|
|
|
|
* Retrieves a specified colour customised to the currently applied theme.
|
|
|
|
|
*
|
|
|
|
|
* @param id attribute ID of the colour reference
|
|
|
|
|
* @return resolved colour
|
|
|
|
|
*/
|
|
|
|
|
fun Resources.Theme.getThemedColor(@AttrRes id: Int): Int = TypedValue().also { value ->
|
|
|
|
|
resolveAttribute(id, value, true)
|
|
|
|
|
}.data
|
|
|
|
|
|
2023-04-12 16:46:38 +02:00
|
|
|
object Misc {
|
2023-04-08 11:41:02 +02:00
|
|
|
|
2023-04-23 11:57:03 +02:00
|
|
|
// private val timeslotAcademicQuarter = mapOf(
|
|
|
|
|
// "6:00" to "6:15",
|
|
|
|
|
// "8:00" to "7:45",
|
|
|
|
|
// "8:00" to "8:15",
|
|
|
|
|
// "10:00" to "9:45",
|
|
|
|
|
// "10:00" to "10:15",
|
|
|
|
|
// "12:00" to "11:45",
|
|
|
|
|
// "12:00" to "12:15",
|
|
|
|
|
// "14:00" to "13:45",
|
|
|
|
|
// "14:00" to "14:15",
|
|
|
|
|
// "16:00" to "15:45",
|
|
|
|
|
// "16:00" to "16:15",
|
|
|
|
|
// "18:00" to "17:45",
|
|
|
|
|
// "18:00" to "18:15",
|
|
|
|
|
// "20:00" to "19:45",
|
|
|
|
|
// "20:00" to "20:15",
|
|
|
|
|
// "22:00" to "21:45",
|
|
|
|
|
// )
|
2023-04-08 11:41:02 +02:00
|
|
|
}
|