mayokunadeniyi / Instant-Weather

An Android weather application implemented using the MVVM pattern, Retrofit2, Dagger Hilt, LiveData, ViewModel, Coroutines, Room, Navigation Components, Data Binding and some other libraries from the Android Jetpack.
MIT License
767 stars 165 forks source link

Fix conversion of numbers with decimals #20

Closed murattuzel closed 4 years ago

murattuzel commented 4 years ago

Converting String to Number directly, may cause a problem. format uses default locale value to format. However, toDouble is unaware of what locale is. format might be return a separator with dot or comma depends on locale, explained here. If those do not match, it causes a crash. To reproduce the crash, e.g. Locale.FRANCE can be given as a parameter to format. So I think DecimalFormat should be used for the conversion.

Also congratulations for this great work and thanks for sharing!