FastAdapter intercepting clicks for other ViewPager tabs
Closed this issue · 1 comments
About this issue
I have a ViewPager2 with 3 statically defined Fragment
s. The first fragment contains a FastAdapter-enhanced RecyclerView
whose items are various inputs: EditTexts
, Button
s, etc. The other 2 Fragment
s contain other layouts with their own content and logic (some buttons, no text inputs) but no RecyclerView
s 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 ViewPager2
orientation 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:
- On
ViewPager2.ORIENTATION_HORIZONTAL
, all clicks are intercepted and trigger whatever is positionally just behind the active fragment. - 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
- Used library version FastAdapter 5.7.0
- Used support library version androidx.appcompat 1.5.1
- Used gradle build tools version 7.2
- Used tooling / Android Studio version 2021.2.1 Patch 1
- Other used libraries, potential conflicting libraries: ViewPager2
Checklist
Checked all :-)
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.