Skip to content

Commit

Permalink
Pleasure detekt.
Browse files Browse the repository at this point in the history
  • Loading branch information
mariobodemann committed Jun 25, 2024
1 parent 1572dd1 commit 165c74c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 422 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package de.berlindroid.zeapp.zeservices

import android.content.Context
import android.graphics.Bitmap
import android.util.Log
import dagger.hilt.android.qualifiers.ApplicationContext
import de.berlindroid.zeapp.zeui.pixelBuffer
import de.berlindroid.zekompanion.BadgePayload
Expand All @@ -11,10 +10,10 @@ import de.berlindroid.zekompanion.base64
import de.berlindroid.zekompanion.buildBadgeManager
import de.berlindroid.zekompanion.toBinary
import de.berlindroid.zekompanion.zipit
import javax.inject.Inject
import timber.log.Timber
import javax.inject.Inject

private val SPACE_REPLACEMENT = "\$SPACE#"
private const val SPACE_REPLACEMENT = "\$SPACE#"

class ZeBadgeManager @Inject constructor(
@ApplicationContext private val context: Context,
Expand Down Expand Up @@ -112,9 +111,9 @@ class ZeBadgeManager @Inject constructor(
)
return Result.success(kv)
}
return Result.failure(IllegalStateException())
return Result.failure(IllegalStateException("Could not read response."))
} else {
return Result.failure(NoSuchElementException())
return Result.failure(NoSuchElementException("Sending command failed."))
}
}

Expand Down Expand Up @@ -148,28 +147,28 @@ class ZeBadgeManager @Inject constructor(
) {
return Result.success(true)
} else {
return Result.failure(IllegalStateException())
return Result.failure(IllegalStateException("Could not save the config to ZeBadge."))
}
} else {
return Result.failure(NoSuchElementException())
return Result.failure(NoSuchElementException("Could not update the runtime configuration on ZeBadge."))
}
}

fun isConnected(): Boolean = badgeManager.isConnected()
}

private fun pythonToKotlin(value: String): Any? = when {
value.startsWith("\"") -> {
value.startsWith("\"") ->
value
.replace("\"", "")
.replace(SPACE_REPLACEMENT, " ")
}

value.startsWith("\'") -> {

value.startsWith("\'") ->
value
.replace("\'", "")
.replace(SPACE_REPLACEMENT, " ")
}


value == "None" -> null
value.toIntOrNull() != null -> value.toInt()
Expand Down
Loading

0 comments on commit 165c74c

Please sign in to comment.