@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; }
@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; }
@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; }