When the currency has two symbols (R$, for example, Brazilian Real, (locale is "pt_BR")) and a number is inserted between "R" and "$", a NumberFormatException is thrown. Here is the stack trace:
java.lang.NumberFormatException: For input string: "R2$31000"
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1306)
at java.lang.Double.parseDouble(Double.java:547)
at faranjit.currency.edittext.CurrencyEditText.format(CurrencyEditText.java:190)
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:8226)
at android.widget.TextView.handleTextChanged(TextView.java:8288)
at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:10410)
at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1214)
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.text.method.NumberKeyListener.onKeyDown(NumberKeyListener.java:121)
at android.widget.TextView.doKeyDown(TextView.java:6312)
at android.widget.TextView.onKeyDown(TextView.java:6102)
at android.view.KeyEvent.dispatch(KeyEvent.java:2684)
at android.view.View.dispatchKeyEvent(View.java:9879)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667)
at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:403)
at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1800)
at android.app.Activity.dispatchKeyEvent(Activity.java:3025)
at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:534)
at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:58)
at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:316)
at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:317)
at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4339)
at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4310)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3914)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3880)
at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4007)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3888)
at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4064)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861)
at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3914)
at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3880)
at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3888)
at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861)
at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6257)
at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6196)
at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6157)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3659)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
When the currency has two symbols (R$, for example, Brazilian Real, (locale is "pt_BR")) and a number is inserted between "R" and "$", a NumberFormatException is thrown. Here is the stack trace: java.lang.NumberFormatException: For input string: "R2$31000" at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1306) at java.lang.Double.parseDouble(Double.java:547) at faranjit.currency.edittext.CurrencyEditText.format(CurrencyEditText.java:190) 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:8226) at android.widget.TextView.handleTextChanged(TextView.java:8288) at android.widget.TextView$ChangeWatcher.onTextChanged(TextView.java:10410) at android.text.SpannableStringBuilder.sendTextChanged(SpannableStringBuilder.java:1214) 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.text.method.NumberKeyListener.onKeyDown(NumberKeyListener.java:121) at android.widget.TextView.doKeyDown(TextView.java:6312) at android.widget.TextView.onKeyDown(TextView.java:6102) at android.view.KeyEvent.dispatch(KeyEvent.java:2684) at android.view.View.dispatchKeyEvent(View.java:9879) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667) at android.view.ViewGroup.dispatchKeyEvent(ViewGroup.java:1667) at com.android.internal.policy.DecorView.superDispatchKeyEvent(DecorView.java:403) at com.android.internal.policy.PhoneWindow.superDispatchKeyEvent(PhoneWindow.java:1800) at android.app.Activity.dispatchKeyEvent(Activity.java:3025) at android.support.v7.app.AppCompatActivity.dispatchKeyEvent(AppCompatActivity.java:534) at android.support.v7.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:58) at android.support.v7.app.AppCompatDelegateImplBase$AppCompatWindowCallbackBase.dispatchKeyEvent(AppCompatDelegateImplBase.java:316) at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:317) at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:4339) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4310) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3914) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3880) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4007) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3888) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4064) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3914) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3880) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3888) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3861) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6257) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6196) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6157) at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3659) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6123)