Thanks! But if that's about optimization you may as well, in MyDiffUtil, 1) use count() instead of size for good practice, and 2) have a local variable to the list[position] items in the old and new list, not to accumulate the linear access cost for each comparison.
Great explanation. I have static list of icons from drawable and i need to show them in recycler view but, recycler view lags on first load. Is there any workaround?
6:08 Why are you comparing each properties of Person Data Class? Kotlin Data class generates equals() function for us. So return oldList[oldItemPosition] == newList[newItemPosition] will be enough.
TIP: you can just use the following code is your are using Kotln Data Classes since it already implment the comparsion for all the properties of a Class. override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = oldList[oldItemPosition] == newList[newItemPosition]
That's great, in local. but can we use this same function (DiffUtil) if our data (those for the recycle view) come from firebase / where several user can constantly be editing the list (adding new elements, for example) ?
Instead of comparing each item's properties, wouldn't it be easier if we just use _return oldList[oldItemPos] == newList[newItemPos]_ in areContentTheSame method?
**EDIT** : I just learned that kotlin data class generates equals() method, so you are correct. This would just compare their address in memory. Suppose object o1 has an address 0xab and a name property whose value is "John Doe", and object o2 has an address 0xbc and a name property whose value is "John Doe". Now if you compare them like this : o1===o2, it will return false because 0xab != 0xbc. But if you were to compare them by their content which is the name property, then you can see that both objects have the same content i.e: o1.name is same as o2.name.
Sad class. I imagined that it adds the new user at the top of the recyclerView list, and not at the end, by default the recyclerView already does this by adding it at the end of the recyclerView. Useless content.
Please do not stop making videos!! Your content is gold to me. I am learning so much from you.
This is one of the best recommended channel youtube done to me..such a great content, Thank you so much for your kind efforts.
Thanks! But if that's about optimization you may as well, in MyDiffUtil, 1) use count() instead of size for good practice, and 2) have a local variable to the list[position] items in the old and new list, not to accumulate the linear access cost for each comparison.
Perfect!!! On a platter my recycler view get animated! so fluid! so fast!
Another component to improve my project. Thank you so much
Lots of loves from Afghanistan...😘🇦🇫
u have internet dude ?? just curious : )
You just read my mind. I was about to search for this video. Thank you
Thank you very much, bro, your material saved me at least two working days for 10 minutes :)
Thanks sir, i love watch your tutorials its gold (sry for my bad english)
Thank you very much everything worked out without question
Great 👌
thanks my fellow developer
Thanks for the clean code and understanding.
Its really helpful & greate explanation
Great explanation. I have static list of icons from drawable and i need to show them in recycler view but, recycler view lags on first load. Is there any workaround?
You are the best 😍
great topic well done ty
6:08 Why are you comparing each properties of Person Data Class? Kotlin Data class generates equals() function for us. So return oldList[oldItemPosition] == newList[newItemPosition] will be enough.
It's purely for tutorial purpose. That way people will better understand how comparison is working behind the scenes.
@@StevdzaSan Thank you for reply. I discovered your channel this morning. I am loving your videos, keep posting videos regularly.❤️❤️
Ohh this is Im waiting for
So so good!! you are the One! thumb up of course Thank you!!!
You are the best.
I love you. ❤️
TIP: you can just use the following code is your are using Kotln Data Classes since it already implment the comparsion for all the properties of a Class.
override fun areContentsTheSame(oldItemPosition: Int, newItemPosition: Int) = oldList[oldItemPosition] == newList[newItemPosition]
Very good
very powerful thanks
Isnt this example the same as NotifyItemChanged and you pass the latest position on the list?
Hi Thank you for video. RowLayoutBinding in the ViewHolder constructor didn’t work for me
That's great, in local. but can we use this same function (DiffUtil) if our data (those for the recycle view) come from firebase / where several user can constantly be editing the list (adding new elements, for example) ?
Very Good... Bravo
Thank you for all videos, Can you make a video about custom views ?
Real deal!!!
Thank you
hello ... what if we want to use diffutil with 2way dataBinging ... is it posible ? ... thank y for your great work !!!
good one
Отличный канал, спасибо большое)
Hello Stevdza-San, i like your videos, i hope you can explain the Repository Pattern, Thanks
Can you cover also async list differ?
how about using ListAdapter
Instead of comparing each item's properties, wouldn't it be easier if we just use _return oldList[oldItemPos] == newList[newItemPos]_ in areContentTheSame method?
**EDIT** : I just learned that kotlin data class generates equals() method, so you are correct.
This would just compare their address in memory. Suppose object o1 has an address 0xab and a name property whose value is "John Doe", and object o2 has an address 0xbc and a name property whose value is "John Doe".
Now if you compare them like this : o1===o2, it will return false because 0xab != 0xbc. But if you were to compare them by their content which is the name property, then you can see that both objects have the same content i.e: o1.name is same as o2.name.
Great 🌹🌹🌹🌹🌹🌹🌹
Hi can you make it with java?
how to handle the case of saving data to local db by diffutil, because it is null if you follow this tutorial
Why don't we use Epoxy? It's already do this job for us without extra boiler plate code
If we have two data types what we have to do?
it preserve position on the recyclerview?
Wouldn't it be easier to use ListAdapter?
What if when i add the person at index 0 ??
I run the app, but it's empty. How to make app shows content? Anyone knows? Thanks.
Can u open translate for your videos ?
can share the source code??
Why you have started the tutorials in Kotlin only why not Java.
🙂...
Sad class. I imagined that it adds the new user at the top of the recyclerView list, and not at the end, by default the recyclerView already does this by adding it at the end of the recyclerView. Useless content.
You are cool man. 🔥
Thanks man
You're welcome!