Тёмный

Simple Guide to Network Caching in Android 

Подписаться
Просмотров 813
% 51

Today I am demonstrating just how simple it can be to cache the network data we receive inside our application for improved performance! This is a shorter video (with a funny moment in the middle) so sit back for a few minutes and gain some knowledge on this extremely powerful + professional tactic.
Don't forget to subscribe and enable notifications to stay up-to-date!
Full playlist here: ru-vid.com/group/PLLgF5xrxeQQ1yTgJKBbEAgsEFAoMV93qS
Source code here: github.com/the-android-factory/SimpleRick
00:00 Intro
1:00 What is caching?
2:11 Cache implementation
=========== Popular Series ===========
Redux e-commerce app: ru-vid.com/group/PLLgF5xrxeQQ2qeszlLJTuL9ZO4bSpngQr
Rick and Morty app: ru-vid.com/group/PLLgF5xrxeQQ01ZWe-5p8_ITUKoPS5c46P
=========== Connect with me ===========
LinkedIn: www.linkedin.com/in/domenic-polidoro-802b72b4/
Instagram: dom_polidoro
Twitter: developer_dom
Tiktok: www.tiktok.com/@building_android

Наука

Опубликовано:

 

14 дек 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 19   
@mahdiporkar236
@mahdiporkar236 6 месяцев назад
simple and straightforward, i love your videos
@TheAndroidFactory
@TheAndroidFactory 6 месяцев назад
Love it! Glad it makes sense :)
@Nixomia
@Nixomia 6 месяцев назад
"You didn't see anything." 😂 no worries it happens to me all the time 😃 can you also "in a future video/project" explain how to integrate Room/Realm as a cache layer and how to sync local saved changes with the server using a Work manager and thank very much for the video 😃
@TheAndroidFactory
@TheAndroidFactory 6 месяцев назад
Ha! I appreciate you watching it through and relating to the moment. I explicitly wanted to leave it in the video and not edit it out to show it's not always perfect the first time! I will need to persist data at some point because I want to build out a "favorites" concept in the app, but I'm not sure I'll go deep into Room for true "offline support". If I do, it will be later in the series for sure and it's a good idea. I'll keep it in mind!
@jam4l
@jam4l 6 месяцев назад
I didn't see that, I swear 😅 As always, Great video 🤩
@TheAndroidFactory
@TheAndroidFactory 6 месяцев назад
HAHAHA come on that was funny. Also a fun moment to work on some editing skills lol I hope the video helped!
@Yusuf-un6md
@Yusuf-un6md 6 месяцев назад
Thanks, I think your videos are underrated
@TheAndroidFactory
@TheAndroidFactory 6 месяцев назад
Appreciate the support. For what it's worth, I agree with you 🫡
@TheAndroidFactory
@TheAndroidFactory 6 месяцев назад
Help me grow by sharing the videos you like with anyone you think would benefit from them!
@RICHARDKOVARLIETZBTW-ye7gu
@RICHARDKOVARLIETZBTW-ye7gu 2 месяца назад
A bit confused. I thought your data would save automatically when clicking on episodes then going back, since you technically didn’t pop the original composable out of your back stack. But maybe that’s just cause I was using rememberSaveable idk.
@TheAndroidFactory
@TheAndroidFactory 2 месяца назад
I think rememberSaveable helps out for configuration changes and such, not if you pop out of a composable and back into it. However, you may be confused because of the LaunchedEffect that runs in the character screen composable. At this point in the code, I was re running a network call every time the composable first comes into view. So, yes, there was data present already because that composable was on the stack, it would redo work when coming back into the foreground. In later episodes, this becomes less of an issue but that is why you may have been confused. All the code is on GitHub if you want to take a look!
@RICHARDKOVARLIETZBTW-ye7gu
@RICHARDKOVARLIETZBTW-ye7gu 2 месяца назад
@@TheAndroidFactoryohh you’re right it is the launched effect. In mine I’ve been using an if conditional in launched effect to not re-fetch when swapping between screens or popping back if there’s no new data. Which probably isn’t the best way lol. I’ve just been doing my school semester project, it came together pretty well so far but definitely messy so I’ve slowly been seeing if I have time to refactor it to use MVVM
@TheAndroidFactory
@TheAndroidFactory 2 месяца назад
@RICHARDKOVARLIETZBTW-ye7gu interesting. Feel free to email me at droidfactory95@gmail.com if you want to chat more. Happy to hop on a call at some point if need be, but I have a reasonable video you should watch if you want to look at MVVM. One second
@TheAndroidFactory
@TheAndroidFactory 2 месяца назад
Take a look at this video here which does a good job at explaining it: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Jfs1FKmxcYc.htmlsi=j7TskltdbbVpMtgD And then this one is also another popular video of mine but a little older at this point: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-DCglGiMI5Ps.htmlsi=tMi3iHGXzS8Imqmg
@yashh2970
@yashh2970 6 месяцев назад
what about pagination stuff caching with hashmap😮
@TheAndroidFactory
@TheAndroidFactory 6 месяцев назад
That can get a little more complicated, but you may want to cache the entire page with something like: var pageCache = mutableMapOf() And the keys are the page indices and the value is the content for that page. Does that help?
@yashh2970
@yashh2970 6 месяцев назад
I tried this one, but it was difficult to manage at times, and I also received duplicate data. If you try once in the series, it would be much beneficial to me. Thank you sir.
@TheAndroidFactory
@TheAndroidFactory 6 месяцев назад
Yeah for sure! We will get to paging when we have to build out the full list of characters, so I can definitely work this in! Sorry it didn't work out for you currently
@yashh2970
@yashh2970 6 месяцев назад
@@TheAndroidFactory Yeahh❤