mikepenz/FastAdapter

Long Click Event not fired while refresh items short periodically

integral0909 opened this issue · 4 comments

Thanks for your great library.
I have implemented my recyclerview with this FastAdapter.
But I have a problem with item long click listener.
The issue is that item long click events are not fired when refresh items per 500ms or less time.
How can I solve this issue?

I have added long click listener like the following

        fastAdapter.onLongClickListener = {view, adapter, item, position->
            item.onLongClick()
            false
        }

and refreshing recyclerview per 250 ~ 500 ms

viewModel.getNetDealList().observe(viewLifecycleOwner, Observer {
            itemAdapter.clear()
            itemAdapter.add(it)
        })

@sweetdream0729 that sounds like a case which is not related to the library.

The click listener can't function if the view is re-done every few 100 ms.

Consider to lower the frequency + also use a diff util to ensure to only update elements which actually changed.

I have tried to use a diff util to only update elements which changed.
But if I click the item which is update per 240ms, listener does not work.
Any other solution?

You could try to use partial updates of your item with payloads.

Please reference to the RecyclerView documentation for more details on payloads