Replacing error prone takeIf structure
This commit is contained in:
parent
7be958e6a5
commit
7ce56ced4d
|
@ -162,9 +162,8 @@ class SessionInfoView @JvmOverloads constructor(
|
||||||
drawableProvider: DrawableProvider,
|
drawableProvider: DrawableProvider,
|
||||||
colorProvider: ColorProvider,
|
colorProvider: ColorProvider,
|
||||||
) {
|
) {
|
||||||
deviceInfo.lastSeenTs
|
if (deviceInfo.lastSeenTs != null && isLastSeenDetailsVisible) {
|
||||||
?.takeIf { isLastSeenDetailsVisible }
|
val timestamp = deviceInfo.lastSeenTs
|
||||||
?.let { timestamp ->
|
|
||||||
views.sessionInfoLastActivityTextView.isVisible = true
|
views.sessionInfoLastActivityTextView.isVisible = true
|
||||||
views.sessionInfoLastActivityTextView.text = if (isInactive) {
|
views.sessionInfoLastActivityTextView.text = if (isInactive) {
|
||||||
val formattedTs = dateFormatter.format(timestamp, DateFormatKind.TIMELINE_DAY_DIVIDER)
|
val formattedTs = dateFormatter.format(timestamp, DateFormatKind.TIMELINE_DAY_DIVIDER)
|
||||||
|
@ -185,11 +184,9 @@ class SessionInfoView @JvmOverloads constructor(
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
views.sessionInfoLastActivityTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
|
views.sessionInfoLastActivityTextView.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null)
|
||||||
}
|
} else {
|
||||||
?: run {
|
|
||||||
views.sessionInfoLastActivityTextView.isGone = true
|
views.sessionInfoLastActivityTextView.isGone = true
|
||||||
}
|
}
|
||||||
|
|
||||||
views.sessionInfoLastIPAddressTextView.setTextOrHide(deviceInfo.lastSeenIp?.takeIf { isLastSeenDetailsVisible })
|
views.sessionInfoLastIPAddressTextView.setTextOrHide(deviceInfo.lastSeenIp?.takeIf { isLastSeenDetailsVisible })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue