From a8fe1ed2c594199c5845099c32e5b0d8f5d0b26e Mon Sep 17 00:00:00 2001 From: Severiano Jaramillo Date: Thu, 31 Jan 2019 19:16:00 -0600 Subject: [PATCH] Make the list of assets in the Balances section to be ordered by asset symbol ignoring the letters case. Show the bit prefix for smartcoins in the Transactions list. --- .../adapters/BalancesAdapter.kt | 2 +- .../adapters/TransfersDetailsAdapter.kt | 8 ++++---- .../database/joins/TransferDetail.kt | 15 +++++++++++---- .../database/joins/TransferDetailDao.kt | 2 +- .../fragments/TransactionsFragment.kt | 2 +- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/BalancesAdapter.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/BalancesAdapter.kt index c2009fd..39a5c0a 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/BalancesAdapter.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/BalancesAdapter.kt @@ -14,7 +14,7 @@ class BalancesAdapter(private val context: Context) : RecyclerView.Adapter() { private val mComparator = - Comparator { a, b -> a.symbol.compareTo(b.symbol) } + Comparator { a, b -> a.toString().compareTo(b.toString(), true) } private val mSortedList = SortedList(BalanceDetail::class.java, object : SortedList.Callback() { diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/TransfersDetailsAdapter.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/TransfersDetailsAdapter.kt index 7d0835a..08b6e6a 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/TransfersDetailsAdapter.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/adapters/TransfersDetailsAdapter.kt @@ -119,13 +119,13 @@ class TransfersDetailsAdapter(private val context: Context) : // Show the crypto amount correctly formatted // TODO lift the DecimalFormat declaration to other place to make things more efficient - val df = DecimalFormat("####."+("#".repeat(transferDetail.cryptoPrecision))) + val df = DecimalFormat("####."+("#".repeat(transferDetail.assetPrecision))) df.roundingMode = RoundingMode.CEILING df.decimalFormatSymbols = DecimalFormatSymbols(Locale.getDefault()) - val amount = transferDetail.cryptoAmount.toDouble() / - Math.pow(10.toDouble(), transferDetail.cryptoPrecision.toDouble()) - val cryptoAmount = "${df.format(amount)} ${transferDetail.cryptoSymbol}" + val amount = transferDetail.assetAmount.toDouble() / + Math.pow(10.toDouble(), transferDetail.assetPrecision.toDouble()) + val cryptoAmount = "${df.format(amount)} ${transferDetail.getUIAssetSymbol()}" viewHolder.tvCryptoAmount.text = cryptoAmount viewHolder.tvFiatEquivalent.text = "-" diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/joins/TransferDetail.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/joins/TransferDetail.kt index f2483fa..19c2d5d 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/joins/TransferDetail.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/joins/TransferDetail.kt @@ -7,9 +7,16 @@ data class TransferDetail( val direction: Boolean, // True -> Received, False -> Sent val memo: String, val date: Long, - val cryptoAmount: Long, - val cryptoPrecision: Int, - val cryptoSymbol: String + val assetAmount: Long, + val assetPrecision: Int, + val assetSymbol: String, + val assetIssuer: String // val fiatAmount: Long, // val fiatCurrency: String -) \ No newline at end of file +) { + fun getUIAssetSymbol(): String { + if (assetIssuer == "1.2.0") + return "bit$assetSymbol" + return assetSymbol + } +} \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/joins/TransferDetailDao.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/joins/TransferDetailDao.kt index f33c365..f614b29 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/database/joins/TransferDetailDao.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/database/joins/TransferDetailDao.kt @@ -7,6 +7,6 @@ import androidx.room.Query @Dao interface TransferDetailDao { - @Query("SELECT transfers.id, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.source) AS `from`, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.destination) AS `to`, (CASE WHEN destination=:userId THEN 1 ELSE 0 END) AS `direction`, transfers.memo AS `memo`, transfers.timestamp AS `date`, transfers.transfer_amount AS `cryptoAmount`, assets.precision AS `cryptoPrecision`, assets.symbol AS cryptoSymbol FROM transfers INNER JOIN assets WHERE transfers.transfer_asset_id = assets.id") + @Query("SELECT transfers.id, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.source) AS `from`, (SELECT name FROM user_accounts WHERE user_accounts.id=transfers.destination) AS `to`, (CASE WHEN destination=:userId THEN 1 ELSE 0 END) AS `direction`, transfers.memo AS `memo`, transfers.timestamp AS `date`, transfers.transfer_amount AS `assetAmount`, assets.precision AS `assetPrecision`, assets.symbol AS `assetSymbol`, assets.issuer as `assetIssuer` FROM transfers INNER JOIN assets WHERE transfers.transfer_asset_id = assets.id") fun getAll(userId: String): LiveData> } \ No newline at end of file diff --git a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt index 3f5ccb0..890b772 100644 --- a/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt +++ b/app/src/main/java/cy/agorise/bitsybitshareswallet/fragments/TransactionsFragment.kt @@ -162,7 +162,7 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele continue // Filter by asset - if (!filterAssetAll && transferDetail.cryptoSymbol != filterAsset) + if (!filterAssetAll && transferDetail.assetSymbol != filterAsset) continue // // Filter by fiat amount