How to Build an MVI Clean Code Weather App in Android Studio (Jetpack Compose)

How to Build an MVI Clean Code Weather App in Android Studio (Jetpack Compose)

Philipp Lackner

2 года назад

117,082 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Roman Semenyshyn
Roman Semenyshyn - 07.10.2023 21:06

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

Ответить
batya3000
batya3000 - 11.08.2023 14:41

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

Ответить
Life OF Moments
Life OF Moments - 07.08.2023 21:46

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

Ответить
Rutvik Nabhoya
Rutvik Nabhoya - 21.07.2023 08:34

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

Ответить
Karan S
Karan S - 11.07.2023 18:28

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

Ответить
Zeeshan Syed
Zeeshan Syed - 10.07.2023 17:19

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

Ответить
Андрей Полтев
Андрей Полтев - 20.05.2023 15:09

"REFRESH" button is needed in this app.

Ответить
Android Development — Frank GP
Android Development — Frank GP - 07.05.2023 04:42

excellent exercise

Ответить
Zynastor
Zynastor - 03.05.2023 15:35

Thank you very much!

Ответить
Sheikh Chilli
Sheikh Chilli - 07.04.2023 07:25

Why we are using try, catch in weatherRepositoryImpl get WeatherData method? Because if the problem occurs because of toWeatherInfo() the error will be catches we will not aware of this issue. Is it possible to avoid using try, catch maximum?

Ответить
Simone Klinkon
Simone Klinkon - 03.03.2023 02:39

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

Ответить
Юлія Ліщук
Юлія Ліщук - 14.02.2023 14:19

Thanks so much for tutorial ❤

To simplify mapping toWeatherDataMap() and to avoid IndexedWeatherData class, we can use function:

private fun daysBetweenDateAndNow(dateTime: LocalDateTime): Int {
val dateStartOfDay = dateTime.toLocalDate().atStartOfDay()
val nowStartOfDay = LocalDate.now().atStartOfDay()
return Duration.between(nowStartOfDay, dateStartOfDay).toDays().toInt()
}


And then use it when grouping WeatherData objects

fun WeatherDataDto.toWeatherDataMap(): Map<Int, List<WeatherData>> {
return time.mapIndexed { index, time ->
val temperature = temperatures[index]
val weatherCode = weatherCodes[index]
val windSpeed = windSpeeds[index]
val pressure = pressures[index]
val humidity = humidities[index]
WeatherData(
time = LocalDateTime.parse(time, DateTimeFormatter.ISO_DATE_TIME),
temperatureCelsius = temperature,
pressure = pressure,
windSpeed = windSpeed,
humidity = humidity,
weatherType = WeatherType.fromWMO(weatherCode)
)
}.groupBy {
daysBetweenDateAndNow(it.time)
}

}

Ответить
AnB
AnB - 12.02.2023 06:29

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

Ответить
Vivek Agarwal
Vivek Agarwal - 10.02.2023 14:51

Thanks for the great tutorial!!!!

Ответить
Denny Kluge
Denny Kluge - 10.02.2023 10:51

First of all, I really like your tutorials. They have an awesome quality, a very concise approach and they are very good to follow along.

One wish though: I am a big fan of TDD. And it would be much easier to understand if you would create some simple unit tests along the way so we can actually see what all the helper functions, like "WeatherDataDto.toWeatherDataMap()", are doing. Just a suggestion :)

Ответить
Nat Serrano
Nat Serrano - 07.02.2023 07:10

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

Ответить
Damask
Damask - 06.02.2023 00:38

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

Ответить
Andrii Solomonov
Andrii Solomonov - 04.02.2023 12:33

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.

Ответить
Sheckl3r
Sheckl3r - 01.02.2023 14:15

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.

Ответить
Steve说
Steve说 - 31.01.2023 01:33

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

Ответить
sarah mohamed
sarah mohamed - 29.01.2023 01:21

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

Ответить
Tuấn nguyễn
Tuấn nguyễn - 07.01.2023 23:52

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

Ответить
Jakub Šlechta
Jakub Šlechta - 23.12.2022 01:25

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

Ответить
Juan Pablo Uriol Balbín
Juan Pablo Uriol Balbín - 15.12.2022 13:11

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

Ответить
noMugop
noMugop - 31.10.2022 09:41

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

Ответить
Dale King
Dale King - 08.10.2022 16:50

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.

Ответить
venkata anantha kiran kona
venkata anantha kiran kona - 25.09.2022 01:22

Bro you are beast raaaaar

Ответить
calvin karanja
calvin karanja - 21.09.2022 15:00

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

Ответить
sigjakutube
sigjakutube - 17.09.2022 14:24

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

Ответить
Ashish Kumar
Ashish Kumar - 07.09.2022 03:09

This really helped thanks a lot!

Ответить
asad qasim
asad qasim - 03.09.2022 22:50

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

Ответить
Sean Thomas
Sean Thomas - 24.08.2022 22:45

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.

Ответить
Barry Fensom
Barry Fensom - 15.08.2022 11:29

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

Ответить
James Bond
James Bond - 14.08.2022 09:49

finally after two weeks finished this video.

Ответить
Rohit Sardana
Rohit Sardana - 07.08.2022 08:30

3 times did not start, but then it worked

Ответить
Shivansh Grover
Shivansh Grover - 06.08.2022 16:49

Do you have any Mac version?

Ответить
Zaccharie Bouvy
Zaccharie Bouvy - 05.08.2022 12:25

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

Ответить
Eric Gacoki
Eric Gacoki - 03.08.2022 04:33

That mapper logic was legendary 😅

Ответить
Dede Iman Saputra
Dede Iman Saputra - 30.07.2022 18:50

Nice tutorial, I'll test it right now!

Ответить
Matiplayer
Matiplayer - 24.07.2022 17:47

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)

Ответить
samdroid37
samdroid37 - 14.07.2022 01:22

thank you! you rule!!!

Ответить
Alon Shlider
Alon Shlider - 13.07.2022 12:34

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

Ответить
Franky Junior
Franky Junior - 13.07.2022 12:10

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

Ответить