From c005d93f8c3f8068ee92f4d5a1d7e0e5a5495506 Mon Sep 17 00:00:00 2001 From: Andy Scherzinger Date: Thu, 21 Mar 2024 18:42:28 +0100 Subject: [PATCH] remove magic numbers Signed-off-by: Andy Scherzinger --- .../DomainEnumNotificationLevelConverter.kt | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/models/domain/converters/DomainEnumNotificationLevelConverter.kt b/app/src/main/java/com/nextcloud/talk/models/domain/converters/DomainEnumNotificationLevelConverter.kt index 037add02b..220053878 100644 --- a/app/src/main/java/com/nextcloud/talk/models/domain/converters/DomainEnumNotificationLevelConverter.kt +++ b/app/src/main/java/com/nextcloud/talk/models/domain/converters/DomainEnumNotificationLevelConverter.kt @@ -25,21 +25,28 @@ import com.nextcloud.talk.models.domain.NotificationLevel class DomainEnumNotificationLevelConverter : IntBasedTypeConverter() { override fun getFromInt(i: Int): NotificationLevel { return when (i) { - 0 -> NotificationLevel.DEFAULT - 1 -> NotificationLevel.ALWAYS - 2 -> NotificationLevel.MENTION - 3 -> NotificationLevel.NEVER + DEFAULT -> NotificationLevel.DEFAULT + ALWAYS -> NotificationLevel.ALWAYS + MENTION -> NotificationLevel.MENTION + NEVER -> NotificationLevel.NEVER else -> NotificationLevel.DEFAULT } } override fun convertToInt(`object`: NotificationLevel): Int { return when (`object`) { - NotificationLevel.DEFAULT -> 0 - NotificationLevel.ALWAYS -> 1 - NotificationLevel.MENTION -> 2 - NotificationLevel.NEVER -> 3 - else -> 0 + NotificationLevel.DEFAULT -> DEFAULT + NotificationLevel.ALWAYS -> ALWAYS + NotificationLevel.MENTION -> MENTION + NotificationLevel.NEVER -> NEVER + else -> DEFAULT } } + + companion object { + private const val DEFAULT: Int = 0 + private const val ALWAYS: Int = 1 + private const val MENTION: Int = 2 + private const val NEVER: Int = 3 + } }