Simplify / leverage kotlin more

This commit is contained in:
ligi 2016-11-14 20:09:16 +01:00
parent c19357000e
commit a7a42420f8
No known key found for this signature in database
GPG key ID: 8E81894010ABF23D

View file

@ -101,22 +101,17 @@ abstract class PassViewHolder(val view: CardView) : RecyclerView.ViewHolder(view
}
private fun getDateOrExtraText(pass: Pass): ZonedDateTime? {
if (pass.calendarTimespan != null && pass.calendarTimespan!!.from != null) {
return pass.calendarTimespan!!.from
}
if (pass.validTimespans.orEmpty().isNotEmpty()) {
return pass.validTimespans!![0].to
}
return null
private fun getDateOrExtraText(pass: Pass) = when {
pass.calendarTimespan?.from != null -> pass.calendarTimespan!!.from
pass.validTimespans.orEmpty().isNotEmpty() -> pass.validTimespans!![0].to
else -> null
}
@Visibility
protected open fun getVisibilityForGlobalAndLocal(global: Boolean, local: Boolean): Int {
if (global) {
return GONE
}
return if (local) VISIBLE else INVISIBLE
protected open fun getVisibilityForGlobalAndLocal(global: Boolean, local: Boolean) = when {
global -> GONE
local -> VISIBLE
else -> INVISIBLE
}
}