BundleCollectionUtil


@UnstableApi
class BundleCollectionUtil


Utilities for converting collections to and from Bundle instances.

Summary

Public functions

java-static HashMap<String!, String!>!
java-static ImmutableMap<String!, String!>!
java-static Unit

Sets the application class loader to the given Bundle if no class loader is present.

java-static ImmutableList<T!>!
<T : Any?> fromBundleList(
    fromBundleFunc: Function<Bundle!, T!>!,
    bundleList: (Mutable)List<Bundle!>!
)

Unbundles a list of Bundle instances to a list of objects.

java-static SparseArray<T!>!
<T : Any?> fromBundleSparseArray(
    fromBundleFunc: Function<Bundle!, T!>!,
    bundleSparseArray: SparseArray<Bundle!>!
)

Unbundles a SparseArray of Bundle instances to a SparseArray of objects.

java-static Bundle!
getBundleWithDefault(bundle: Bundle!, field: String!, defaultValue: Bundle!)
java-static ArrayList<Int!>!
getIntegerArrayListWithDefault(
    bundle: Bundle!,
    field: String!,
    defaultValue: ArrayList<Int!>!
)
java-static Bundle!
java-static ArrayList<Bundle!>!
<T : Any?> toBundleArrayList(
    items: (Mutable)Collection<T!>!,
    toBundleFunc: Function<T!, Bundle!>!
)

Bundles a collection of objects to an ArrayList of Bundle instances so that the returned list can be put to Bundle using putParcelableArrayList conveniently.

java-static ImmutableList<Bundle!>!
<T : Any?> toBundleList(
    list: (Mutable)List<T!>!,
    toBundleFunc: Function<T!, Bundle!>!
)

Bundles a list of objects to a list of Bundle instances.

java-static SparseArray<Bundle!>!
<T : Any?> toBundleSparseArray(
    items: SparseArray<T!>!,
    toBundleFunc: Function<T!, Bundle!>!
)

Bundles a SparseArray of objects to a SparseArray of Bundle instances so that the returned SparseArray can be put to Bundle using putSparseParcelableArray conveniently.

Public functions

bundleToStringHashMap

java-static fun bundleToStringHashMap(bundle: Bundle!): HashMap<String!, String!>!

bundleToStringImmutableMap

java-static fun bundleToStringImmutableMap(bundle: Bundle!): ImmutableMap<String!, String!>!

ensureClassLoader

java-static fun ensureClassLoader(bundle: Bundle?): Unit

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

java-static fun <T : Any?> fromBundleList(
    fromBundleFunc: Function<Bundle!, T!>!,
    bundleList: (Mutable)List<Bundle!>!
): ImmutableList<T!>!

Unbundles a list of Bundle instances to a list of objects.

Parameters
fromBundleFunc: Function<Bundle!, T!>!

Function that specified how to unbundle each item.

bundleList: (Mutable)List<Bundle!>!

List of Bundle instances to be unbundled.

Returns
ImmutableList<T!>!

The ImmutableList of unbundled items.

fromBundleSparseArray

java-static fun <T : Any?> fromBundleSparseArray(
    fromBundleFunc: Function<Bundle!, T!>!,
    bundleSparseArray: SparseArray<Bundle!>!
): SparseArray<T!>!

Unbundles a SparseArray of Bundle instances to a SparseArray of objects.

Parameters
fromBundleFunc: Function<Bundle!, T!>!

Function that specified how to unbundle each item.

bundleSparseArray: SparseArray<Bundle!>!

SparseArray of Bundle instances to be unbundled.

Returns
SparseArray<T!>!

The SparseArray of unbundled items.

getBundleWithDefault

java-static fun getBundleWithDefault(bundle: Bundle!, field: String!, defaultValue: Bundle!): Bundle!

getIntegerArrayListWithDefault

java-static fun getIntegerArrayListWithDefault(
    bundle: Bundle!,
    field: String!,
    defaultValue: ArrayList<Int!>!
): ArrayList<Int!>!

stringMapToBundle

java-static fun stringMapToBundle(map: (Mutable)Map<String!, String!>!): Bundle!

toBundleArrayList

java-static fun <T : Any?> toBundleArrayList(
    items: (Mutable)Collection<T!>!,
    toBundleFunc: Function<T!, Bundle!>!
): ArrayList<Bundle!>!

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
items: (Mutable)Collection<T!>!

Collection of items to be bundled.

toBundleFunc: Function<T!, Bundle!>!

Function that specifies how to bundle each item.

Returns
ArrayList<Bundle!>!

The ArrayList of bundled items.

toBundleList

java-static fun <T : Any?> toBundleList(
    list: (Mutable)List<T!>!,
    toBundleFunc: Function<T!, Bundle!>!
): ImmutableList<Bundle!>!

Bundles a list of objects to a list of Bundle instances.

Parameters
list: (Mutable)List<T!>!

List of items to be bundled.

toBundleFunc: Function<T!, Bundle!>!

Function that specifies how to bundle each item.

Returns
ImmutableList<Bundle!>!

The ImmutableList of bundled items.

toBundleSparseArray

java-static fun <T : Any?> toBundleSparseArray(
    items: SparseArray<T!>!,
    toBundleFunc: Function<T!, Bundle!>!
): SparseArray<Bundle!>!

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
items: SparseArray<T!>!

Collection of items to be bundled.

toBundleFunc: Function<T!, Bundle!>!

Function that specifies how to bundle each item.

Returns
SparseArray<Bundle!>!

The SparseArray of bundled items.