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.
This commit is contained in:
parent
b628260d77
commit
a8fe1ed2c5
5 changed files with 18 additions and 11 deletions
|
@ -14,7 +14,7 @@ class BalancesAdapter(private val context: Context) :
|
||||||
RecyclerView.Adapter<BalancesAdapter.ViewHolder>() {
|
RecyclerView.Adapter<BalancesAdapter.ViewHolder>() {
|
||||||
|
|
||||||
private val mComparator =
|
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 =
|
private val mSortedList =
|
||||||
SortedList<BalanceDetail>(BalanceDetail::class.java, object : SortedList.Callback<BalanceDetail>() {
|
SortedList<BalanceDetail>(BalanceDetail::class.java, object : SortedList.Callback<BalanceDetail>() {
|
||||||
|
|
|
@ -119,13 +119,13 @@ class TransfersDetailsAdapter(private val context: Context) :
|
||||||
|
|
||||||
// Show the crypto amount correctly formatted
|
// Show the crypto amount correctly formatted
|
||||||
// TODO lift the DecimalFormat declaration to other place to make things more efficient
|
// 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.roundingMode = RoundingMode.CEILING
|
||||||
df.decimalFormatSymbols = DecimalFormatSymbols(Locale.getDefault())
|
df.decimalFormatSymbols = DecimalFormatSymbols(Locale.getDefault())
|
||||||
|
|
||||||
val amount = transferDetail.cryptoAmount.toDouble() /
|
val amount = transferDetail.assetAmount.toDouble() /
|
||||||
Math.pow(10.toDouble(), transferDetail.cryptoPrecision.toDouble())
|
Math.pow(10.toDouble(), transferDetail.assetPrecision.toDouble())
|
||||||
val cryptoAmount = "${df.format(amount)} ${transferDetail.cryptoSymbol}"
|
val cryptoAmount = "${df.format(amount)} ${transferDetail.getUIAssetSymbol()}"
|
||||||
viewHolder.tvCryptoAmount.text = cryptoAmount
|
viewHolder.tvCryptoAmount.text = cryptoAmount
|
||||||
|
|
||||||
viewHolder.tvFiatEquivalent.text = "-"
|
viewHolder.tvFiatEquivalent.text = "-"
|
||||||
|
|
|
@ -7,9 +7,16 @@ data class TransferDetail(
|
||||||
val direction: Boolean, // True -> Received, False -> Sent
|
val direction: Boolean, // True -> Received, False -> Sent
|
||||||
val memo: String,
|
val memo: String,
|
||||||
val date: Long,
|
val date: Long,
|
||||||
val cryptoAmount: Long,
|
val assetAmount: Long,
|
||||||
val cryptoPrecision: Int,
|
val assetPrecision: Int,
|
||||||
val cryptoSymbol: String
|
val assetSymbol: String,
|
||||||
|
val assetIssuer: String
|
||||||
// val fiatAmount: Long,
|
// val fiatAmount: Long,
|
||||||
// val fiatCurrency: String
|
// val fiatCurrency: String
|
||||||
)
|
) {
|
||||||
|
fun getUIAssetSymbol(): String {
|
||||||
|
if (assetIssuer == "1.2.0")
|
||||||
|
return "bit$assetSymbol"
|
||||||
|
return assetSymbol
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,6 @@ import androidx.room.Query
|
||||||
@Dao
|
@Dao
|
||||||
interface TransferDetailDao {
|
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>>
|
fun getAll(userId: String): LiveData<List<TransferDetail>>
|
||||||
}
|
}
|
|
@ -162,7 +162,7 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
|
||||||
continue
|
continue
|
||||||
|
|
||||||
// Filter by asset
|
// Filter by asset
|
||||||
if (!filterAssetAll && transferDetail.cryptoSymbol != filterAsset)
|
if (!filterAssetAll && transferDetail.assetSymbol != filterAsset)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
// // Filter by fiat amount
|
// // Filter by fiat amount
|
||||||
|
|
Loading…
Reference in a new issue