-
Notifications
You must be signed in to change notification settings - Fork 1
HashBundle
The HashBundle class is based on Android's Bundle, using HashMap like the Bundle did previously. But the internal mapping does not have much importance. Depending on the data being stored, HashMap vs. ArrayMap does not provide much difference. What matters is that HashBundle hash much more consistent tool collection compared to Bundle. It also fixes a few Parcel issues when parsing it between processes and it supports JSONParcel so that it can be added to any persistent storage.
Example
// Create a new bundle
HashBundle bundle = new HasBundle();
// Add a value to it
bundle.putBoolean("key", true);
// Use the value
if (bundle.getBoolean("key", false)) {
}It is also possible to wrap a normal Bundle. This allows you to use the tool collection on a Bundle, like adding it to a JSONParcel, but without copying the data from one map to another.
Bundle bundle = new bundle();
HashBundle hashBundle = new HashBundle( bundle );
JSONParcel parcel = new JSONParcel();
parcel.writeJSONParcelable( hashBundle );The above only wraps the Bundle by referencing it's internal mapping. Changes to one will affect the other.