Closed Morteza-Rastgoo closed 4 years ago
if you have a list with such frequent updates, updating is a lot more efficient and a much better approach here.
Use the diff utils to just do updates of things which actually changed.
Did it with FastAdapterDiffUtil[marketWatchListAdapter] = items and also
private fun setDataAsync() {
disposables.add(Single.fromCallable { createData() }
.map<DiffUtil.DiffResult> { simpleItems -> FastAdapterDiffUtil.calculateDiff(fastItemAdapter.itemAdapter, simpleItems) }.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe { result -> FastAdapterDiffUtil[fastItemAdapter.itemAdapter] = result })
}
same result and filter resets
Any solution?
Have you had a look at setNewList
with the retainFilter flag?
setNewList
works fine with filter, but does it honor the diff Util?
My list updates a lot and I see lags on UI
So after further investigation of this issue. The FastAdapter
does not support filters and using the DiffUtil at the same time. You can use either but not both together.
I came up with a branch where-as I add experimental support for this behavior, but due to the workarounds required to achieve something like this (to have both keep in sync kind of with each other) this will not be officially supported.
Here's the branch if you are curious: https://github.com/mikepenz/FastAdapter/tree/feature/experimental_835
The main reason to not support this is the management between updating / diffing the filtered temporary list, but also properly handling the original (unfiltered / full list) in the background. Keeping this in sync and ensuring no race conditions occur is highly risky and most likely will result in unexpected behaviors.
For this particular situation whereas you want to use the DiffUtil
I suggest that you will do the filtering of the list solely on your application side, and always pass the filtered list (as what you want to display) to the adapter.
E.g. when you want to display the full list you provide the normal unfiltered list from your side. if you want to update filtered, provide the pre filtered list to the adapter.
this will greatly simplify the whole setup and resolve any issues this might serve. especially as your application will be in the control of the data.
I hope this resolves your problem.
Best regards, Mike
Thanks for helping me. I did the same thing. I have another problem and I will ask it in another issue.
On Fri, 13 Dec. 2019, 18:33 Mike Penz, notifications@github.com wrote:
Closed #835 https://github.com/mikepenz/FastAdapter/issues/835.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mikepenz/FastAdapter/issues/835?email_source=notifications&email_token=ABH2IC3MF3AWUTAIJN2JKXLQYOP5JA5CNFSM4JRISKZKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOVPBI36Q#event-2881654266, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABH2ICYKBLOK3YL54VPMXZDQYOP5JANCNFSM4JRISKZA .
About this issue
I have a list of coins with prices which is updated every second. So I call set(items) every second. If user set a filter string to filter items, if the list updates, All the items are shown instead of just filtered items. How to handle this? Note: I tried setting the filter after
set(items)
but it updates the list with all items and shows all items for a quarter of a second, and then filters items, which is not good enough.I also tried set list using
adapter.set(items, resetFilter = false , null)
and not working.Details
Checklist