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...

КОМЕНТАРІ • 138

  • @PhilippLackner
    @PhilippLackner  2 роки тому +44

    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 😂

    • @devstuff2576
      @devstuff2576 2 роки тому

      You are awesome. Thank you

    • @evgenyplaksin2380
      @evgenyplaksin2380 2 роки тому +2

      i'm too lazy to do it)

    • @ahmedabdelrahman1375
      @ahmedabdelrahman1375 Рік тому +3

      val hour = when {
      now.minute < 30 -> now.hour
      now.hour == 23 -> 12.00
      else -> now.hour + 1
      }

    • @wagnerarcieri
      @wagnerarcieri Рік тому

      Hey man, there is someone making scams using your name, check the comments in this video

    • @mohamadrezamehrjou9553
      @mohamadrezamehrjou9553 2 місяці тому

      val hour = if (now.minute >= 30) now.hour + 1 else now.hour

  • @leonardosibela
    @leonardosibela 2 роки тому +14

    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

  • @MKRN_2024
    @MKRN_2024 2 роки тому +4

    The app looks so powerful. Thank you for great videos as always.

  • @edycole5543
    @edycole5543 2 роки тому +19

    thanks philipp, you are my teacher, more project with jetpack compose CRUD with room, restful api, and firebase, please, thanks

  • @sarahmohamed2973
    @sarahmohamed2973 Рік тому

    I liked the idea of the app and your simple explanation for the concepts, thanks Philipp

  • @benkabore
    @benkabore 6 місяців тому

    Wow really nice walk through. Thanks for taking it every step of the way.

  • @user-eo9gb1qq7n
    @user-eo9gb1qq7n 2 роки тому

    thank you for work Philipp, it's well done as always

  • @softcoder404
    @softcoder404 2 роки тому +3

    currently searching for how to implement location service in jetpack compose and boom saw dis video .. Great video

  • @ZanluSk8
    @ZanluSk8 Рік тому +1

    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.

  • @animekingdom6919
    @animekingdom6919 2 роки тому +3

    Thanks a lot for your amazing tutorials

  • @zacchariebouvy6719
    @zacchariebouvy6719 Рік тому

    Thanks for the good idea to use copy for the state ! This is what i was looking for.

  • @mirchm
    @mirchm 2 роки тому +1

    Thank you for the tutorial ❤️

  • @dedeimansaputra5069
    @dedeimansaputra5069 Рік тому +1

    Nice tutorial, I'll test it right now!

  • @ankitverma3932
    @ankitverma3932 2 роки тому +1

    Much needed!

  • @dev_jeongdaeri
    @dev_jeongdaeri 2 роки тому +2

    Super cool!😎

  • @AshishKumar-dy6sw
    @AshishKumar-dy6sw Рік тому +1

    This really helped thanks a lot!

  • @bhuvaneshwaranm7290
    @bhuvaneshwaranm7290 2 роки тому +1

    Great tutorial!

  • @dipeshsaini04
    @dipeshsaini04 2 роки тому

    Nice tutorial , its gives a great overview for how to use MVI architecture with Compose #Clean UI

  • @vivekagarwal1760
    @vivekagarwal1760 Рік тому

    Thanks for the great tutorial!!!!

  • @hectorvector4887
    @hectorvector4887 2 роки тому

    My best Android channel..

  • @ericgacoki2225
    @ericgacoki2225 Рік тому +1

    That mapper logic was legendary 😅

  • @hossamqandel5638
    @hossamqandel5638 2 роки тому +8

    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?

  • @JamesBond-mq7pd
    @JamesBond-mq7pd Рік тому +2

    finally after two weeks finished this video.

  • @sergeytarasov5041
    @sergeytarasov5041 2 роки тому

    great, as usual !

  • @zynastor1
    @zynastor1 Рік тому +1

    Thank you very much!

  • @miladhashemzadeh5626
    @miladhashemzadeh5626 2 роки тому +1

    Gr8 my friend thank you a lot

  • @samandar7632
    @samandar7632 2 роки тому +1

    Wunderschön 😃

  • @bajrangchapola6748
    @bajrangchapola6748 2 роки тому +1

    Good content again!!!. Can you make a video on Firebase Authentication using MVVM clean architecture?

  • @pumaelgatosiberian5047
    @pumaelgatosiberian5047 2 роки тому

    awesome, thanks

  • @hellosagar
    @hellosagar 2 роки тому +1

    Philipp saying 30 degree HOT! meanwhile me chilling in 44 degrees 🥲

  • @OtarBediashvili
    @OtarBediashvili 2 роки тому +2

    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

  • @samdroid37
    @samdroid37 Рік тому

    thank you! you rule!!!

  • @Alexeytrn
    @Alexeytrn 2 роки тому +1

    Brilliant

  • @clamum9648
    @clamum9648 2 роки тому +9

    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.

  • @juanpablouriolbalbin887
    @juanpablouriolbalbin887 Рік тому +1

    Hi Philpp! Why do you build a Resource class instead of using Kotlin's Result class? Thank you for the video

  • @bboitech8920
    @bboitech8920 2 роки тому

    Great vid

  • @Tuannguyen-bn6sp
    @Tuannguyen-bn6sp Рік тому

    lmao code in video is super easy to understand, it better than many project in github

  • @geekdev0
    @geekdev0 2 роки тому

    Hi, thanks for the great tutorial.
    Will it be possible to make lessons on testing this application ?

  • @Zeeshan-Syed
    @Zeeshan-Syed 11 місяців тому +2

    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

  • @FrankGP.Mobile
    @FrankGP.Mobile Рік тому

    excellent exercise

  • @Matiplayer
    @Matiplayer Рік тому +14

    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)

    • @alexneeky7920
      @alexneeky7920 Рік тому +5

      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"

    • @mark99999ish
      @mark99999ish Рік тому

      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

    • @SiamakAshrafi
      @SiamakAshrafi Рік тому

      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+.

  • @TarunKumar-sq5wj
    @TarunKumar-sq5wj 2 роки тому +14

    Is MVI better suited for Compose (seen many examples) or you just used it for a change since everyone uses MVVM all the time?

  • @alex08585
    @alex08585 Рік тому +2

    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

  • @andriisolomonov7302
    @andriisolomonov7302 Рік тому

    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.

  • @nrg4285
    @nrg4285 Рік тому +4

    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...

  • @emmanuelmtera5936
    @emmanuelmtera5936 2 роки тому

    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

  • @UCdsDlBCBCKMiUUvc8zBWOVQ
    @UCdsDlBCBCKMiUUvc8zBWOVQ Рік тому

    Hello Philipp !👋

  • @pauloCosteira
    @pauloCosteira 2 роки тому +2

    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

  • @nat.serrano
    @nat.serrano Рік тому

    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

    • @PhilippLackner
      @PhilippLackner  Рік тому +1

      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 😄)

  • @batya-im1sc
    @batya-im1sc 10 місяців тому +2

    Is it okay that we are using drawable dependency in domain layer WeatherType mode???

  • @miltonpimentel3769
    @miltonpimentel3769 2 роки тому +1

    Amazing video. Congrats. what yours themes in android studio???

    • @javieer
      @javieer Рік тому

      Also want to know🙌

  • @Daaab89
    @Daaab89 Рік тому +1

    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"

  • @ArthurKhazbs
    @ArthurKhazbs 8 місяців тому

    "It would be cool to know how hot it actually is" - ha-ha, nice!

  • @damask_
    @damask_ Рік тому +2

    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

    • @baderkhaneoussama
      @baderkhaneoussama Рік тому

      try out Clean Architecture: A Craftsman's Guide to Software Structure and Design

  • @fensom80
    @fensom80 Рік тому

    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

  • @claytonmabatlo253
    @claytonmabatlo253 17 днів тому

    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

  • @alonshlider4881
    @alonshlider4881 Рік тому

    Can you make a followup video on this one adding testing?

  • @David-zb8br
    @David-zb8br 2 роки тому +2

    can you explain why did you use mvi over mvvm for this specific project?

    • @sevbanthebuyer
      @sevbanthebuyer Рік тому +1

      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.

  • @romansemenyshyn6052
    @romansemenyshyn6052 8 місяців тому

    Thanks for tutorial. But where is the internets? (You claimed MVI architecture) 😞

  • @sigjakutube
    @sigjakutube Рік тому

    Could you quote a source for the pressure, humidity etc icons?

  • @simoneklinkon3663
    @simoneklinkon3663 Рік тому

    Hi, In case I wanted to fix the position of the app in my town for wwxample, how I can do?

  • @asadqasim8234
    @asadqasim8234 Рік тому +1

    Thank u so much. I've been so confused, but tNice tutorials video helped a lot.

  • @elnatand
    @elnatand 2 роки тому

    Why you named the class which wrap the API calls responses as "Resource" and not "Result"?

  • @rohitsardana6805
    @rohitsardana6805 Рік тому

    3 times did not start, but then it worked

  • @sk-nath
    @sk-nath 10 місяців тому +1

    Can I published app on playstore using free weather api ? but it's mention non commercial use

  • @victorsanchezmula1051
    @victorsanchezmula1051 4 місяці тому

    great video ty

  • @nomugop8017
    @nomugop8017 Рік тому

    So, MVI is just replacing xml with compose with States?

  • @LightBueno
    @LightBueno Рік тому +1

    MVI - Model View Intent
    Could anyone explain to me what would be the Intent part here?

  • @calvinkaranja1306
    @calvinkaranja1306 Рік тому

    my app does load but upon giving location perms it moves to the next screen then crashes ... what could be the problem

  • @tonnie7079
    @tonnie7079 Рік тому +2

    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

    • @Let_it_be
      @Let_it_be Рік тому

      He takes icons from WeatherType. There are only daytime icons

  • @romeobetances7964
    @romeobetances7964 2 роки тому

    Let me ask you a question. Do you recommend to an android developer to learn SwiftUI?

  • @user-lb6rg5cr1t
    @user-lb6rg5cr1t 11 місяців тому +1

    hey @@PhilippLackner could you please show newer version of this video because new version of android comes with lots of dagger hilt issue

  • @nikolozlatsabidze2196
    @nikolozlatsabidze2196 2 роки тому

    instead of data class (weatherState) we can use seald class right?.

  • @muhammadsarimmehdi
    @muhammadsarimmehdi 2 роки тому +1

    will you create a multi-modular app tutorial in the future?

    • @PhilippLackner
      @PhilippLackner  2 роки тому +1

      Got a full course already: pl-coding.com/multi-module-course

    • @muhammadsarimmehdi
      @muhammadsarimmehdi 2 роки тому

      @@PhilippLackner any plans to make a free one?

    • @PhilippLackner
      @PhilippLackner  2 роки тому +2

      @@muhammadsarimmehdi no, that's a huge topic and requires some time to do right. Nothing for UA-cam

  • @DaymnDotEth
    @DaymnDotEth Рік тому

    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

  • @seanthomas9398
    @seanthomas9398 Рік тому +1

    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.

    • @ubersticks
      @ubersticks 11 місяців тому

      I am pretty sure he mentioned that specifically at: 41:17

  • @byran3019
    @byran3019 2 роки тому +2

    Seems cannot get location when API level is 31 or higher.

    • @PhilippLackner
      @PhilippLackner  2 роки тому

      I'm using that API level

    • @alanprajapati8007
      @alanprajapati8007 2 роки тому +1

      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!

    • @ahmedfouda45
      @ahmedfouda45 Рік тому

      hey there! did you find any solution for that i'm using api level 33 and couldn't retrieve location

  • @jasleenchahal8560
    @jasleenchahal8560 2 місяці тому +1

    I have enabled gps and location permission on device still not able to display weather info

  • @maksym6415
    @maksym6415 2 роки тому

    If domain layer is innermost layer, where should we place useCases?
    They are the part of business logic, but not data.

  • @punyani775
    @punyani775 6 місяців тому +1

    I tried running the app but it says " Couldn't retrieve location. Make sure to grant permission and enable GPS"

  • @WansaIndika
    @WansaIndika 7 місяців тому

    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

  • @shivanshgrover6101
    @shivanshgrover6101 Рік тому

    Do you have any Mac version?

  • @anb4351
    @anb4351 Рік тому +2

    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

    • @josephzhou7035
      @josephzhou7035 Рік тому +1

      Well i don't think so, the network objects here are not quite easy to work with and overall Philip processed it quite well.

    • @swish6143
      @swish6143 10 місяців тому

      It says clean code in the title and is obviously intended for more complex apps, where it does make sense.

  • @frankyjunior6005
    @frankyjunior6005 Рік тому

    why in weather repository you return weatherinfo not weatherdto?, only later in use case we should mapping it to weatherinfo

    • @PhilippLackner
      @PhilippLackner  Рік тому +1

      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

    • @frankyjunior6005
      @frankyjunior6005 Рік тому

      @@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?

  • @RoKotEyn
    @RoKotEyn Рік тому

    "REFRESH" button is needed in this app.

  • @wagnerarcieri
    @wagnerarcieri 2 роки тому

    Hey man ! please set your starting codes on Github as TEMPLATES, so we can easily create a repository equals your

    • @dujemandalinic5468
      @dujemandalinic5468 2 роки тому

      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

    • @wagnerarcieri
      @wagnerarcieri 2 роки тому

      @@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

    • @dujemandalinic5468
      @dujemandalinic5468 2 роки тому

      @@wagnerarcieri I was too fast to write, should have read it once more. oops.

  • @ojo_lali_ngaji
    @ojo_lali_ngaji 2 роки тому

    so we doesnt need return flow when get api?

  • @siva_subramaniam
    @siva_subramaniam Рік тому

    bm - 15:02 to 36:00

  • @HugoElcabezas
    @HugoElcabezas 2 роки тому +1

    any youtuber as good as this one but code on xcode with swift ?

  • @AhmadBakdash07
    @AhmadBakdash07 2 роки тому +1

    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?

  • @Steve-sm2mw
    @Steve-sm2mw Рік тому +3

    Andoird development is over-complicated. I would expect an API call takes one line of code, but it doesn't looks like that.

    • @justmeagain9302
      @justmeagain9302 17 днів тому

      How do you actually do it in other platform?

    • @Steve-sm2mw
      @Steve-sm2mw 17 днів тому

      @@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.

  • @DaleKingProfile
    @DaleKingProfile Рік тому +1

    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.

  • @roonyshekho8067
    @roonyshekho8067 2 роки тому

    It's 42 in Iraq 🥵🥵

  • @ksmakan
    @ksmakan 11 місяців тому

    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 {..}

  • @mehmettekin9142
    @mehmettekin9142 Рік тому +1

    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

  • @amirdorri888
    @amirdorri888 4 місяці тому

    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"