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.

master
Severiano Jaramillo 2019-01-31 19:16:00 -06:00
parent b628260d77
commit a8fe1ed2c5
5 changed files with 18 additions and 11 deletions

View File

@ -14,7 +14,7 @@ class BalancesAdapter(private val context: Context) :
RecyclerView.Adapter<BalancesAdapter.ViewHolder>() {
private val mComparator =
Comparator<BalanceDetail> { a, b -> a.symbol.compareTo(b.symbol) }
Comparator<BalanceDetail> { a, b -> a.toString().compareTo(b.toString(), true) }
private val mSortedList =
SortedList<BalanceDetail>(BalanceDetail::class.java, object : SortedList.Callback<BalanceDetail>() {

View File

@ -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 = "-"

View File

@ -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
)
) {
fun getUIAssetSymbol(): String {
if (assetIssuer == "1.2.0")
return "bit$assetSymbol"
return assetSymbol
}
}

View File

@ -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<List<TransferDetail>>
}

View File

@ -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