do not show opening hours if they are not available

This commit is contained in:
johan12345
2020-05-27 20:14:49 +02:00
parent 69ccc55ad4
commit 0cdb12711d
2 changed files with 5 additions and 3 deletions

View File

@@ -114,7 +114,7 @@ fun buildDetails(loc: ChargeLocation?, ctx: Context): List<DetailAdapter.Detail>
loc.network
) else null,
// TODO: separate layout for opening hours with expandable details
if (loc.openinghours != null) DetailAdapter.Detail(
if (loc.openinghours != null && !loc.openinghours.isEmpty) DetailAdapter.Detail(
R.drawable.ic_hours,
R.string.hours,
loc.openinghours.getStatusText(ctx),

View File

@@ -107,6 +107,10 @@ data class OpeningHours(
@JsonObjectOrFalse val description: String?,
@Embedded val days: OpeningHoursDays?
) {
val isEmpty: Boolean
get() = description == "Leider noch keine Informationen zu Öffnungszeiten vorhanden."
&& days == null && !twentyfourSeven
fun getStatusText(ctx: Context): CharSequence {
if (twentyfourSeven) {
return HtmlCompat.fromHtml(ctx.getString(R.string.open_247), 0)
@@ -134,8 +138,6 @@ data class OpeningHours(
), 0
)
}
} else if (description != null) {
return description
} else {
return ""
}