Repository: horizontalsystems/unstoppable-wallet-android
Issue: Send module bugs

Amount input shows small numbers with E letter
After sending money, on dialog open old amount is seen

Changed files:
app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendViewModel.kt, app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendFragment.kt

diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendFragment.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendFragment.kt
index 511d36d82..3d7f17381 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendFragment.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendFragment.kt
@@ -23,6 +23,7 @@ import io.horizontalsystems.bankwallet.R
 import io.horizontalsystems.bankwallet.viewHelpers.HudHelper
 import io.horizontalsystems.bankwallet.viewHelpers.LayoutHelper
 import io.horizontalsystems.bankwallet.viewHelpers.ValueFormatter
+import java.math.BigDecimal
 
 class SendFragment : DialogFragment() {
 
@@ -134,20 +135,20 @@ class SendFragment : DialogFragment() {
         })
 
         viewModel.amountInfoLiveData.observe(this, Observer { amountInfo ->
-            amountInfo?.let {
-                amountPrefixTxt.text = when (it) {
-                    is SendModule.AmountInfo.CoinValueInfo -> it.coinValue.coin
-                    is SendModule.AmountInfo.CurrencyValueInfo -> it.currencyValue.currency.symbol
+            var amountNumber = 0.0
+            when (amountInfo) {
+                is SendModule.AmountInfo.CoinValueInfo -> {
+                    amountPrefixTxt.text = amountInfo.coinValue.coin
+                    amountNumber = Math.round(amountInfo.coinValue.value * 100_000_000.0) / 100_000_000.0
                 }
-
-                val amountNumber = when (it) {
-                    is SendModule.AmountInfo.CoinValueInfo -> it.coinValue.value
-                    is SendModule.AmountInfo.CurrencyValueInfo -> it.currencyValue.value
+                is SendModule.AmountInfo.CurrencyValueInfo -> {
+                    amountPrefixTxt.text = amountInfo.currencyValue.currency.symbol
+                    amountNumber = Math.round(amountInfo.currencyValue.value * 100.0) / 100.0
                 }
+            }
 
-                if (amountNumber > 0) {
-                    amountEditTxt.setText(amountNumber.toString())
-                }
+            if (amountNumber > 0) {
+                amountEditTxt.setText(BigDecimal.valueOf(amountNumber).toPlainString())
             }
         })
 
diff --git a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendViewModel.kt b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendViewModel.kt
index ca1568447..5d4655bf3 100644
--- a/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendViewModel.kt
+++ b/app/src/main/java/io/horizontalsystems/bankwallet/modules/send/SendViewModel.kt
@@ -23,6 +23,17 @@ class SendViewModel : ViewModel(), SendModule.IRouter, SendModule.IView {
     val showConfirmationLiveEvent = SingleLiveEvent<Unit>()
 
     fun init(coin: String) {
+        hintInfoLiveData.value = null
+        sendButtonEnabledLiveData.value = null
+        coinLiveData.value = null
+        amountInfoLiveData.value = null
+        switchButtonEnabledLiveData.value = null
+        addressInfoLiveData.value = null
+        primaryFeeAmountInfoLiveData.value = null
+        secondaryFeeAmountInfoLiveData.value = null
+        errorLiveData.value = null
+        sendConfirmationViewItemLiveData.value = null
+
         SendModule.init(this, this, coin)
         delegate.onViewDidLoad()
     }