BundleCollectionUtil
@UnstableApi
public final class BundleCollectionUtil
Utilities for converting collections to and from Bundle instances.
Summary
Public methods |
|
|---|---|
static HashMap<String, String> |
bundleToStringHashMap(Bundle bundle) |
static ImmutableMap<String, String> |
bundleToStringImmutableMap(Bundle bundle) |
static void |
ensureClassLoader(@Nullable Bundle bundle)Sets the application class loader to the given |
static ImmutableList<T> |
Unbundles a list of |
static SparseArray<T> |
<T extends Object> fromBundleSparseArray(Unbundles a |
static Bundle |
getBundleWithDefault(Bundle bundle, String field, Bundle defaultValue) |
static ArrayList<Integer> |
getIntegerArrayListWithDefault( |
static Bundle |
stringMapToBundle(Map<String, String> map) |
static ArrayList<Bundle> |
<T extends Object> toBundleArrayList(Bundles a collection of objects to an |
static ImmutableList<Bundle> |
<T extends Object> toBundleList(List<T> list, Function<T, Bundle> toBundleFunc)Bundles a list of objects to a list of |
static SparseArray<Bundle> |
<T extends Object> toBundleSparseArray(Bundles a |
Public methods
bundleToStringImmutableMap
public static ImmutableMap<String, String> bundleToStringImmutableMap(Bundle bundle)
ensureClassLoader
public static void ensureClassLoader(@Nullable Bundle bundle)
Sets the application class loader to the given Bundle if no class loader is present.
This assumes that all classes unparceled from bundle are sharing the class loader of BundleCollectionUtil.
fromBundleList
public static ImmutableList<T> <T extends Object> fromBundleList(
Function<Bundle, T> fromBundleFunc,
List<Bundle> bundleList
)
Unbundles a list of Bundle instances to a list of objects.
| Parameters | |
|---|---|
Function<Bundle, T> fromBundleFunc |
Function that specified how to unbundle each item. |
List<Bundle> bundleList |
List of |
| Returns | |
|---|---|
ImmutableList<T> |
The |
fromBundleSparseArray
public static SparseArray<T> <T extends Object> fromBundleSparseArray(
Function<Bundle, T> fromBundleFunc,
SparseArray<Bundle> bundleSparseArray
)
Unbundles a SparseArray of Bundle instances to a SparseArray of objects.
| Parameters | |
|---|---|
Function<Bundle, T> fromBundleFunc |
Function that specified how to unbundle each item. |
SparseArray<Bundle> bundleSparseArray |
|
| Returns | |
|---|---|
SparseArray<T> |
The |
getBundleWithDefault
public static Bundle getBundleWithDefault(Bundle bundle, String field, Bundle defaultValue)
getIntegerArrayListWithDefault
public static ArrayList<Integer> getIntegerArrayListWithDefault(
Bundle bundle,
String field,
ArrayList<Integer> defaultValue
)
toBundleArrayList
public static ArrayList<Bundle> <T extends Object> toBundleArrayList(
Collection<T> items,
Function<T, Bundle> toBundleFunc
)
Bundles a collection of objects to an ArrayList of Bundle instances so that the returned list can be put to Bundle using putParcelableArrayList conveniently.
| Parameters | |
|---|---|
Collection<T> items |
Collection of items to be bundled. |
Function<T, Bundle> toBundleFunc |
Function that specifies how to bundle each item. |
toBundleList
public static ImmutableList<Bundle> <T extends Object> toBundleList(List<T> list, Function<T, Bundle> toBundleFunc)
Bundles a list of objects to a list of Bundle instances.
| Parameters | |
|---|---|
List<T> list |
List of items to be bundled. |
Function<T, Bundle> toBundleFunc |
Function that specifies how to bundle each item. |
| Returns | |
|---|---|
ImmutableList<Bundle> |
The |
toBundleSparseArray
public static SparseArray<Bundle> <T extends Object> toBundleSparseArray(
SparseArray<T> items,
Function<T, Bundle> toBundleFunc
)
Bundles a SparseArray of objects to a SparseArray of Bundle instances so that the returned SparseArray can be put to Bundle using putSparseParcelableArray conveniently.
| Parameters | |
|---|---|
SparseArray<T> items |
Collection of items to be bundled. |
Function<T, Bundle> toBundleFunc |
Function that specifies how to bundle each item. |
| Returns | |
|---|---|
SparseArray<Bundle> |
The |