public class ObservableParcelable<T extends Parcelable> extends ObservableField<T> implements Parcelable, Serializable
Observable field classes may be used instead of creating an Observable object:
public class MyDataObject {
public final ObservableParcelable<String> name = new ObservableParcelable<String>();
public final ObservableInt age = new ObservableInt();
}
Fields of this type should be declared final because bindings only detect changes in the
field's value, not of the field itself.
This class is parcelable but you should keep in mind that listeners are ignored when the object is parcelled. Unless you add custom observers, this should not be an issue because data binding framework always re-registers observers when the view is bound.
Parcelable.ClassLoaderCreator<T>, Parcelable.Creator<T>
Observable.OnPropertyChangedCallback
Modifier and Type | Field and Description |
---|---|
static Parcelable.Creator<ObservableParcelable> |
CREATOR |
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_ELIDE_DUPLICATES, PARCELABLE_WRITE_RETURN_VALUE
Constructor and Description |
---|
ObservableParcelable()
Creates an empty observable object
|
ObservableParcelable(T value)
Wraps the given object and creates an observable object
|
Modifier and Type | Method and Description |
---|---|
int |
describeContents()
Describe the kinds of special objects contained in this Parcelable
instance's marshaled representation.
|
void |
writeToParcel(Parcel dest,
int flags)
Flatten this object in to a Parcel.
|
get, set
addOnPropertyChangedCallback, notifyChange, notifyPropertyChanged, removeOnPropertyChangedCallback
public static final Parcelable.Creator<ObservableParcelable> CREATOR
public ObservableParcelable(T value)
value
- The value to be wrapped as an observable.public ObservableParcelable()
public int describeContents()
Parcelable
Parcelable.writeToParcel(Parcel, int)
,
the return value of this method must include the
Parcelable.CONTENTS_FILE_DESCRIPTOR
bit.describeContents
in interface Parcelable
Parcelable.CONTENTS_FILE_DESCRIPTOR
public void writeToParcel(Parcel dest, int flags)
Parcelable
writeToParcel
in interface Parcelable
dest
- The Parcel in which the object should be written.flags
- Additional flags about how the object should be written.
May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE
.