Hey Philipp brother you helped me a lot by showing how to use DiffUtil. Thank you so much🙌
@matt-g-recovers3 жыл бұрын
I Gotta say I love this part, such a good optimization.
@BaljeetSingh-ib1pf3 жыл бұрын
Hey Philipp, Thanks for this amazing lesson over diffUtil. Could you explain how to assign items list to this adapter. Thanks
@bharathpediredla5494 жыл бұрын
You explained it better man. 👌🏼
@PhilippLackner4 жыл бұрын
better than what? :D
@bharathpediredla5494 жыл бұрын
@@PhilippLackner Than the stupid Documentation 😂😂.
@PhilippLackner4 жыл бұрын
@@bharathpediredla549 thanks 😂👍
@mhmitsray6 ай бұрын
hey :) just a few questions (all towards the end of the video): 1. Wouldn't it be better to make the setOnItemClickListener function private? or is it for external use? 2. I'm getting an error when add '.name' to: tvSource.text = article.source.name
@rodneyperello3 жыл бұрын
Everything is in good programming style.
@tiagosutter88213 жыл бұрын
First of all, thanks for the course. I have a question related to big android projects in general What are the advantage of having all the 'adapters' in one top level package in big projects? I see this often, the same for ViewModels. When we get to a point of having 50+ adapters (my case) it gets kind of messy, and most adapters are used in one single place in my application. The same happens to viewmodels folder. For example in an app we have some screen related to payment, to get better separation i put everything related to payment screens in the ui.payment package Then i have packages like ui.payment.viewmodels, ui.payment.fragments, ui.payment.adapters, etc The adapters related to payment are used only for the screens related to payment, so i see no reason to put them in a top level 'adapters' package, same thing with the ViewModels. Is there some big disadvantage of working with this structure that I described that i'm just not seeing? Thanks again for the awesome content.
@PhilippLackner3 жыл бұрын
You're totally right with that, this is not the structure I would use for big scale apps. I think for this simple app and tutorial here it's not a big issue though :)
@felipepereira30614 жыл бұрын
I still got confused about the line 58, with the : ((Article) -> Unit)? it is an Article object?Why all the Unit? declarations?
@ubersticks3 жыл бұрын
"Unit" in Kotlin is just like "void" in Java -- "-> Unit" means this function that accepts "Article" as a parameter does not return anything.
@egementt2453 жыл бұрын
@@ubersticks Great explanation! Thanks a lot.
@yootewb2 жыл бұрын
It is not an Article object. It is actually a nullable function that takes an Article as an argument and returns Unit (the equivalent of void in Java). We are simply assigning a variable to represent a function that we can choose to either implement or leave null.
@j2ck1e Жыл бұрын
Is the setOnClickListener attribute of item layout?
@johntotetwoo4 жыл бұрын
Hello, how do you add a button click listener inside the recyclerview and notify it when that item's property has been changed?
@brucebane74013 жыл бұрын
what does listener mean ???
@fu7ur3gh0573 жыл бұрын
Hello Phill,can you show us how to filter recycler view with DiffUtil?for example at SavedNewsFragments?
@firantemilan4 жыл бұрын
Thank you very much. How many videos are there in total?
@PhilippLackner4 жыл бұрын
In total 12 videos. You're welcome 👍
@testapp6163 жыл бұрын
Thank you for everything :)
@matt-g-recovers3 жыл бұрын
Perfect! Thanks so much!
@ackerman69922 жыл бұрын
Can anyone explain me about that onitemclicklistener and all? It is bad practice to call setonclicklistener in bind viewholder right? Then why he used it there?
@himanshujain7184 жыл бұрын
Please upload video on how to implement seach saved news in saved news fragment.
@iam-learning63744 жыл бұрын
Hi @Philipp Lacker.... may I know what is the difference between ListAdapter and AsyncListDiffer? and which one to use ? Great tutorial as always! thanks.
@yootewb2 жыл бұрын
Not much of a difference. ListAdapter is just an extension of RecyclerView.Adapter that uses AsyncListDiffer to calculate the differences on a background thread. If your list is dynamic (like in this video), it would be better to opt for ListAdapter because the constructor requires you to specify a Diff checker and therefore prevent you from forgetting to do so.
@muthami_duncan2 жыл бұрын
Hi Phil, How can I use view binding here?
@jayceeddeyro14064 жыл бұрын
Do you have a video where you use diffUtil and with databinding?
@Omsamara64 жыл бұрын
When you're setting all of those textviews (tvSource, tvTitle, etc) do they have to be inside of the apply block? None of those reference "this" (the view) so I'm not sure why it's in the apply block. Same applies to the setOnClickListener. Great tutorial as always, thank you
@PhilippLackner4 жыл бұрын
They do reference the view (itemView). Otherwise you would have to write holder.itemView.* for every view you reference. Same counts for onclicklistener
@albertocastro54962 жыл бұрын
How would you set up a listener to handle clicks on a view that is inside of a list item, for example if you wanted to execute some code after clicking on your tvTitle view
@chuka_obi51674 жыл бұрын
Hey Phillip this is a really great tutorial! Thank you for sharing. Can you create a tutorial in future that uses data binding and ListAdapter for recyclerview? I currently use ListAdapter for my recyclerview but I can't tell which one is better, using a Recyclerview.Adapter or ListAdapter
@yootewb2 жыл бұрын
Not much of a difference. ListAdapter is just an extension of RecyclerView.Adapter that uses AsyncListDiffer to calculate the differences on a background thread. If your list is dynamic (like in this video), it would be better to opt for ListAdapter because the constructor requires you to specify a Diff checker and therefore prevent you from forgetting to do so.
@sohilupadhyay48043 жыл бұрын
Why do you use Diff utils in RecyclerView? You can also create seperate adapter class different Fragments ?
@joywanjiku23173 жыл бұрын
1:18-2:15 DiffUtil is more efficient & runs in the background thread compared to NotifyDataSetChanged
@shyngyskhann2 жыл бұрын
AMAZING!
@ajaygalagali59634 жыл бұрын
It would be helpful to beginners, if you explain in more details
@PhilippLackner4 жыл бұрын
This is not a beginner tutorial though. Don't skip the basics
@DriveWithHamza3 жыл бұрын
Thumbs up Philipp
@FelixEsUnDios2 жыл бұрын
I'm here October 2022
@dennisgonzales95214 жыл бұрын
Thanks bro! You're awesome 👌👍
@PhilippLackner4 жыл бұрын
You're welcome!
@chuka_obi51674 жыл бұрын
Also, for my ListAdapter, I don't know why it will only work if I write my code like this val itemToRemove = ToDoItem(toDoText, isCompleted) viewModel.removeFromToDoList(itemToRemove) toDoAdapter.submitList(null) toDoAdapter.submitList(viewModel.toDoList.value!!) toDoAdapter.notifyDataSetChanged() Isn't the point of a DiffUtil so that you dont need to call notifyDataSetChanged()
@osmanmusse94323 жыл бұрын
Great video
@hasanal-qaisi87124 жыл бұрын
Thank you for this valuable information. I have a question, what if my adapter receive data of type (any) and i cast the data in the adapter. How can I implement DiffUtil in this case (Of having multiple data types) ?
@PhilippLackner4 жыл бұрын
check with a when-expression what type of data you're dealing with
@hasanal-qaisi87124 жыл бұрын
@@PhilippLackner I tried to make differItemCallback of type Any and checked the type of data by using when expression I faced two problems: 1- Suspicious equality check: equals() is not implemented in Object DiffUtilEquals I solved this first problem by making the data class implement an interface that override equals function and make the differItemCallback type of this interface. 2- The second problem is that neither areItemsTheSame() nor areContentsTheSame() working.. I logged them and found out that they're not getting called. I don't know why.
@PhilippLackner4 жыл бұрын
@@hasanal-qaisi8712 you can also compare the hashcodes of 2 items to check if the contents are the same
@SudhanshuKumar-xy6xv3 жыл бұрын
Now how do I access imageview with view binding as this method is deprecated plz help
@tjgolder993 жыл бұрын
First write --> private lateinit var binding: ItemArticlePreviewBinding inside the class NewsAdapter and then in onBindViewHolder write this ---> val ivArticleImage = binding.ivArticleImage and then use ivArticleImage in into(ivArticleImage) . Hope you understand .. If you feel any difficulty contact me.
@IlyaTihii2 жыл бұрын
Phillip, you can help me. How do I change Bindviewholder so that tv.Source, tv.Title and so on are not highlighted in red.
I have one recyclerview with nestedscrollview. That's works perfectly as normal. But, when I tried to improve it with diffutil it don't appear. So, what is the issue I don't know?? Please, help me.
@amineayachi3353 жыл бұрын
Thanks
@amateur_gamer1012 жыл бұрын
when setting up the glide, i cant find the ".urlToImage" to call. what's the problem?
@9769ug Жыл бұрын
the NewsAPi no longer has a field for urlToImage, does anyone know a workaround to get the images?
@praystation04092 жыл бұрын
I am here January 2022
@mex53412 жыл бұрын
it's better to implement ListAdapter to Adapter Class
@tabrezlj70574 жыл бұрын
Why do you have the setOnItemClickListener function when you didn’t even call it ?
@ackerman69922 жыл бұрын
Did you got any answer?
@brucebane74013 жыл бұрын
isnt onitemclicklistener a keyword how can we name a variable like that ????
@mubaraknative Жыл бұрын
phillip get 123K subscriber's at 02/08/2023 at 11:09 AM
@yasminedwedar86514 жыл бұрын
A failure occurred while executing org.jetbrains.kotlin.gradle.internal.KaptExecution i got this error helpppp
@mikec42204 жыл бұрын
Hi Yasmine, had the same issue... In Article class replace "val author : Any" with "val author : String" .. it worked on my end but I don't know if I messed it up in the long run.. although it should not be a big issue.
@nirajmalpani95894 жыл бұрын
@@mikec4220 Thanks buddy... I had the same error it worked👍
@roopkishore7853 жыл бұрын
This tutorial series is not for beginners, I am beginner and I am totally confused.
@pembatamang82333 жыл бұрын
who the heck hit dislike. Must be high haha
@aakashroushann16024 жыл бұрын
tried your way but unfortunately the list disappers after using diffutil...hope you can help here's the link to my adapter class: pastebin.com/v4jshBgZ
@Sk-gb2hx3 жыл бұрын
+
@innocentkumwenda81392 жыл бұрын
sir I cant get my view in my layout file in the overrided function "onBindViewHolder" this part : holder.itemView.apply { }