Android Kotlin: Forecast App 09 – Location Infrastructure – MVVM Tutorial Course

In the last episode we’ve created the settings fragment. We’ve already successfully implemented the unit system setting with which a user can switch between metric and imperial values. There are also some settings which we haven’t touched yet, though. Those are related to location.

Location is quite a big topic to deal with. We need to start adding the weather location into the database, incorporate it into the repository, add some code which is actually displaying the location in our view and most importantly, code the business logic of location handling.

These four things are not going to fit into one sensible video and that’s why in this part we’re exclusively going to deal with the database and the underlying interface of our business logic. Then, in the next part we’re actually going to implement the business logic properly.

👉Get the code from this tutorial👈

 

Leave a comment


This site uses Akismet to reduce spam. Learn how your comment data is processed.


Alin

4 weeks ago

Hi Matej

First I would like to thank you for your hard work, I am aware how time consuming is to make video tutorials. Secondly, congratulations for the awesome tutorials. I have been searching a lot after MVVM tutorials and yours are really great.

There are a few things that come in my mind:
1. Do you plan to also implement testing on the Weather MVVM as a tutorial part, since JetPack also now has testing library? Your thoughts on Test Driven Development on android?
2. Dependency Injection was something that I stayed away from. Do you think it makes sense for small projects or simply go with InjectUtils?
3. Most of tutorials I saw were related to Dagger2 and that always felt way to complex for me. Kodein from your explanations looks very promising. Why did you go with it instead of Dagger?
4. Since data binding looks handy in MVVM after playing with it, to me it looks like it makes things more complex. Trying to keep track also of xml file…. seems a bit too complex versus the easy way of using view ids in the Fragment. Indeed, in the old days when you had TextView text = (TextView)findViewById(R.id.text) for each text manually added was not pleasant, but now with kotlin…

Matej Rešetár

4 weeks ago

Hello and thank you, first of all.

Regarding your questions:
1. I didn’t plan to add tests to Forecast MVVM series but since there are so many requests I’m seriously considering to show you how to test at least one class. I didn’t do TDD for this tutorial, although I think it’s really beneficial for any kind of a project. I’m currently making a Flutter app for a tutorial and there I’m doing TDD.

2 & 3. DI is good, use it if you can. Dagger is complex, I didn’t touch it once and I jumped right into Kodein. It’s nice to work with and I don’t see any reason to work with Dagger’s atrocious syntax and rules.

4. You are correct! At first, I intended to use data binding for the Forecast app but it was buggy as all hell. Honestly, I think that data binding makes you learn new things and pull your hair out if it doesn’t work while offering you basically no benefits at all. All you get is a bit less code in your Fragments / Activities. Not worth it IMO.

Happy coding!

Alin

4 weeks ago

Thanks for your quick answer.

So far the tutorial is very precise and interesting. What I am missing so far is the testing implementation, for instance you could show it on the recyclerview screen. Kodein looks easy to use but I am sure it is so because you know what you are doing. I am glad to see coroutines implemented in an actual real-life project.

I saw you had some videos explaining different things, one could be Android Studio plugins you use. For instance the JSON to kotlin classes is cool and I did not knew about it.

Keep up the good work.

Development made simple

We're here to help you. If you have any questions, let us know.

Copyright 2017 - 2018 Reso Coder © All Rights Reserved