public class SyncClient
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
SyncClient.ConnectionState
Enum representing underlying twilsock connection state.
|
static interface |
SyncClient.ConnectionStateListener
Listener interface to receive connection state change events.
|
static class |
SyncClient.Properties
Specify properties for creating new Sync Client.
|
Modifier and Type | Method and Description |
---|---|
static void |
create(android.content.Context context,
java.lang.String accessToken,
SyncClient.Properties props,
SuccessListener<SyncClient> listener)
Public factory method to create a new instance of Sync Client.
|
void |
dispose() |
SyncClient.ConnectionState |
getConnectionState() |
static java.lang.String |
getSdkVersion() |
void |
openDocument(Options options,
DocumentObserver observer,
SuccessListener<Document> output)
Open or create a
Document object. |
void |
openList(Options options,
ListObserver observer,
SuccessListener<List> output)
Open or create a
List object. |
void |
openMap(Options options,
MapObserver observer,
SuccessListener<Map> output)
Open or create a
Map object. |
void |
openStream(Options options,
StreamObserver observer,
SuccessListener<Stream> output)
Open or create a
Stream object. |
void |
setConnectionStateListener(SyncClient.ConnectionStateListener listener)
Set new connection state listener on the client.
|
static void |
setLogLevel(int level) |
void |
shutdown()
Cleanly shut down the SyncClient and free up associated resources.
|
void |
updateToken(java.lang.String accessToken,
SuccessListener<java.lang.Void> listener)
Update SyncClient with a refreshed token.
|
public static void create(@NonNull android.content.Context context, java.lang.String accessToken, SyncClient.Properties props, SuccessListener<SyncClient> listener)
context
- Pass Application Context here, cannot be null.accessToken
- Access token containing at least a Sync Grant to access sync features.props
- Properties for initializing client. Properties.defaultProperties()
could be commonly used. See SyncClient.Properties
for more details.listener
- Listener to receive the newly created Sync Client.public static java.lang.String getSdkVersion()
public void updateToken(java.lang.String accessToken, SuccessListener<java.lang.Void> listener)
accessToken
- New access token containing at least a Sync Grant to access sync features.listener
- Listener to receive status of the operation.public void shutdown()
Avoid calling methods on Sync objects from their own callback events, as it may lead to unexpected nesting and poorly predictable behavior. SyncClient shutdown method must not be called from an event callback.
It will dispose() the client after shutdown, so it could not be reused.
public void openDocument(Options options, DocumentObserver observer, SuccessListener<Document> output)
Document
object.options
- Options that specify open mode and possible SID or Unique Name of the Document.observer
- Observer to receive callbacks on all actions performed on the document both
locally and remotely.output
- Listener that will receive opened document in its onSuccess() callback or
any error in onError() callback.public void openList(Options options, ListObserver observer, SuccessListener<List> output)
List
object.options
- Options that specify open mode and possible SID or Unique Name of the List.observer
- Observer to receive callbacks on all actions performed on the list both
locally and remotely.output
- Listener that will receive opened list in its onSuccess() callback or
any error in onError() callback.public void openMap(Options options, MapObserver observer, SuccessListener<Map> output)
Map
object.options
- Options that specify open mode and possible SID or Unique Name of the Map.observer
- Observer to receive callbacks on all actions performed on the map both
locally and remotely.output
- Listener that will receive opened map in its onSuccess() callback or
any error in onError() callback.public void openStream(Options options, StreamObserver observer, SuccessListener<Stream> output)
Stream
object.options
- Options that specify open mode and possible SID or Unique Name of the Stream.observer
- Observer to receive callbacks on all actions performed on the stream both
locally and remotely.output
- Listener that will receive opened stream in its onSuccess() callback or
any error in onError() callback.public SyncClient.ConnectionState getConnectionState()
public void setConnectionStateListener(SyncClient.ConnectionStateListener listener)
onConnectionStateChanged
callback
with the current state of the connection.listener
- New listener to use or null to remove listener.public static void setLogLevel(int level)
public void dispose()