Closed shobhik closed 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.
About this issue
I have a ViewPager2 with 3 statically defined
Fragment
s. The first fragment contains a FastAdapter-enhancedRecyclerView
whose items are various inputs:EditTexts
,Button
s, etc. The other 2Fragment
s contain other layouts with their own content and logic (some buttons, no text inputs) but noRecyclerView
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 anEditText
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:
ViewPager2.ORIENTATION_HORIZONTAL
, all clicks are intercepted and trigger whatever is positionally just behind the active fragment.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 FAFragment
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 theFragment
is inactive/active.Details
Checklist
Checked all :-)