How to Build an MVI Clean Code Weather App in Android Studio (Jetpack Compose)
Вставка
- Опубліковано 2 лип 2022
- In this video, you'll learn how you can make use of the Open Meteo API to get weather data and nicely display it in an Android app.
Check the API here:
open-meteo.com/en
⭐ Get certificates for your future job
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become an industry-ready Android developer now with this course:
pl-coding.com/premium-courses...
Inspired by this design:
dribbble.com/shots/17998271-C...
Get the initial source code here:
github.com/philipplackner/Wea...
Get the final source code for this video here:
github.com/philipplackner/Wea...
Join my Discord server:
/ discord
Regular programming advice on my Instagram page: / _philipplackner_
Checkout my GitHub: github.com/philipplackner
You like my free content? Here you can buy me a coffee:
www.buymeacoffee.com/philippl...
Little correction for 34:48, you'd actually also need to take care of the case when the time would be 23:50 for example, then you want to take 12am of the next day, not of the current one. Take it as a homework 😂
You are awesome. Thank you
i'm too lazy to do it)
val hour = when {
now.minute < 30 -> now.hour
now.hour == 23 -> 12.00
else -> now.hour + 1
}
Hey man, there is someone making scams using your name, check the comments in this video
val hour = if (now.minute >= 30) now.hour + 1 else now.hour
Philip, today I'll starting doing a lot of your videos and learning Compose. I said this a lot of times here, but, man... You rock!! You are really awesome!! I've been seeing how you're growing as an youtuber. How your videos are getting better quality wise, how you are making funny stories, how you are taking about more hard topics such as SOLID, how you are using new stuff such as Compose... Anyway, you really have an awesome channel and I wish you all best!! You deserve to become a huge channel and I'm looking forward to see that :D
Thanks so much man🙏❤️
The app looks so powerful. Thank you for great videos as always.
thanks philipp, you are my teacher, more project with jetpack compose CRUD with room, restful api, and firebase, please, thanks
I liked the idea of the app and your simple explanation for the concepts, thanks Philipp
Wow really nice walk through. Thanks for taking it every step of the way.
thank you for work Philipp, it's well done as always
currently searching for how to implement location service in jetpack compose and boom saw dis video .. Great video
Hi Philipp,
This tutorial is well made, as a general feedback it would be great if at the end of any video you would add some hints into how you would expand this app.
Thanks a lot for your amazing tutorials
Thanks for the good idea to use copy for the state ! This is what i was looking for.
Thank you for the tutorial ❤️
Nice tutorial, I'll test it right now!
Much needed!
Super cool!😎
This really helped thanks a lot!
Great tutorial!
Nice tutorial , its gives a great overview for how to use MVI architecture with Compose #Clean UI
Thanks for the great tutorial!!!!
My best Android channel..
That mapper logic was legendary 😅
Hey man..in fact we are very lucky to have someone like you in the field of designing Android applications.. .you are a gift sent to us
Can you explain how FCM deals with the API Request and also receiving a real notification from a chat application or something?
finally after two weeks finished this video.
great, as usual !
Thank you very much!
Gr8 my friend thank you a lot
Wunderschön 😃
Good content again!!!. Can you make a video on Firebase Authentication using MVVM clean architecture?
awesome, thanks
Philipp saying 30 degree HOT! meanwhile me chilling in 44 degrees 🥲
Wireless debugging works ok on Electric Eel but if you are using a cable, try a better quality one, even if the cable you're using now seems fine
thank you! you rule!!!
Brilliant
Clean Architecture does seem interesting but agreed with what you said at start that it can be overkill for smaller apps like this (to include Use Cases, etc).
I'm using it for rewriting an old Android app of mine and I'm not even half done and am actually considering starting over and dropping CA or at least neutering it, lmao. The app is so much more complicated now (using Kotlin/Room/Clean Arch, from just Java/Sqlite) and has at least 3-4 times the number of files as the old app and I'm not even half done yet. It's just a super simple mainly data entry and listview type app with a few screens.
Hi Philpp! Why do you build a Resource class instead of using Kotlin's Result class? Thank you for the video
Great vid
lmao code in video is super easy to understand, it better than many project in github
Hi, thanks for the great tutorial.
Will it be possible to make lessons on testing this application ?
Hey Philipp, I thought I will see something new with MVC architecture but there is nothing difference compared to MVVM.. am i missing something or you accidentally mentioned MVC instead of MVVM
excellent exercise
Hey @Philipp Lackner, I watched this video to see how does MVI architecture look like and how does it differ from 'classic' MVVM, but i don't see any differences from other tutorial apps done with MVVM (besides the difference of not using UseCases here)
Could You please clarify or explain what the actual difference is? (since I always assumed that MVI does not use ViewModels but some other classes to resolve UI state control)
same thing, this is not an MVI - no reducers, no stores, maaaybe a single state - WeatherState, but it looks like a MVVM + jetpack compose, which is great, but it's not what the title says - "MVI Clean Code Weather App"
Why MVI doesn't use ViewModels? ViewModel is just one type of controllers with longer lifcycler then fragment or activity. In the MVI architecture, we use an additional State and Event components, wich assumed us more flexible controll on the presentation layer
As stated. This is not MVI. No reducers, Channels, Immutable State and no Intents so how can it be MV(Intent)?
If you try to explain why this is not MVVM+ you will realize it is MVVM+.
Is MVI better suited for Compose (seen many examples) or you just used it for a change since everyone uses MVVM all the time?
Hi @Philipp, the part for getting the location 47:07 in the code for "lastLocation" this shows an error
I checked online and found lastLocation is deprecated, what is the alternative i can add in the code
Hey, thanks for intro. I keep wanting to start using compose but keep staying with xml. Now thinking to start again, however now is a question, what are the recommendations now about all basic dependencies such as navigation.
What a bummer, followed and coded the entire way up to 1:16:16 and the app doesn't work, just tried the source code from master and that one doesn't work either, presumably due to the location code issue that someone else in the comments mentioned was deprecated...
Hello Philip, nice video, can you do a video in compose concerning camerax and mlkit or tensorflow like face detection, enrollment e.t.c Thanks
Hello Philipp !👋
Where u declarate your Intentions??? You have your WeatherState I think that you have a WhatherIntention for example: sealed class WhatherIntention{ object FetchData: MainInten() ... } and cosuming in your viewModelm and cosuming in your viewModel
great tutorial, what theme and font are you using? I can follow without having any knowledge of kotlin but slowly, what course from your portfolio do you recommend me to buy? I'm coming from swift and I have kids so I have limited time to learn, I want to learn fast
Thanks! I'm using xcode dark and source code pro font. All my premium courses are a bit more advanced, but if you already watched and understood videos like these, the multi module course is a good start to get an understanding of Android architecture. Also if you have a swift background you might want to look at the kmm course which teaches how to build ios and Android apps mostly with kotlin (and a bit of swift 😄)
Is it okay that we are using drawable dependency in domain layer WeatherType mode???
Amazing video. Congrats. what yours themes in android studio???
Also want to know🙌
Me: "I will create a simple weather app to learn MVI + Compose, lets see what I can learn from UA-cam"
UA-cam: "Here is a video on how to create a weather app with MVI + Compose"
"It would be cool to know how hot it actually is" - ha-ha, nice!
hey, Philipp!
I'd like to have the same skills to make such a good architecture, but it's difficult to me to figure out why creating so many classes, interfaces is needed
could you advice me some materials, books to get comprehensive understanding of developing clean architecture apps?
thank you in advance
try out Clean Architecture: A Craftsman's Guide to Software Structure and Design
If I am using a graphql backend can I use retrofit or should I use Apollo. I don't really get Apollo. just struggling my way through learning Kotlin and Jetpack Compose and clean architecture. lol
Hi Philip, i hope you are good. Could you please explain how you generated this end-point v1/forecast?hourly=temperature_.............that went to the WeatherAPI
Can you make a followup video on this one adding testing?
can you explain why did you use mvi over mvvm for this specific project?
because our app does not depend on user interactions. İt's only a screen that show some values. So in MVI, we use a single state for each whole screen and it's easy to control cases with single State instead of many states for many ui elements.
Thanks for tutorial. But where is the internets? (You claimed MVI architecture) 😞
Could you quote a source for the pressure, humidity etc icons?
Hi, In case I wanted to fix the position of the app in my town for wwxample, how I can do?
Thank u so much. I've been so confused, but tNice tutorials video helped a lot.
Why you named the class which wrap the API calls responses as "Resource" and not "Result"?
3 times did not start, but then it worked
Can I published app on playstore using free weather api ? but it's mention non commercial use
great video ty
So, MVI is just replacing xml with compose with States?
MVI - Model View Intent
Could anyone explain to me what would be the Intent part here?
my app does load but upon giving location perms it moves to the next screen then crashes ... what could be the problem
At 1:27:13 the app is working but I can't help to wonder why the sun on the emulator is shining at Midnight, which location is this or is it a bug
He takes icons from WeatherType. There are only daytime icons
Let me ask you a question. Do you recommend to an android developer to learn SwiftUI?
hey @@PhilippLackner could you please show newer version of this video because new version of android comes with lots of dagger hilt issue
instead of data class (weatherState) we can use seald class right?.
Nah, not for a screen ui state
will you create a multi-modular app tutorial in the future?
Got a full course already: pl-coding.com/multi-module-course
@@PhilippLackner any plans to make a free one?
@@muhammadsarimmehdi no, that's a huge topic and requires some time to do right. Nothing for UA-cam
5:05 Copying the Github code, cant select Initial from Master drop down.... not sure if thats why my set up isnt working when I add master.... Im just learning this so its probably something stupdi
No big deal alert, but the domain layer should also be free of Android dependencies. So the LocationTracker method shouldn't return an Android Location.
I am pretty sure he mentioned that specifically at: 41:17
Seems cannot get location when API level is 31 or higher.
I'm using that API level
Yes, i am using API level 31 and location is not getting. I debug the code but there is no error showing. Please tell me if anyone knows the solution. Thanks!
hey there! did you find any solution for that i'm using api level 33 and couldn't retrieve location
I have enabled gps and location permission on device still not able to display weather info
same here
If domain layer is innermost layer, where should we place useCases?
They are the part of business logic, but not data.
They belong to domain
I tried running the app but it says " Couldn't retrieve location. Make sure to grant permission and enable GPS"
same issue
Moshi Converter will not throwing any errors for malform response, whta'ts your openiton about it, I would use Kotlin Json Convertor which not clean but usefull
Do you have any Mac version?
I really appreciate your work, You have helped me tremendously in becoming a better developer but you have a problem, you tend to make thing unnecessarily complex. Things which could have been done / written in simpler more readable manner, you tend to make them complex
Well i don't think so, the network objects here are not quite easy to work with and overall Philip processed it quite well.
It says clean code in the title and is obviously intended for more complex apps, where it does make sense.
why in weather repository you return weatherinfo not weatherdto?, only later in use case we should mapping it to weatherinfo
No that's not correct. That way the use case would use a class from the data layer which would be against the principle of the domain layer
@@PhilippLackner but in your tutorial CryptocurrencyAppYT, in data package you just return the dto, then in usecase package you mapping to domain object. which one is correct?
"REFRESH" button is needed in this app.
Hey man ! please set your starting codes on Github as TEMPLATES, so we can easily create a repository equals your
he leaves the starting code in description of every video man, here you go:
Get the initial source code here:
github.com/philipplackner/WeatherApp/tree/initial
Get the final source code for this video here:
github.com/philipplackner/WeatherApp
@@dujemandalinic5468 did you read my comment ? I was referring to the GitHub code you are mentioning...
I was asking for him to set a configuration on the project that make it have a new button right side of "CLONE" in GitHub... a button "TEMPLATE"... when you click this template button, the GitHub copies the repository to your user with all files
@@wagnerarcieri I was too fast to write, should have read it once more. oops.
so we doesnt need return flow when get api?
nah why? It's just one result, not multiple
ok thanks
bm - 15:02 to 36:00
any youtuber as good as this one but code on xcode with swift ?
Why are a lot of programmers from Germany?
and why you don't have a german speaking channel?
how you learned programming in Germany?
...last question...
if I am in Germany and can do some programming, what to do to continue to be a professional programmer?
use english mate come on
Andoird development is over-complicated. I would expect an API call takes one line of code, but it doesn't looks like that.
How do you actually do it in other platform?
@@justmeagain9302 Alamofire for iOS and OkHttpClient for Android. Those are my choices after years of mobile development.
Android development itself isn't that complicated if you get the concept/framework/template. This youtuber did the simple API call in the hard way.
WeatherType violates clean architecture. It is spanning data, domain, and presentation. It knows about the codes from this particular API (data layer) and it contains references to icons (presentation). If you switched to a different service that did not use the same codes that would mean changing domain layer. If you changed the icons used to present the weather type that would also mean changing the domain layer. The weather type in domain should just be an enum or sealed class hierarchy. It should know nothing about codes or icons. The mapping from code should be a function in the data layer that takes a code and returns a weather type. Similarly mapping type to an icon would be a function in presentation.
It's 42 in Iraq 🥵🥵
The Hilt compiler is not able to find a way to provide an instance of the DefaultLocationTracker class. This class is a concrete class, so it does not have an @Inject constructor.
revised code snippet:
class DefaultLocationTracker @Inject constructor(
private val locationClient: FusedLocationProviderClient,
private val application: Application
) : LocationTracker {..}
Thanks Philipp . Guys If you get the following error about "Dagger Hilt" becuase of this "implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha03"" you have to delete it . ERROR : ComponentProcessingStep was unable to process 'com.mehmettekin.shortweatherapp.WeatherApp_HiltComponents.SingletonC' dagger.hilt.android.internal.lifecycle.DefaultActivityViewModelFactory' could not be resolved
thanks a lot. Im in Iran, there's a problem for me when i run the app it says couldn't retrieve the location and in logcat "RKPD failed to provision keyscom.android.rkpdapp.RkpdException: HTTP error status encountered: 400"