From c6c60d9dbd874323133be0ef5b7c009e20b7d097 Mon Sep 17 00:00:00 2001 From: Fabian Wiesel Date: Mon, 26 Feb 2024 19:41:37 +0100 Subject: [PATCH] Move service name to constructor --- .../childmonitor/DiscoverActivity.kt | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/app/src/main/kotlin/de/rochefort/childmonitor/DiscoverActivity.kt b/app/src/main/kotlin/de/rochefort/childmonitor/DiscoverActivity.kt index 0fc5724..b4aae6d 100644 --- a/app/src/main/kotlin/de/rochefort/childmonitor/DiscoverActivity.kt +++ b/app/src/main/kotlin/de/rochefort/childmonitor/DiscoverActivity.kt @@ -219,19 +219,15 @@ internal class ServiceInfoWrapper(private val info: NsdServiceInfo) { get() = info.host.hostAddress val port: Int get() = info.port - val name: String - get() { - // If there is more than one service with the same name on the network, it will - // have a number at the end, but will appear as the following: - // "ChildMonitor\\032(number) - // or - // "ChildMonitor\032(number) - // Replace \\032 and \032 with a " " - var serviceName = info.serviceName - serviceName = serviceName.replace("\\\\032", " ") - serviceName = serviceName.replace("\\032", " ") - return serviceName - } + // If there is more than one service with the same name on the network, it will + // have a number at the end, but will appear as the following: + // "ChildMonitor\\032(number) + // or + // "ChildMonitor\032(number) + // Replace \\032 and \032 with a " " + val name: String = info.serviceName + .replace("\\\\032", " ") + .replace("\\032", " ") override fun toString(): String { return name