kopia lustrzana https://github.com/meshtastic/Meshtastic-Android
refactor: 24H and 48H intervals (#1500)
rodzic
ed45d0ff96
commit
45e50b829a
|
@ -135,9 +135,10 @@ enum class TimeFrame(
|
||||||
*/
|
*/
|
||||||
fun lineInterval(): Long {
|
fun lineInterval(): Long {
|
||||||
return when (this.ordinal) {
|
return when (this.ordinal) {
|
||||||
TWENTY_FOUR_HOURS.ordinal,
|
TWENTY_FOUR_HOURS.ordinal ->
|
||||||
|
TimeUnit.HOURS.toSeconds(6)
|
||||||
FORTY_EIGHT_HOURS.ordinal ->
|
FORTY_EIGHT_HOURS.ordinal ->
|
||||||
TimeUnit.HOURS.toSeconds(1)
|
TimeUnit.HOURS.toSeconds(12)
|
||||||
ONE_WEEK.ordinal,
|
ONE_WEEK.ordinal,
|
||||||
TWO_WEEKS.ordinal ->
|
TWO_WEEKS.ordinal ->
|
||||||
TimeUnit.DAYS.toSeconds(1)
|
TimeUnit.DAYS.toSeconds(1)
|
||||||
|
@ -152,18 +153,7 @@ enum class TimeFrame(
|
||||||
* @param time in seconds
|
* @param time in seconds
|
||||||
*/
|
*/
|
||||||
fun dp(screenWidth: Int, time: Long): Dp {
|
fun dp(screenWidth: Int, time: Long): Dp {
|
||||||
|
val timePerScreen = this.lineInterval()
|
||||||
val timePerScreen = when (this.ordinal) {
|
|
||||||
TWENTY_FOUR_HOURS.ordinal,
|
|
||||||
FORTY_EIGHT_HOURS.ordinal ->
|
|
||||||
TimeUnit.HOURS.toSeconds(1)
|
|
||||||
ONE_WEEK.ordinal,
|
|
||||||
TWO_WEEKS.ordinal ->
|
|
||||||
TimeUnit.DAYS.toSeconds(1)
|
|
||||||
else ->
|
|
||||||
TimeUnit.DAYS.toSeconds(7)
|
|
||||||
}
|
|
||||||
|
|
||||||
val multiplier = time / timePerScreen
|
val multiplier = time / timePerScreen
|
||||||
val dp = (screenWidth * multiplier).toInt().dp
|
val dp = (screenWidth * multiplier).toInt().dp
|
||||||
return dp.takeIf { it != 0.dp } ?: screenWidth.dp
|
return dp.takeIf { it != 0.dp } ?: screenWidth.dp
|
||||||
|
|
Ładowanie…
Reference in New Issue