diff --git a/app/src/main/java/com/geeksville/mesh/MainActivity.kt b/app/src/main/java/com/geeksville/mesh/MainActivity.kt index 89bd53f64..54c51bc65 100644 --- a/app/src/main/java/com/geeksville/mesh/MainActivity.kt +++ b/app/src/main/java/com/geeksville/mesh/MainActivity.kt @@ -160,10 +160,7 @@ class MainActivity : AppCompatActivity(), Logging { private val tabsAdapter = object : FragmentStateAdapter(supportFragmentManager, lifecycle) { override fun getItemCount(): Int = tabInfos.size - - override fun createFragment(position: Int): Fragment { - return tabInfos[position].content - } + override fun createFragment(position: Int): Fragment = tabInfos[position].content } private val isInTestLab: Boolean by lazy { @@ -217,20 +214,12 @@ class MainActivity : AppCompatActivity(), Logging { } private fun updateConnectionStatusImage(connected: MeshService.ConnectionState) { - - if (model.actionBarMenu == null) - return + if (model.actionBarMenu == null) return val (image, tooltip) = when (connected) { - MeshService.ConnectionState.CONNECTED -> Pair(R.drawable.cloud_on, R.string.connected) - MeshService.ConnectionState.DEVICE_SLEEP -> Pair( - R.drawable.ic_twotone_cloud_upload_24, - R.string.device_sleeping - ) - MeshService.ConnectionState.DISCONNECTED -> Pair( - R.drawable.cloud_off, - R.string.disconnected - ) + MeshService.ConnectionState.CONNECTED -> R.drawable.cloud_on to R.string.connected + MeshService.ConnectionState.DEVICE_SLEEP -> R.drawable.ic_twotone_cloud_upload_24 to R.string.device_sleeping + MeshService.ConnectionState.DISCONNECTED -> R.drawable.cloud_off to R.string.disconnected } val item = model.actionBarMenu?.findItem(R.id.connectStatusImage) diff --git a/app/src/main/java/com/geeksville/mesh/NodeInfo.kt b/app/src/main/java/com/geeksville/mesh/NodeInfo.kt index 4b147321e..49fdc2d82 100644 --- a/app/src/main/java/com/geeksville/mesh/NodeInfo.kt +++ b/app/src/main/java/com/geeksville/mesh/NodeInfo.kt @@ -164,7 +164,7 @@ data class NodeInfo( val g = (num and 0x00FF00) shr 8 val b = num and 0x0000FF val brightness = ((r * 0.299) + (g * 0.587) + (b * 0.114)) / 255 - return Pair(if (brightness > 0.5) Color.BLACK else Color.WHITE, Color.rgb(r, g, b)) + return (if (brightness > 0.5) Color.BLACK else Color.WHITE) to Color.rgb(r, g, b) } val batteryLevel get() = deviceMetrics?.batteryLevel diff --git a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt index 8eae84b7b..4e8410f67 100644 --- a/app/src/main/java/com/geeksville/mesh/service/MeshService.kt +++ b/app/src/main/java/com/geeksville/mesh/service/MeshService.kt @@ -330,11 +330,10 @@ class MeshService : Service(), Logging { myNodeInfo = ni // put our node array into our two different map representations - nodeDBbyNodeNum.putAll(nodes.map { Pair(it.num, it) }) + nodeDBbyNodeNum.putAll(nodes.map { it.num to it }) nodeDBbyID.putAll(nodes.mapNotNull { - it.user?.let { user -> // ignore records that don't have a valid user - Pair(user.id, it) - } + // ignore records that don't have a valid user + it.user?.let { user -> user.id to it } }) } diff --git a/app/src/main/java/com/geeksville/mesh/ui/UsersFragment.kt b/app/src/main/java/com/geeksville/mesh/ui/UsersFragment.kt index a7fd0ae3a..faab5da07 100644 --- a/app/src/main/java/com/geeksville/mesh/ui/UsersFragment.kt +++ b/app/src/main/java/com/geeksville/mesh/ui/UsersFragment.kt @@ -254,12 +254,9 @@ class UsersFragment : ScreenFragment("Users"), Logging { ) { val (image, text) = when (battery) { - in 0..100 -> Pair( - R.drawable.ic_battery_full_24, - "%d%% %.2fV".format(battery, voltage ?: 0) - ) - 101 -> Pair(R.drawable.ic_power_plug_24, "") - else -> Pair(R.drawable.ic_battery_full_24, "?") + in 0..100 -> R.drawable.ic_battery_full_24 to "%d%% %.2fV".format(battery, voltage) + 101 -> R.drawable.ic_power_plug_24 to "" + else -> R.drawable.ic_battery_full_24 to "?" } holder.batteryPctView.text = text