mikepenz / FastAdapter

The bullet proof, fast and easy to use adapter library, which minimizes developing time to a fraction...
https://mikepenz.dev
Apache License 2.0
3.84k stars 494 forks source link

Long Click Event not fired while refresh items short periodically #1006

Closed integral0909 closed 3 years ago

integral0909 commented 3 years ago

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?

integral0909 commented 3 years ago

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)
        })
mikepenz commented 3 years ago

@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.

integral0909 commented 3 years ago

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?

mikepenz commented 3 years ago

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

Please reference to the RecyclerView documentation for more details on payloads