Closed samuelili closed 7 years ago
Hm. I'll take a look. I'm planning on doing a deep dive into this code hopefully this weekend. It's been too long since I've made any updates and there's a handful of issues I need to address (as well as refactor all this old code which to current-me seems to have quite a bit of smell in a few places). I'll be sure this makes my to-do list. Thanks for the report.
It's going to take me a bit longer than anticipated as there's quite a bit here that needs to be cleaned up, but this issue specifically I've already resolved. Hope to have a new version out by the end of the week.
Thanks a lot. Glad to see the project is still being worked on.
Version 2.0 was just released.
This issue is technically 'resolved' in the sense that setCurrency() no longer suffers from this problem because it no longer exists :)
You can now directly set the decimalDigits value used by the formatter by calling setDecimalDigits()
on the CurrencyEditText
object or by setting the decimal_digits
attribute in the XML layout.
Aside from the hint value (which you can set manually), currency was only used for setting the decimal digits value, so exposing the decimal digits value abstracted from the currency class made sense to help hide implementation details. If there's another reason you still want to set the underlying currency class directly, let me know and I'll take a look.
In my application, I need to have the user to be able to input different currencies, not tied to the users locale. If it's possible, I would still like to be able to set the currency with a simple method.
What features that currency provides are you looking for from the module?
Currently, there are only two things we do with a currency object: obtain the default number of decimal places, and set the hint text with the currencys symbol. Both of things are provided via the API already, and maintaining the various states of "did a caller set their own currency" vs us having to make our own just added needless complexity to the library.
perhaps if you can explain your use case in more detail I can understand better, but there's literally nothing we do with currency besides those two things.
I noticed that when calling
setCurrency
, it'll set it back to the default currency. It's becausesetCurrency
callsinit
, which callsinitCurrency
and sets the currency back to the default locale. Basically, trying to set a currency that is not the default currency is impossible because it would set itself back to the default currency. I can't set a locale because I only have a currency.