Skip to content

Commit

Permalink
Order rise/set by time
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecorry31 committed Jun 6, 2023
1 parent 6b6abfe commit 401b641
Showing 1 changed file with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,21 +72,48 @@ abstract class BaseAstroListItemProducer(protected val context: Context) :
}

protected fun riseSet(rise: ZonedDateTime?, set: ZonedDateTime?): CharSequence {

val setBeforeRise = set != null && rise != null && set.isBefore(rise)

val firstIcon = if (setBeforeRise) {
R.drawable.ic_arrow_down
} else {
R.drawable.ic_arrow_up
}

val firstTime = if (setBeforeRise) {
set
} else {
rise
}

val secondIcon = if (setBeforeRise) {
R.drawable.ic_arrow_up
} else {
R.drawable.ic_arrow_down
}

val secondTime = if (setBeforeRise) {
rise
} else {
set
}

return buildSpannedString {
appendImage(
context,
R.drawable.ic_arrow_up,
firstIcon,
imageSize,
tint = secondaryColor
)
append(" ${time(rise)} ")
append(" ${time(firstTime)} ")
appendImage(
context,
R.drawable.ic_arrow_down,
secondIcon,
imageSize,
tint = secondaryColor
)
append(" ${time(set)}")
append(" ${time(secondTime)}")
}
}

Expand Down

0 comments on commit 401b641

Please sign in to comment.