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.83k stars 492 forks source link

FastAdapter intercepting clicks for other ViewPager tabs #1042

Closed shobhik closed 1 year ago

shobhik commented 1 year ago

About this issue

I have a ViewPager2 with 3 statically defined Fragments. The first fragment contains a FastAdapter-enhanced RecyclerViewwhose items are various inputs: EditTexts, Buttons, etc. The other 2 Fragments contain other layouts with their own content and logic (some buttons, no text inputs) but no RecyclerViews or FA code. Unfortunately, if I go to the 2nd or 3rd page/Fragment, I cannot click any buttons in those with the expected result. Instead, what I see is the keyboard surfacing for an EditText in the first tab where the FastAdapter is, or a picker triggering if that position was where a button was in FA. If I type text into the keyboard and return to the first tab, I see that it populates one of those FA text items, so I know it's FastAdapter intercepting those clicks.

That was on ViewPager2orientation set to Horizontal. If I change to Vertical, I no longer see the stray keyboard or button triggers, but I don't see any button clicks firing for my intended Page 2/3 layouts either.

To summarize:

  1. On ViewPager2.ORIENTATION_HORIZONTAL, all clicks are intercepted and trigger whatever is positionally just behind the active fragment.
  2. On ViewPager2.ORIENTATION_VERTICAL, all clicks are intercepted without any further action occurring at that expected position.

Possible workaround/question: could we turn off EventHook capture at will? Say I detect my FA Fragment is no longer the current item, could I tell it's adapter to ignore clicks? I'd like to preserve state simply so not I'm proposing a reset of the entire fragment, just a soft-disable/enable when the Fragment is inactive/active.

Details

Checklist

Checked all :-)

shobhik commented 1 year ago

EDIT: Sorry, this was an issue with ViewPager! Just my luck that I spent a few days on this problem and only cracked it minutes after filing this issue.

In case you run into this as well, just remember to check that your custom PageTransformers are actually doing their work. We had ours set to disable the swipe animation and do a fade animation, but the code samples we'd seen before did not do offsets sufficiently large enough.