Open StainlessStlRat opened 7 years ago
This happens during the "TextChanged" event, the "text" variable is formatted to eliminate the symbols and spaces. But it fails to delete the space at the beginning of the value, in your case "0002".
I decided to create my own class based on CurrencyEditText and added the line:
text = text.replaceAll ("\ s +", "");
and that works.
I also added that line in the "getCurrencyDouble" function because an exception was also presented.
These are my modifications so they can be added to this library:
String text = s.toString();
text = text.replace(groupDivider, '\u0020').replace(monetaryDivider, '\u0020')
.replace(".", "").replace(" ", "")
.replace(currencySymbol, "").trim();
text = text.replaceAll("\\s+", "");
Since this is not being maintained I will fork this and create an independent project.
Hi, Sorry for my late response. I cant reproduce this crash :(
Hi, This is happening on the Android PIE for me 😢
Hi, for me happening only on Android Pie. The edit text insert automatically blank space and .trim or replace not remove this.
Thanks @AmadoMata - this fixes the issue for me :)
java.lang.NumberFormatException: For input string: " 0002" at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1306) at java.lang.Double.parseDouble(Double.java:547) at faranjit.currency.edittext.CurrencyEditText.format(CurrencyEditText.java:192) at faranjit.currency.edittext.CurrencyEditText.access$300(CurrencyEditText.java:22) at faranjit.currency.edittext.CurrencyEditText$1.onTextChanged(CurrencyEditText.java:171) at android.widget.TextView.sendOnTextChanged(TextView.java:8448) at android.widget.TextView.handleTextChanged(TextView.java:8510) at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:10764) at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1208) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:578) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:509) at android.text.SpannableStringBuilder.replace(SpannableStringBuilder.java:508) at android.view.inputmethod.BaseInputConnection.replaceText(BaseInputConnection.java:845) at android.view.inputmethod.BaseInputConnection.commitText(BaseInputConnection.java:198) at com.android.internal.widget.EditableInputConnection.commitText(EditableInputConnection.java:183) at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:345) at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:91) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154)