You can make few optimizations : 1. Optimize the layouts - decrease the layout nesting as much as possible to increase the performance. 2. Remove one dependency (circle image view) since Glide provides an options to transform an image into circular one. 3. Avoid non-static or anonymous instances of AsyncTask - leads to memory leak. 4. Instead of NotifyDataSetChanged that will refresh the whole collection. You can just notify an item position or range that you are updating (NotifyItemInserted or NotifyItemRangeChanged). This will cause less ui calculations and drawing. Cheers!
@babbintandukar99595 жыл бұрын
wow didn't knew there was notifyiteminserted or notifyitemchanged till now been almost 8 months in android thanks man
@arpitkumar45254 жыл бұрын
Any sources/references on how to use Glide to transform an image into a circular one?
@ritvijsaxena72014 жыл бұрын
For AsyncTask, it's better to give weak reference using interfaces rather than using non-static instances
@@ritvijsaxena7201 How would one achieve point 3)? Even the JSONObjectRequest class from Android uses anonymous instances/lambdas.
@paweguszczak86315 жыл бұрын
Each time when I'm thinking about learning some new good stuff - you just upload new great video about it. Keep doing your fantastic job man, your tutorials are great!
@sudhir12744 жыл бұрын
Yet another high quality tutorial from you Mitch. I could not understand how MVVM works. The other tutorials go into details of databases and related topics. The result is MVVM basics are difficult to follow and implement. I did have to watch this tutorial five or six times to understand the MVVM concept. To test my understanding, the kotlin recyclerview tutorial (BlogPost) by you was used as a starting point. Following the instructions in this video and the source code for this tutorial, BlogPost source code was converted to the MVVM model used in this tutorial. Along the way I had to jump to google to solve problems when the intended kotlin code did not work as expected. The code I amended now works like this tutorial including adding new blogs by clicking the floating button. Many, many thanks for such a good tutorial. You are one of my go to channels for Android learning. Appreciate the time you take to post these tutorials.
@nicoqueijo5 жыл бұрын
Suggestion: enable "Show taps" on your emulator under developer options so the viewer can see exactly where you are pressing when you are demoing stuff.
@zhianchen33494 жыл бұрын
Logically clear, and it helps me understand MVVM better (Also the English speech is relatively easy so I can get your point well). GOOD TUTORIAL.
@theophilus4943 жыл бұрын
So far the only tutorial on MVVM i eventually got working... i understood it better after watching this tutorial... thank you...
@aditchauhan8765 жыл бұрын
Finally found an awesome Android teacher .
@mychannel-do1bv3 жыл бұрын
I really like your idea to present complete examples. Many tutorials on the internet contains only fragments of the entire solution, and very often the code doesn't even compile. Very good job!
@hiteshchalise39885 жыл бұрын
Wow, just wow, I can't even begin to explain how you've inspired me. Thank you. :)
@anchitmittal65465 жыл бұрын
The best video for the beginners to understand the MVVM. Thank you
@buffzackel3 жыл бұрын
watched a lots of videos for mvvm but finally this one really taught me something thank you sir awesome explanation.
@DrSchille3 жыл бұрын
I absolutely love your tutorials. So easy to follow and understand. I love your clean and direct explanation of the topics. Great job! Thank you so much!
@alvaroisea22595 жыл бұрын
I'm a big fan of your tutorials man, keep up with the good work !! (Y)
@wallacethierre94194 жыл бұрын
Very good explanation and example, you used a simple problem to explain about live data with MVVM arch, congrats.
@SoyAmurita4 жыл бұрын
your video is incredible, it's my first time to deal with mvvm and all problems that have faced me, you already have put the answer for them in this video. thanks much,
@arifhussain83494 жыл бұрын
All courses should teach using the best practices
@safees31655 жыл бұрын
I also learned that if you need the application context in your viewmodel, just extend Androidviewmodel instead of ViewModel
@rickardelimaa4 жыл бұрын
Couldn't that lead to memory leaks? The whole point with the ViewModel is to avoid Context all together.
@ofir-bar-softr4 жыл бұрын
maaaan you just took a complicated subject and made it simple thank you!!
@zersaeger3 жыл бұрын
Great explanation. First minute watched and i know what its about. Havent seen any better explanation than that.
@RAHULPAWAR6545 жыл бұрын
Thanks for tutorial , you have explained Android MVVM way easier than other tutorials on youtube.
@codingwithmitch5 жыл бұрын
Watch this next for a much better mvvm example codingwithmitch.com/courses/rest-api-mvvm-retrofit2/
@dineshchoudhary82215 жыл бұрын
Hey Mitch, you’re doing a great job! I’m sure with time you’ll have a ton of subscribers and views.
@WingChanApp4 жыл бұрын
Just applied your example to my app, and it works. Thank you!
@safees31655 жыл бұрын
Look at that I implemented viewmodel into my app last night and this afternoon I see your video!
@theo_st2 жыл бұрын
Thanks for the tutorial, it was really helpful! One tiny detail you could change is that, when creating classes with the singleton pattern, the getInstance method should ideally be synchronized to avoid race conditions. Apart from that, excellent tutorial! :)
@shivamdhuria075 жыл бұрын
After trying for about months ,I think finally got this!Thank you~!
@shobhitagarwal36475 жыл бұрын
CONGRATS ON 30K my man!
@kareemhamed56065 жыл бұрын
much appreciated i always love your work man! you are a legend.
@omertajelsir69392 жыл бұрын
You are creating really awsome content. We can feel that you are really putting your heart into it. I really really thank you. best of luck
@nilesh69292 жыл бұрын
Most simple tutorial ever seen bro, Thank you very much. U helped me lot
@meisammansourzadeh77795 жыл бұрын
The hardest part in implementing MVVM is dealing with different data source like cache and local database and network, so your app can be useful even in situations like poor internet. I hope you use these different data sources in your upcoming tutorial
@codingwithmitch5 жыл бұрын
I'm going to do a rest API integration with MVVM. I'll prob add a cache too. Depends on how many members I get on my website. I can't spend too much time on a single course
@PostMeridianLyf4 жыл бұрын
This helped a lot in my understanding of MVVM. Hopefully I can build my own viewmodel soon
@barathan87663 жыл бұрын
Awesome. Using your vids for my bachelor thesis.!!! thank you
@HezOmanjo3 жыл бұрын
So glad I stumbled upon your tutorials! Thanks man!
@aminsoley91913 жыл бұрын
Thank you for your clear and step by step explanation !
@johnnyshoesofthetwo73743 жыл бұрын
I'm more of a MCVMPICVVM guy? It basically takes 2 years to write a simple app, but, it's worth the wait!
@clublulu3994 жыл бұрын
Glad I stumbled upon this. Great explanation!
@tabarekmohammed66134 жыл бұрын
Thats good info u are give to the world for free ... big love
@taar14 жыл бұрын
thanks for that video, it was exactly what I was looking for. Excited for MVVM now :)
@xoca71715 жыл бұрын
Thanks man. Very clear explanation.
@utkarsh59595 жыл бұрын
Thanks for the demo of MVVM Liked it a lot
@MrMannyvanny4 жыл бұрын
Other than ViewModel advantage,configuration change, what's the real benefit of using MVVM considering all the hassle and fuss involved in MVVM along with Retrofit? Assume I was to create a simple app that just makes network request using Volley without the need of worrying screen rotation, and DAO, what's the advantage we are getting for banging head learning complex architecture that can be achieved in just 10 liner code? It's no doubt good for complex projects though since it's well structured and Unit testing friendly. But what for a simple app?
@weihenglu6914 жыл бұрын
The best Viewmodel video you can find, end!
@user-gz1ep9sw4b5 жыл бұрын
Waiting so bad for your rest api + MVVM Project!!
@nareshns7738 Жыл бұрын
Please continue this topic to adavance..🙏🖤
@junaidijaz415 жыл бұрын
you should also make the default constructor of NicePlaceRepository class private. in order to implement the proper singleton method.
@codingwithmitch5 жыл бұрын
Yes you're right
@terjemah_alquran4 жыл бұрын
thank you, this is awesome. really eazy to follow and focus to the important point
@HamimKiVines5 жыл бұрын
Hello i am from India, You are Amazing brother, Thank you...
@HamimKiVines5 жыл бұрын
Thanks
@venukapavarapu13565 жыл бұрын
dudee...Just excellent this is really what i want
@ilyichelgar44934 жыл бұрын
I dont understand how the list in the adapter automatically changed. We just call notifydatasetchanged(), but doesn't add the new value to the list in adapter. But somehow when the list in livedata is updated, the list in adapter is updated too. How that's work? The list in adapter is just normal list and we doesn't update it too..
@sandeepkushwaha57163 жыл бұрын
Add imageview inside card view and give card view radius of half of it's height and it will be circular imageview
@chesdasann33453 жыл бұрын
your video is very helpful and well thought out
@lukasschmitt30755 жыл бұрын
Your style of teaching and the topic is very nice! But I have one issue: As far as I know the business logic doesn't belong to the viewmodels at all. In my opinion the viewmodels job is to prepare the data for the view and to route events between model and view so the view knows when the model changes and the view actions result in business logic calls on the model. That said - nice video! I did like it :)
@codingwithmitch5 жыл бұрын
I actually agree with you. It's best used as a "hub" to route the different business "events". That being said this is an introduction. In an actual implementation I would have repositories and other sources for data. My MVVM local database cache course is a good example. Here's the repo if your curious github.com/mitchtabian/Local-db-Cache-Retrofit-REST-API-MVVM
@Yogesh-bp4vv3 жыл бұрын
.. kzfaq.info/get/bejne/j5upppmUzbHDp30.html
@begmyratmammedov93573 жыл бұрын
Excellent explanation! Thanks
@Joe123Jackol4 жыл бұрын
Really nice and well explained tutorial, notice that "ViewModelProviders" has been deprecated and now have to use "ViewModelProvider"only :)
@codingwithmitch4 жыл бұрын
This video is old
@shanks_19083 жыл бұрын
Loved the tutorial but I couldn't stop looking at the misspelling of Australia in the recycler app 😂
@skywalkerpz5 жыл бұрын
Great video as always, and nice teaching keep it up!
@stalker13614 жыл бұрын
It was great. 🙏 and, so helpful. 🙏 Thanks, Dear Mitch
@TechMalaya4 жыл бұрын
Thank you for explaining difference mutablelivedata vs livedata. I am very confused when to used both of them because they are basically almost same.
@lfzhu5864 жыл бұрын
Good video! But Android team didn’t come up with the name view model, Microsoft did lol
@orhanavan72225 жыл бұрын
Yes I need this right now :) Please more
@strictnonconformist73695 жыл бұрын
Google could have done far worse than to create an MVVM framework, but Google didn’t do anything for naming more grand than following naming as created by Microsoft for the ViewModel class, keeping in context MVVM is a Microsoft creation. Now, if only all the old Microsoft Windows GUI applications were self-consistent for how they were architected for the GUI code versus the rest, with keeping it separated...
@HarshaVardhan-xx6ii2 жыл бұрын
If only the MutableLiveData objects can change and I understand you can "observe" those changes, why would the regular LiveData have the observe method, if it does not change. Are we always supposed to use the MutableLiveData?
@EL-cb1nu4 жыл бұрын
Please use the dark theme for your IDE... very hard to watch the video during the night
@theonlyarjun5 жыл бұрын
whaaaaaaaaaaat !!!! i made the right decision subscribing you man !!!!
@roopkishore7853 жыл бұрын
Honestly speaking, this video is not for complete beginners.
@KalpeshChari3 жыл бұрын
I am still confuse with the adapter you have not used data binding in the xml of recyclerView item
@fipabrate4 жыл бұрын
Thank you so much, this was more than helpful!
@andrejuntermanns76604 жыл бұрын
5:57 The user is a datasource,too. Activity/Fragment editText.getText.toString is data.The user of the app is ALWAYS a Datasource
@ankitrajdwivedi9965 жыл бұрын
This one is awesome tutorial........ Please add local cache and retrofit both in your next tutorial..
@codingwithmitch5 жыл бұрын
Here it is: codingwithmitch.com/courses/android-local-database-cache-rest-api/
@chillandcodeyt80653 жыл бұрын
Pretty awesome work.
@critikalfade4 жыл бұрын
Nicely explained, thanks!
@scarswell123 жыл бұрын
Great video. I'm gonna have to rewatch it a few times though. As someone new to design patterns it was hard to follow.
@aref1113 жыл бұрын
Awesome video , great Job my friend. Thanks for your smooth English and great explanation, I was really frustrated by Indian videos out there.. glg lglgl gl
@mformobileapps3 жыл бұрын
ViewModelProviders.of(context) is deprecated..what to use instead
@AVdubs12 жыл бұрын
Change: mViewModel = ViewModelProviders.of(this).get(MainActivityViewModel.class); To: mViewModel = new ViewModelProvider(this).get(MainActivityViewModel.class);
@FckYouPlz4 жыл бұрын
Line 46 (28:24) - you are getting back the new list from the viewmodel everytime the observer knows about a change but you do nothing with the new list that you receive - so why bother notifying the adapter for any changes as you do nothing with these changes anyway?
@b.k41425 жыл бұрын
Thanks again mitch!!
@Call_me_buddy3 жыл бұрын
Is possible to share the same instance of view model between activities similar to share the same view model between fragments? Please Help
@codervlogs49214 жыл бұрын
Very good explanation
@natetolbert36714 жыл бұрын
The way you describe mvvm, it sounds exactly like mvc. The model is the same, the view is the same, the repository/ DAO/ data layer is the same, and the controller in MVC is a wrapper for the application's business logic. You say that the viewmodel in mvvm has the same responsibility. I am struggling to see the difference.
@sathidpy.16225 жыл бұрын
Thank you.
@rayalevinson98035 жыл бұрын
Thank you for the movie. One important comment: new nicePlace is added in MainActivityViewModel (and not in NicePlaceRepository). I would like to see how to run postValue from the NivePlaceRepository. Thank you.
@harisibrahimovic19913 жыл бұрын
Anyone had a problem with items not showing until you rotate screen ?
@IsanOn5 жыл бұрын
thanks mitch, love it
@codingwithmitch5 жыл бұрын
You should watch the full course, you'll really love that. codingwithmitch.com/courses/rest-api-mvvm-retrofit2/
@IsanOn5 жыл бұрын
@@codingwithmitch of course mitch ;)
@Chekist20084 жыл бұрын
Is mAdapter != null in 46 row inside your activity? U init mAdapter only in 50 row....
@sayanthss57934 жыл бұрын
Well explained the concept.
@vivekjagtap70245 жыл бұрын
I just done your demo example , it so simple i understood the concept cleanly . But when i tried to implement this with my Database related app its hard to handle , didn't work in my case. I have to minimize app and then reopen it then i see changes. Just waiting for you MVVM Retrofit tutorial to understood it clearly. Thanks for all.
@codingwithmitch5 жыл бұрын
It's published codingwithmitch.com/courses/rest-api-mvvm-retrofit2/
@abdulwahid_mohammed5 жыл бұрын
That sounds so great. What are the differences between various Android architectures? What is the proper ways to use them?
@codingwithmitch5 жыл бұрын
They represent different ways to structure your code. MVC, MVP, MVVM. They all have different advantages/disadvantages. But personally I like MVVM for the reasons discussed in this video.
@abdulwahid_mohammed5 жыл бұрын
@@codingwithmitch thank you so much sir.
@theonlyarjun5 жыл бұрын
MVP - addressed separation on concerns MVVM - addressed data persistence that was lacked in MVP
@codingwithmitch5 жыл бұрын
@@theonlyarjun good way to put it
@kaushiknits03075 жыл бұрын
@@codingwithmitch I have seen MVP is used to make test driven development which widen the scope for JUNIT testing , but I never saw MVVM being used for test driven development. So my question is whether MVVM can also be used for TDD ?
@veys70354 жыл бұрын
I'm confused when you used Singleton Pattern, especially after reading this stackoverflow comment: "An Android Service (sub)class cannot be a singleton since the framework requires access to a default constructor for the class. The only reason I can think of for keeping a static reference to the (last) instance for which onStart was called is to simplify some internal code that may happen to reside in static methods. Considering that onStart was deprecated a long time ago (as of API level 5), this is most likely an example of bad coding style from early days of Android."
@minamcvinnie46294 жыл бұрын
These are interesting tutorials. The Java is a little odd to follow, though. Are you going to make versions of these videos in Kotlin?
@VipulSharma-qp7hw Жыл бұрын
Do we have to use live data if we are using viewmodel and mvvm ? Like I have some values of user name, address, age etc.. so how to store and retrieve them using viewmodel and mvvm ?
@Nidvoraich3 жыл бұрын
Thanks a lot, man, bro! ;)
@CoolAiAvatars4 жыл бұрын
I have found a bug. Each time the app is restarted the dataSet is duplicated. To avoid this I have added dataSet.clear(); in the method setNicePlaces() Do you noticed this also? Why the array is saved?
@randeepsiddhu4 жыл бұрын
@CodingWithMitch got a new subscriber :)
@sureshr39103 жыл бұрын
Hi , I am unable to Register into your Official website I am registering for the very first time but still says "Account with this Username already exists".
@sudhir12744 жыл бұрын
I have modified the code by moving the function to add data to repository class. The viewmodel has links to live data in repository. The code compiles without error and runs. Can you confirm one query on update.
@tiagooliveira953 жыл бұрын
I just started learning MVVM so sorry if my question is stupid, at 23:49 you are making an example of what would be a server request, here you have a reference to `mIsUpdating` but is my understanding that I should have my api/db access code in the repository right? So If I make a server request on my Repository, how can I change `mIsUpdating`? I guess I could pass a reference of `mIsUpdating` to the repo but this is just me speculating I don't know if it's the best practice
@krishanmadushanka95213 жыл бұрын
Where do we write the business logic in mvvm? In some articles it says Model and in some other articles it says Viewmodel.
@nanjuks68653 жыл бұрын
cool explanation ... great...
@ZeeshanKhan-id4fw5 жыл бұрын
hello mitch i was trying to fetch the data from firebase database using MVVM and following this lecture but it is not working,at the end mutableLivedata showing null,
@rajeshkadiri52683 жыл бұрын
Great work Mitch. But i have one doubt as per understanding ViewModel data should clear when we click back button in the mobile and activity is destoryed Right. Iam trying to reopen the app then recycler view Items going on increase. Is there any leak the program.