|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
public static interface Dataset.SyncCallback
This is the callback used in Dataset.synchronize(SyncCallback).
| Method Summary | |
|---|---|
boolean |
onConflict(Dataset dataset,
java.util.List<SyncConflict> conflicts)
This can be triggered during two phases. |
boolean |
onDatasetDeleted(Dataset dataset,
java.lang.String datasetName)
This is triggered when the given dataset is deleted remotely. |
boolean |
onDatasetsMerged(Dataset dataset,
java.util.List<java.lang.String> datasetNames)
If two or more datasets are merged as a result of identity merge, this will be triggered. |
void |
onFailure(DataStorageException dse)
This is called when an exception occurs during sync. |
void |
onSuccess(Dataset dataset,
java.util.List<Record> updatedRecords)
This is called after remote changes are downloaded to local storage and local changes are uploaded to remote storage. |
| Method Detail |
|---|
void onSuccess(Dataset dataset,
java.util.List<Record> updatedRecords)
onConflict(com.amazonaws.mobileconnectors.cognito.Dataset, java.util.List) after
several retries, then updatedRecords will be what are pulled down
from remote in the last retry.
dataset - the dataset that performed syncupdatedRecords - new records from remote storage that are
downloaded
boolean onConflict(Dataset dataset,
java.util.List<SyncConflict> conflicts)
List<Record> resolved = new ArrayList<Record>();
for (SyncConflict conflict : conflicts) {
resolved.add(conflicts.resolveWithRemoteRecord());
}
dataset.save(resolved);
return true; // so that synchronize() can retry
If you prefer to add additional logic when resolving conflict, you
can use SyncConflict.resolveWithValue(String)
int remoteMoney = Integer.valueOf(conflicts.getRemote().getValue()); int localMoney = Integer.valueOf(conflicts.getLocal().getValue()); int total = remoteMoney + localMoney; Record resolve = conflicts.resolveWithValue(String.valueOf(total));
dataset - the dataset that performed syncconflicts - conflicting records
boolean onDatasetDeleted(Dataset dataset,
java.lang.String datasetName)
dataset - dataset handlerdatasetName - the name of the dataset that is deleted remotely
boolean onDatasetsMerged(Dataset dataset,
java.util.List<java.lang.String> datasetNames)
dataset - dataset handlerdatasetNames - a list of names of merged datasets'
void onFailure(DataStorageException dse)
dse - exception
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||