couchbase / couchbase-lite-android-ce

The community edition of couchbase lite for android
Apache License 2.0
9 stars 1 forks source link

Shouldn't Dictionary be Parcelable? #3

Closed PrasannaVenkadesh closed 5 years ago

PrasannaVenkadesh commented 5 years ago

In one case, I happen to put a Dictionary into a HashMap and pass it to a fragment. This caused a RunTimeException stating, the Parcel was unable to mash the value which is a Dictionary.

Shouldn't Dictionary be Parcelable? or is there better way to share a dictionary?

pasin commented 5 years ago

Currently none of CBL objects are Parcelable. To share that, I would suggest to put it into a global or application level Map/HashMap and share it by key string.

bmeike commented 5 years ago

@PrasannaVenkadesh, where are you passing the HashMap from? If it is an Activity, there is an idiom for transferring non-parcelable data. The Fragment defines an interface:

public interface ArgumentProvider<K, V> { 
    HashMap<K, V> getArguments();
}

... which the Activity implements. The Fragment verifies that any Activity to which it is bound implements this interface (instanceof) and then requests the value.

Will that work of you? We have an interest in keeping the Dictionary object pure Java, if that is possible.

bmeike commented 5 years ago

@PrasannaVenkadesh Do you need more help with this?

As I said, we intend to keep the Dictionary object pure Java. We would consider, however, making a new class, ParcelableDictionary, that could be passed across Binder.

bmeike commented 5 years ago

I've created https://issues.couchbase.com/browse/CBL-18 to track this issue. Please follow it there.