Coding Fun Kotlin Android Kotlin: Forecast App 06 – Current Weather View & ViewModel – MVVM Tutorial Course

Android Kotlin: Forecast App 06 – Current Weather View & ViewModel – MVVM Tutorial Course





📗 Get the code from this tutorial 👇👇

We have already created a Retrofit service, WeatherNetworkDataSource as an abstraction on top of that service, local database with entities and DAO using the Room library and lastly a repository to rule them all. So, technically speaking, we currently have the model layer done. What’s missing to have a functioning MVVM application is precisely the ViewModel and the View.

In this part we’re going to…

Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

19 thoughts on “Android Kotlin: Forecast App 06 – Current Weather View & ViewModel – MVVM Tutorial Course”

  1. amit ranjan says:

    @Reso Coder – I am getting the following error :

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.event.amit.kotlindemo/com.event.amit.kotlindemo.MainActivity}: java.lang.RuntimeException: cannot find implementation for com.event.amit.kotlindemo.data.db.ForecastDatabase. ForecastDatabase_Impl does not exist
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2426)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2490)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1354)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5443)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    Caused by: java.lang.RuntimeException: cannot find implementation for com.event.amit.kotlindemo.data.db.ForecastDatabase. ForecastDatabase_Impl does not exist
    at androidx.room.Room.getGeneratedImplementation(Room.java:94)
    at androidx.room.RoomDatabase$Builder.build(RoomDatabase.java:667)
    at com.event.amit.kotlindemo.data.db.ForecastDatabase$Companion.buildDatabase(ForecastDatabase.kt:27)
    at com.event.amit.kotlindemo.data.db.ForecastDatabase$Companion.invoke(ForecastDatabase.kt:21)

  2. octanbf3 says:

    Hey @Reso Coder, you made one mistake, on the ScopedFragment class the job.cancel() should be called before the super.onDestroy()

  3. I have an error java.lang.IllegalStateException: Cannot invoke observe on a background thread

    at androidx.lifecycle.LiveData.assertMainThread(LiveData.java:443)

    at androidx.lifecycle.LiveData.observe(LiveData.java:171)

    at com.robusta.forecastmvvm.ui.weather.current.CurrentWeatherFragment$bindUI$1.invokeSuspend(CurrentWeatherFragment.kt:52)
    plese show what i was wrong?

  4. Gourav Kundu says:

    Can you please describe lazyDeferred function in details and how the coroutine inside it works with the fragment.

  5. Islam shams says:

    also i have error in java.lang.RuntimeException: cannot find implementation for com.developer.shams.forecast.data.db.ForecastDatabase. ForecastDatabase_Impl does not exist
    and i cannot figure what is wrong

  6. Islam shams says:

    could u tell me please what is the importance of "apply plugin: kotlin-kapt"

  7. Ana Polo says:

    Hi, I'm having problems since I get the following error java.lang.RuntimeException: Unable to start activity ComponentInfo {com.resocoder.forecastmvvm / com.novadev.eltiempomvvm.ui.MainActivity}: org.kodein.di.Kodein $ NotFoundException : No binding found for bind <ApixuWeatherApiService> () with? {? }
    I do not understand why the name of your package comes out if you just copy the xml from your code. I did a clean and rebuild but there was no solution. Please can help? Thank you.

  8. giozh says:

    Awesome tutorial as always. I would just know why the ViewModelProvider is not bind as singleton? is because only one fragment will use it so is not necessary a unique instance through the app?

  9. At this point i just leave a like before even watch the video. Very nice insight!

  10. Thanks for your videos and I really appreciate your help .
    When will the next videos arrive ? please 🙂

  11. @resocoder
    Thanks for your awesome videos. We really appreciate your effort in this.
    Finally, I wanted to ask you that at 9:32 you told that we are not going to use GlobalScope.async() instead a local scope, inside lazyDeferred extension function. I guess you forgot to mention it in the video. Can you please guide me in the comments, how to change it to local scope. Thanks

  12. Reso, it is not necessary
    if (it == null) return@Observer

    it is enough
    null checker ?. access
    text_view_current_weather.text = it?.toString()

  13. Hey Matej, great video once again and can't wait for the next one. Have you ever thought about making videos about how you learn all these tricks and styles you use? I feel as though that would be very beneficial to us viewers and help become independent learners. 😃

  14. https://stackoverflow.com/questions/53464190/can-i-always-use-workmanager-instead-of-coroutines
    Reso I think that it would be easier to workmanager instead of coroutines. Could you explain choice?

  15. Ride Share says:

    Sir, when run apps it crashes and show below error in logcat. please help me and adavanced thanks:

    11-25 12:53:23.662 5582-5582/com.simecsystem.weather E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.simecsystem.weather, PID: 5582
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.simecsystem.weather/com.simecsystem.weather.ui.main.MainActivity}: java.lang.RuntimeException: cannot find implementation for com.simecsystem.weather.data.db.ForecastDatabase. ForecastDatabase_Impl does not exist
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)
    at android.app.ActivityThread.-wrap11(ActivityThread.java)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5417)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
    Caused by: java.lang.RuntimeException: cannot find implementation for com.simecsystem.weather.data.db.ForecastDatabase. ForecastDatabase_Impl does not exist
    at androidx.room.Room.getGeneratedImplementation(Room.java:94)
    at androidx.room.RoomDatabase$Builder.build(RoomDatabase.java:667)
    at com.simecsystem.weather.data.db.ForecastDatabase$Companion.buildDatabase(ForecastDatabase.kt:27)
    at com.simecsystem.weather.data.db.ForecastDatabase$Companion.invoke(ForecastDatabase.kt:21)
    at com.simecsystem.weather.ForecastApplication$kodein$1$1.invoke(ForecastApplication.kt:60)
    at com.simecsystem.weather.ForecastApplication$kodein$1$1.invoke(ForecastApplication.kt:22)
    at org.kodein.di.bindings.Singleton$getFactory$1$1$1.invoke(standardBindings.kt:134)
    at org.kodein.di.bindings.SingletonReference.make(references.kt:34)
    at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:134)
    at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:99)
    at org.kodein.di.bindings.MultiItemScopeRegistry.getOrCreate(scopes.kt:62)
    at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:134)
    at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:99)
    at org.kodein.di.KodeinContainer$provider$$inlined$toProvider$1.invoke(curry.kt:14)
    at org.kodein.di.internal.DKodeinBaseImpl.Instance(DKodeinImpl.kt:33)
    at com.simecsystem.weather.ForecastApplication$kodein$1$2.invoke(ForecastApplication.kt:60)
    at com.simecsystem.weather.ForecastApplication$kodein$1$2.invoke(ForecastApplication.kt:22)
    at org.kodein.di.bindings.Singleton$getFactory$1$1$1.invoke(standardBindings.kt:134)
    at org.kodein.di.bindings.SingletonReference.make(references.kt:34)
    at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:134)
    at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:99)
    at org.kodein.di.bindings.MultiItemScopeRegistry.getOrCreate(scopes.kt:62)
    at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:134)
    at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:99)
    at org.kodein.di.KodeinContainer$provider$$inlined$toProvider$1.invoke(curry.kt:14)
    at org.kodein.di.internal.DKodeinBaseImpl.Instance(DKodeinImpl.kt:33)
    at com.simecsystem.weather.ForecastApplication$kodein$1$6.invoke(ForecastApplication.kt:60)
    at com.simecsystem.weather.ForecastApplication$kodein$1$6.invoke(ForecastApplication.kt:22)
    at org.kodein.di.bindings.Singleton$getFactory$1$1$1.invoke(standardBindings.kt:134)
    at org.kodein.di.bindings.SingletonReference.make(references.kt:34)
    at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:134)
    at org.kodein.di.bindings.Singleton$getFactory$1$1.invoke(standardBindings.kt:99)
    at org.kodein.di.bindings.MultiItemScopeRegistry.getOrCreate(scopes.kt:62)
    at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:134)
    at org.kodein.di.bindings.Singleton$getFactory$1.invoke(standardBindings.kt:99)
    at org.kodein.di.K

  16. Expecting this yesterday 😀😉, Have you worked in Nested Recylerciew to maintain selected item and scroll state??

  17. Thanks for this part ❤❤ . Waiting for the next one…..

Leave a Reply

Your email address will not be published. Required fields are marked *