From e196b6fefed8e3854f4f5cb30a4e26d03b73130a Mon Sep 17 00:00:00 2001 From: George Mount Date: Wed, 5 Apr 2017 13:56:37 -0700 Subject: [PATCH] Change getFragments() to return a List. Bug 36762718 Bug 36982279 Changes getFragments() to return a List instead of a Collection. The order is the order in which the fragment is added or attached. Test: ran fragment cts tests Change-Id: I10bbeef13e9154bbe052127cfa0e160b2e500b4d --- api/current.txt | 2 +- api/system-current.txt | 2 +- api/test-current.txt | 2 +- core/java/android/app/FragmentManager.java | 13 ++++++++----- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/api/current.txt b/api/current.txt index 3c90844a987f7..c164d9f40db5e 100644 --- a/api/current.txt +++ b/api/current.txt @@ -4771,7 +4771,7 @@ package android.app { method public abstract android.app.FragmentManager.BackStackEntry getBackStackEntryAt(int); method public abstract int getBackStackEntryCount(); method public abstract android.app.Fragment getFragment(android.os.Bundle, java.lang.String); - method public abstract java.util.Collection getFragments(); + method public abstract java.util.List getFragments(); method public abstract android.app.Fragment getPrimaryNavigationFragment(); method public void invalidateOptionsMenu(); method public abstract boolean isDestroyed(); diff --git a/api/system-current.txt b/api/system-current.txt index 6a14b1594ba70..6d0f104a59cd1 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -4932,7 +4932,7 @@ package android.app { method public abstract android.app.FragmentManager.BackStackEntry getBackStackEntryAt(int); method public abstract int getBackStackEntryCount(); method public abstract android.app.Fragment getFragment(android.os.Bundle, java.lang.String); - method public abstract java.util.Collection getFragments(); + method public abstract java.util.List getFragments(); method public abstract android.app.Fragment getPrimaryNavigationFragment(); method public void invalidateOptionsMenu(); method public abstract boolean isDestroyed(); diff --git a/api/test-current.txt b/api/test-current.txt index c5dc584634a06..fd402a91b2e91 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -4783,7 +4783,7 @@ package android.app { method public abstract android.app.FragmentManager.BackStackEntry getBackStackEntryAt(int); method public abstract int getBackStackEntryCount(); method public abstract android.app.Fragment getFragment(android.os.Bundle, java.lang.String); - method public abstract java.util.Collection getFragments(); + method public abstract java.util.List getFragments(); method public abstract android.app.Fragment getPrimaryNavigationFragment(); method public void invalidateOptionsMenu(); method public abstract boolean isDestroyed(); diff --git a/core/java/android/app/FragmentManager.java b/core/java/android/app/FragmentManager.java index 399987fe1c417..23bcb6e56c9f1 100644 --- a/core/java/android/app/FragmentManager.java +++ b/core/java/android/app/FragmentManager.java @@ -314,14 +314,17 @@ public abstract class FragmentManager { public abstract Fragment getFragment(Bundle bundle, String key); /** - * Get a collection of all fragments that are currently added to the FragmentManager. + * Get a list of all fragments that are currently added to the FragmentManager. * This may include those that are hidden as well as those that are shown. * This will not include any fragments only in the back stack, or fragments that * are detached or removed. + *

+ * The order of the fragments in the list is the order in which they were + * added or attached. * - * @return A collection of all fragments that are added to the FragmentManager. + * @return A list of all fragments that are added to the FragmentManager. */ - public abstract Collection getFragments(); + public abstract List getFragments(); /** * Save the current instance state of the given Fragment. This can be @@ -907,12 +910,12 @@ final class FragmentManagerImpl extends FragmentManager implements LayoutInflate } @Override - public Collection getFragments() { + public List getFragments() { if (mAdded == null) { return Collections.EMPTY_LIST; } synchronized (mAdded) { - return (Collection) mAdded.clone(); + return (List) mAdded.clone(); } }