Updated on 2026-08-14

This commit is contained in:
Tangem 2023-01-18 18:05:18 +08:00
parent e98780ff93
commit 479d142807
283 changed files with 2338 additions and 2730 deletions

View file

@ -24,7 +24,7 @@ fun BigDecimal.toFormattedString(
fun BigDecimal.toFiatString(
rateValue: BigDecimal,
fiatCurrencyName: String,
formatWithSpaces: Boolean = false
formatWithSpaces: Boolean = false,
): String {
val fiatValue = rateValue.multiply(this)
return fiatValue.toFormattedFiatValue(fiatCurrencyName, formatWithSpaces)
@ -32,13 +32,14 @@ fun BigDecimal.toFiatString(
fun BigDecimal.toFormattedFiatValue(
fiatCurrencyName: String,
formatWithSpaces: Boolean = false
formatWithSpaces: Boolean = false,
): String {
val fiatValue = this.setScale(2, RoundingMode.HALF_UP)
.let { if (formatWithSpaces) it.formatWithSpaces() else it }
return "${fiatValue} $fiatCurrencyName"
}
@Suppress("MagicNumber")
fun BigDecimal.formatWithSpaces(): String {
val str = this.toString()
var integerStr = str.substringBefore('.')

View file

@ -9,19 +9,17 @@ import java.util.logging.Logger
/**
[REDACTED_AUTHOR]
*/
class FeatureCoroutineExceptionHandler {
object FeatureCoroutineExceptionHandler {
// add an external logger (FbAnalytics) for handling errors
companion object {
fun create(from: String): CoroutineExceptionHandler = CoroutineExceptionHandler { _, throwable ->
val sw = StringWriter()
throwable.printStackTrace(PrintWriter(sw))
val exceptionAsString: String = sw.toString()
//it delegates logging to android Logger, cause cant use timber in java module
Logger.getLogger("CoroutineExceptHandler").log(
Level.INFO, "CoroutineException: from: $from, exception: $exceptionAsString",
)
throw throwable
}
fun create(from: String): CoroutineExceptionHandler = CoroutineExceptionHandler { _, throwable ->
val sw = StringWriter()
throwable.printStackTrace(PrintWriter(sw))
val exceptionAsString: String = sw.toString()
//it delegates logging to android Logger, cause cant use timber in java module
Logger.getLogger("CoroutineExceptHandler").log(
Level.INFO, "CoroutineException: from: $from, exception: $exceptionAsString",
)
throw throwable
}
}

View file

@ -0,0 +1,28 @@
package com.tangem.utils.detekt
/**
* Annotation for an unused component that should be ignored by Detekt
*
* @property description description of why I shouldn't remove it
*
[REDACTED_AUTHOR]
*/
@Target(
AnnotationTarget.CLASS,
AnnotationTarget.ANNOTATION_CLASS,
AnnotationTarget.TYPE_PARAMETER,
AnnotationTarget.PROPERTY,
AnnotationTarget.FIELD,
AnnotationTarget.LOCAL_VARIABLE,
AnnotationTarget.VALUE_PARAMETER,
AnnotationTarget.CONSTRUCTOR,
AnnotationTarget.FUNCTION,
AnnotationTarget.PROPERTY_GETTER,
AnnotationTarget.PROPERTY_SETTER,
AnnotationTarget.TYPE,
AnnotationTarget.EXPRESSION,
AnnotationTarget.FILE,
AnnotationTarget.TYPEALIAS
)
@Retention(AnnotationRetention.SOURCE)
annotation class UnusedRequiredComponent(val description: String)

View file

@ -12,5 +12,7 @@ import dagger.hilt.components.SingletonComponent
interface CoroutineDispatcherProviderModule {
@Binds
fun bindCoroutineDispatcherProvider(coroutineDispatcherProvider: AppCoroutineDispatcherProvider): CoroutineDispatcherProvider
fun bindCoroutineDispatcherProvider(
coroutineDispatcherProvider: AppCoroutineDispatcherProvider,
): CoroutineDispatcherProvider
}