Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix showing 'null' decimals on token details #116

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,8 @@ object CurrencyUtil {
return strBuilder.toString().removeSuffix(separator.toString())
}

fun toGTUValue(stringValue: String, token: Token?): BigInteger? {
var decimals = 0
token?.let {
it.metadata?.decimals?.let { tokenDecimals ->
decimals = tokenDecimals
}
}
return toGTUValue(stringValue, decimals)
}
fun toGTUValue(stringValue: String, token: Token?): BigInteger? =
toGTUValue(stringValue, token?.decimals ?: 0)

fun toGTUValue(stringValue: String, decimals: Int = 6): BigInteger? {
var str = stringValue.replace("Ͼ", "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class TokenDetailsActivity : BaseActivity(R.layout.activity_token_details) {
setOwnership(token, tokenMetadata)
setDescription(tokenMetadata)
setTicker(tokenMetadata)
setDecimals(tokenMetadata)
setDecimals(token)
}
if (token.isNewlyReceived) {
handleNewlyReceivedToken(token)
Expand Down Expand Up @@ -222,10 +222,10 @@ class TokenDetailsActivity : BaseActivity(R.layout.activity_token_details) {
}
}

private fun setDecimals(tokenMetadata: TokenMetadata) {
if (tokenMetadata.unique != true) {
private fun setDecimals(token: Token) {
if (!token.isUnique) {
binding.includeAbout.decimalsHolder.visibility = View.VISIBLE
binding.includeAbout.decimals.text = tokenMetadata.decimals.toString()
binding.includeAbout.decimals.text = token.decimals.toString()
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class ManageTokensSelectionAdapter(
val tokenBalance = CurrencyUtil.formatGTU(
token.balance,
false,
token.metadata?.decimals ?: 0
token.decimals
)
holder.binding.subtitle.text =
context.getString(R.string.cis_search_balance, tokenBalance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class ManageTokensTokenDetailsFragment : Fragment() {
setImage(tokenMetadata)
setDescription(tokenMetadata)
setTicker(tokenMetadata)
setDecimals(tokenMetadata)
setDecimals(token)
}
}
}
Expand Down Expand Up @@ -125,10 +125,10 @@ class ManageTokensTokenDetailsFragment : Fragment() {
}
}

private fun setDecimals(tokenMetadata: TokenMetadata) {
if (tokenMetadata.unique != true) {
private fun setDecimals(token: Token) {
if (!token.isUnique) {
binding.details.decimalsHolder.visibility = View.VISIBLE
binding.details.decimals.text = tokenMetadata.decimals.toString()
binding.details.decimals.text = token.decimals.toString()
}
}
}