From 0e2d33848b408c05e638723e87d3ea9f5ff6ecec Mon Sep 17 00:00:00 2001 From: Javier Varona Date: Thu, 22 Nov 2018 21:32:04 -0400 Subject: [PATCH] - Now the transactions shows as many decimals as the coin have, only when needed --- .../crystalwallet/views/TransactionViewHolder.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/cy/agorise/crystalwallet/views/TransactionViewHolder.java b/app/src/main/java/cy/agorise/crystalwallet/views/TransactionViewHolder.java index c105f50..4a3a14a 100644 --- a/app/src/main/java/cy/agorise/crystalwallet/views/TransactionViewHolder.java +++ b/app/src/main/java/cy/agorise/crystalwallet/views/TransactionViewHolder.java @@ -10,7 +10,10 @@ import android.view.View; import android.widget.ImageView; import android.widget.TextView; +import org.apache.commons.codec.binary.StringUtils; + import java.text.DateFormat; +import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.TimeZone; @@ -113,7 +116,12 @@ public class TransactionViewHolder extends RecyclerView.ViewHolder { CryptoNetAccountViewModel cryptoNetAccountViewModel = ViewModelProviders.of(this.fragment).get(CryptoNetAccountViewModel.class); cryptoNetAccountViewModel.loadCryptoNetAccount(transaction.getAccountId()); - String amountString = String.format("%.2f",transaction.getAmount()/Math.pow(10,cryptoCurrency.getPrecision())); + String pattern = new String(new char[cryptoCurrency.getPrecision()]).replace('\0', '#'); + pattern = "#."+pattern; + + DecimalFormat df = new DecimalFormat(pattern); + //String amountString = String.format("%.2f",transaction.getAmount()/Math.pow(10,cryptoCurrency.getPrecision())); + String amountString = df.format(transaction.getAmount()/Math.pow(10,cryptoCurrency.getPrecision())); GeneralSettingListViewModel generalSettingListViewModel = ViewModelProviders.of(this.fragment).get(GeneralSettingListViewModel.class); GeneralSetting timeZoneSetting = generalSettingListViewModel.getGeneralSettingByName(GeneralSetting.SETTING_NAME_TIME_ZONE);