Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Changes some deprecated functions to new ones
Browse files Browse the repository at this point in the history
  • Loading branch information
mhss1 committed Apr 26, 2022
1 parent 4a7f9c0 commit a02f4ef
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/src/main/java/com/ivy/wallet/utils/UtilExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,24 @@ fun <T> MutableList<T>?.orEmpty(): MutableList<T> {
return this ?: mutableListOf()
}

fun String.nullifyEmpty() = if (this.isBlank()) null else this
fun String.nullifyEmpty() = this.ifBlank { null }

fun getDefaultFIATCurrency(): Currency =
Currency.getInstance(Locale.getDefault()) ?: Currency.getInstance("USD")
?: Currency.getInstance("usd") ?: Currency.getAvailableCurrencies().firstOrNull()
?: Currency.getInstance("EUR")

fun String.toUpperCaseLocal() = this.toUpperCase(Locale.getDefault())
fun String.toUpperCaseLocal() = this.uppercase(Locale.getDefault())

fun String.toLowerCaseLocal() = this.toLowerCase(Locale.getDefault())
fun String.toLowerCaseLocal() = this.lowercase(Locale.getDefault())

fun String.uppercaseLocal(): String = this.toUpperCase(Locale.getDefault())
fun String.uppercaseLocal(): String = this.uppercase(Locale.getDefault())

fun String.capitalizeLocal(): String = this.capitalize(Locale.getDefault())
fun String.capitalizeLocal(): String = this.replaceFirstChar {
if (it.isLowerCase()) it.titlecase(
Locale.getDefault()
) else it.toString()
}

fun String.capitalizeWords(): String {
return split(" ").joinToString(" ") { it.capitalizeLocal() }
Expand Down

0 comments on commit a02f4ef

Please sign in to comment.