Java 类com.amazonaws.mobileconnectors.cognito.SyncConflict 实例源码

项目:aws-cognito-sync-issues    文件:CustomSyncCallBack.java   
@Override
public boolean onConflict(Dataset dataset, List<SyncConflict> conflicts) {
    boolean r = super.onConflict(dataset, conflicts);
    if (observer != null) {
        observer.onDatasetDidSync(dataset.getDatasetMetadata().getDatasetName());
    }
    return r;
}
项目:aws-mobile-self-paced-labs-samples    文件:CognitoSyncTask.java   
@Override
public boolean onConflict(final Dataset dataset,
        final List<SyncConflict> conflicts) {
    callingActivity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            dialog.dismiss();
            Log.i("Sync onConflict",
                String.format("%s records in conflict", conflicts.size()));
            List<Record> resolvedRecords = new ArrayList<Record>();
            for (SyncConflict conflict : conflicts) {
                Log.i("Sync onConflict",
                    String.format("remote: %s; local: %s",
                        conflict.getRemoteRecord(),
                        conflict.getLocalRecord()));
                /* resolve by taking remote records */
                resolvedRecords.add(conflict.resolveWithRemoteRecord());
            }
            dataset.resolve(resolvedRecords);
            Toast.makeText(
                    callingActivity,
                    String.format(
                        "%s records in conflict. Resolve by taking remote records",
                        conflicts.size()),
                    Toast.LENGTH_LONG).show();
        }
    });
    return true;
}
项目:snake-game-aws    文件:CognitoSyncTask.java   
@Override
public boolean onConflict(final Dataset dataset,
        final List<SyncConflict> conflicts) {
    callingActivity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            dialog.dismiss();
            Log.i("Sync onConflict",
                String.format("%s records in conflict", conflicts.size()));
            List<Record> resolvedRecords = new ArrayList<Record>();
            for (SyncConflict conflict : conflicts) {
                Log.i("Sync onConflict",
                    String.format("remote: %s; local: %s",
                        conflict.getRemoteRecord(),
                        conflict.getLocalRecord()));
                /* resolve by taking remote records */
                resolvedRecords.add(conflict.resolveWithRemoteRecord());

                /* resolve by taking local records */
                // resolvedRecords.add(conflict.resolveWithLocalRecord());

                /*
                 * resolve with customized logic, e.g.
                 * concatenate strings
                 */
                // String newValue =
                // conflict.getRemoteRecord().getValue()
                // + conflict.getLocalRecord().getValue();
                // resolvedRecords.add(conflict.resolveWithValue(newValue));
            }
            dataset.resolve(resolvedRecords);
            Toast.makeText(
                    callingActivity,
                    String.format(
                        "%s records in conflict. Resolve by taking remote records",
                        conflicts.size()),
                    Toast.LENGTH_LONG).show();
        }
    });
    return true;
}