Created
July 1, 2019 13:06
-
-
Save zamahaka/527aa9b860f7f822eef972a583e355e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun bind(data: ActiveSession) { | |
val device = data.device | |
val deviceStr = device.device.takeIf(String::isNotBlank) | |
val platform = device.platform.takeIf(String::isNotBlank) | |
title = when { | |
deviceStr != null && platform != null -> "$deviceStr, $platform" | |
deviceStr != null && platform == null -> deviceStr | |
deviceStr == null && platform != null -> platform | |
// deviceStr == null && platform == null | |
else -> getString(R.string.unknown) | |
} | |
val browser = device.browser.takeIf(String::isNotBlank) | |
val deviceType = when { | |
device.isRobot -> getString(R.string.robot) | |
device.isPhone -> getString(R.string.phone) | |
device.isDesktop -> getString(R.string.desktop) | |
else -> null // Unknown | |
} | |
subTitle = when { | |
deviceType != null && browser != null -> "$deviceType, $browser" | |
deviceType != null && browser == null -> deviceType | |
deviceType == null && browser != null -> browser | |
// sub == null && browser == null | |
else -> getString(R.string.unknown) | |
} | |
additional = data.device.ipAddress.takeIf(String::isNotBlank) ?: getString(R.string.unknown) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment