T
- Supported types are String
, Byte
, Short
, Integer
, Long
,
Float
, Double
, Boolean
, Parcelable
,
or any class annotated with @Parcelpublic class RemoteObservable<T>
extends java.lang.Object
implements android.os.Parcelable
Observable
across android remote services.
This is a Parcelable
which can be passed through remote service
aidl or Remoter interfaces
and then get an Observable
from this class at the client side.
At the client side either use getObservable()
to get an Observable
,
or use getData(boolean)
to directly get the last data and register for updates
using setDataListener(RemoteDataListener)
RemoteObservable
can be created using the factory class RemoteObservables
or manually from either an Observable
using #RemoteObservable(Observable)
or RemoteEventController
using RemoteObservable(RemoteEventController)
RemoteObservables
Modifier and Type | Field and Description |
---|---|
static android.os.Parcelable.Creator<RemoteObservable> |
CREATOR |
Constructor and Description |
---|
RemoteObservable(<any> sourceObservable)
Initialize at the service side with an
Observable |
RemoteObservable(RemoteEventController<T> remoteController)
Initialize at the service side with the
RemoteEventController |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this
RemoteObservable
No further events will be delivered |
int |
describeContents() |
T |
getData()
Returns the last data received, blocking until one is available.
|
T |
getData(boolean wait)
Returns the last data received, optionally blocking till the data is received
|
<any> |
getObservable()
Returns an
Observable which will receive the data send from the service side. |
void |
setDataListener(RemoteDataListener<T> dataListener)
Sets a listener to get notified of data.
|
void |
setDebug(boolean enable)
Enable or disable debug prints.
|
void |
setReconnecter(java.util.concurrent.Callable<RemoteObservable<T>> reconnecter)
Sets a Callable to be used to reconnect if the connection with the remote
service dies.
|
RemoteObservable<T> |
setRemoteObservableListener(RemoteObservableListener remoteObservableListener)
Set the listener to get notified when remote end closes connection.
|
void |
writeToParcel(android.os.Parcel dest,
int flags) |
public static final android.os.Parcelable.Creator<RemoteObservable> CREATOR
public RemoteObservable(RemoteEventController<T> remoteController)
RemoteEventController
remoteController
- RemoteEventController
used for generating the eventspublic RemoteObservable(<any> sourceObservable)
Observable
sourceObservable
- Observable
whose data needs to be delivered remotelypublic RemoteObservable<T> setRemoteObservableListener(RemoteObservableListener remoteObservableListener)
public int describeContents()
describeContents
in interface android.os.Parcelable
public void writeToParcel(android.os.Parcel dest, int flags)
writeToParcel
in interface android.os.Parcelable
public <any> getObservable()
Observable
which will receive the data send from the service side.public T getData()
getData(boolean)
public T getData(boolean wait)
wait
- If true, this call will block until a data is availablepublic void setDataListener(RemoteDataListener<T> dataListener)
getObservable()
dataListener
- RemoteDataListener
to get notifiedpublic void close()
RemoteObservable
No further events will be deliveredpublic void setReconnecter(java.util.concurrent.Callable<RemoteObservable<T>> reconnecter)
public void setDebug(boolean enable)