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

Forecast: App closes when click on weekly calendar #49

Open joseluisq opened 2 years ago

joseluisq commented 2 years ago

Version: 1.0 Steps to reproduce:

  1. Install the app and open it, then click on bottom menu called Forecast
  2. Now click on whatever day of the top weekly calendar.
  3. The app closes itself.
Kenny50 commented 1 year ago

@mayokunadeniyi

This issue caused by date format, date string will format to Locale.getDefault() before save into db, but the parsing after reading id Locale.ENGLISH, changing the parsing after reading will cause error if user change system language

I came up with following solution,

  1. Save clean date format, then parse it after read it from db
    • demo
    • This require update code in multiple place, including test and db migration.
    • update -- fromDtoToVo() will be better to this fun WeatherForecast.fromDtoToVo() = this.copy( date = date.formatDate())
  2. Force user save date string in Locale.English.
    • still require db migration.