0

I love FastAdapter so far and have found it tremendously useful. However, I have a curious issue where I cannot register a second EventHook for a custom object type and get it to run.

First ItemType My first EventHook looks like this:

class FirstEventHook(var activity: FragmentActivity) : ClickEventHook<FirstItemType>(), ISubItemEventHook<FirstItemType>

Registration looks like this:

adapter.addEventHook(DateSubItem.DateEventHook(activity))

Second ItemType

My second EventHook looks like this:

class SecondEventHook(var userHandler: UserHandler?) : ClickEventHook<SecondItemType>(), ISubItemEventHook<SecondItemType> {

Registration looks like this:

adapter.addEventHook(SecondItemType.SecondEventHook(userHandler))

With both of these EventHooks registered, clicking on an item of the second type causes a crash. The error message in the fatal exception says it cannot cast to the first item type, referencing the first method declaration above instead of the second.

If I comment out registration of the first EventHook, leaving all other registrations unaltered (I have a few CustomEventHook types as well) then on clicking items of the second type, nothing happens.

I registered EventHooks above as shown in the docs. What am I missing here?

shobhik
  • 200
  • 5
  • Can you share your `EventHook` classes and your adapter initialization ? Maybe something is wrong in `onBind` or `onClick` methods. – Julien_H Jan 08 '23 at 10:26

0 Answers0