-
-
Notifications
You must be signed in to change notification settings - Fork 493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FastAdapter flickers after loading from LiveData even though the data stays same #737
Comments
Hi, you are clearing all items and adding them again each time your LiveData changes. https://github.com/afarber/android-questions/blob/master/TopPlayers/app/src/main/java/de/afarber/topplayers/TopFragment.java#L87 |
Fabian, thanks for your hint, but could you add few general words on how to use DiffUtils? Just few words on what they produce and where to put their output then? Especially unclear to me - where would I get the old data, while in the |
Nevermind DiffUtils is google's class, I need to read up on the docs. Thanks |
Good evening again! I am confused, how to use DiffUtil with FastAdapter - I have added a callback class:
And then I am trying to use it in the
Please give me some hints. Also, I don't want to use FastAdapterDiffUtil, because I don't have any expandable items. |
Still, I have tried using FastAdapterDiffUtil too -
and then the RecyclerView is updated correctly, but the flickering is still there. |
Your items hashcode, and equals method have a proper implementation? The default is by identifier, if you base on the AbstractItem, if you use the interface alone you should implement these. |
Hello Mike, thanks for your reply! I have added the 2 methods to my TopItem class (representing player objects with unique integer
But unfortunately the one-time flickering is still there when I try to use
I have also posted my question on Stackoverflow and few people suggest, that FastAdapter might have issues with DiffUtil or FastAdapterDiffUtil, but I think it is maybe just an issue with missing documentation... Best regards |
and the new items definitely have the same identifier? it definitely should work without a flicker as it does in the sample, and various apps I use it in. |
Mike, yes - if you look at my TopItem - it uses:
There are no other items in my simple test case. Or do you mean something else, maybe I misunderstand you? |
no I mean the unique identifier per actual element in your list: https://github.com/mikepenz/FastAdapter/blob/develop/library-core/src/main/java/com/mikepenz/fastadapter/items/AbstractItem.java#L43 |
I have added
because each player So Can Google's DiffUtil be used with FastAdapter too? |
Well the FastAdapterDiffUtil is just a convenience class to simplify usage directly. You can use the Btw. the So it is always important if you can get a proper identifier that you also define your logic or set proper identifiers :) |
Just one more additional detail. the "identifier" is nothing specific to the The FastAdapter only offers a more "easy" handling for it for most super simple usecases |
About this issue
Good evening, for my question I have prepared a simple test case at Github -
My example app downloads a JSON array containing top 30 players in a game using okhttp and stores them into SQLite Room. In the fragment I observe the corresponding
LiveData<List<TopEntity>>
object and update the FastAdapter instance:My problem is: the recycler view flickers once - every time the data is downloaded.
Even though the top 30 does not change often, i.e. the data stays same.
When inspecting the example app in the FastAdapter library, I do not see any flickering there.
What am I missing please, probably something minor?
Details
Checklist
The text was updated successfully, but these errors were encountered: