diff options
author | Jake Wharton <jakewharton@gmail.com> | 2012-04-23 22:02:32 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2012-04-25 15:41:16 -0700 |
commit | c0581aff1d201208c42273b825d573d6cba52900 (patch) | |
tree | ae21ef7afe42baea78dc55a032677b825158d473 | |
parent | 1b8f499a14a4340d3422d95c7f6fdc8c0c72b3a4 (diff) | |
download | frameworks_base-c0581aff1d201208c42273b825d573d6cba52900.zip frameworks_base-c0581aff1d201208c42273b825d573d6cba52900.tar.gz frameworks_base-c0581aff1d201208c42273b825d573d6cba52900.tar.bz2 |
DO NOT MERGE. Do not dispatch context selection events to non-visible fragments.
When used in a `ViewPager`, fragments that are present on the adjacent,
cached pages will receive context selection dispatches which, depending
on your fragment contents, can be difficult to determine whether or not
the event truly originated from your view.
By using the visible hint we restrict dispatching to only those fragments
which are marked as being visible. Since the fragment pager adapter
updates this setting properly most implementations will be afforded this
fix without any change required. If the user is implementing their own
adapter they likely already understand the implications of these cached
fragments and the reponsibility for updating the boolean falls to them.
Mirrors support library change Ie6a72c1c82c2784774373670007b6f5948fe16da
Integrated from AOSP.
Change-Id: I19bbbe4c8d910fb38c14d6ae5d462eb7dd44fd26
-rw-r--r-- | core/java/android/app/FragmentManager.java | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index 0519d3e..7e1daa4 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -1890,7 +1890,7 @@ final class FragmentManagerImpl extends FragmentManager { if (mActive != null) { for (int i=0; i<mAdded.size(); i++) { Fragment f = mAdded.get(i); - if (f != null && !f.mHidden) { + if (f != null && !f.mHidden && f.mUserVisibleHint) { if (f.onContextItemSelected(item)) { return true; } |