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

项目: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-cognito-sync-issues    文件:CustomSyncCallBack.java   
@Override
public boolean onDatasetsMerged(Dataset dataset, List<String> datasetNames) {
    if (observer != null) {
        observer.onDatasetDidSync(dataset.getDatasetMetadata().getDatasetName());
    }
    return super.onDatasetsMerged(dataset, datasetNames);
}
项目:react-native-cognito    文件:ReactCognitoModule.java   
@ReactMethod
public void syncData(String datasetName, String key, String value)
{
    Dataset dataset = cognitoClient.openOrCreateDataset(datasetName);
    dataset.put(key, value);
    dataset.synchronize(new DefaultSyncCallback());
}
项目:snake-game-aws    文件:CognitoSyncTask.java   
public void doSync(boolean showDialog) {

    //    Log.i("doInBackground", "Starting CognitoSyncTask with id: "
    //            + cognito.getIdentityId());
        ProgressDialog dialog = new ProgressDialog(callingActivity);
        if(showDialog) dialog = ProgressDialog.show(callingActivity,"Syncing", "Please wait");
        Dataset dataset = AWSClientManager.getDataset();
        printDataset();

            dataset.synchronize(new SimpleCallback(dialog));
    }
项目:snake-game-aws    文件:CognitoSyncTask.java   
@Override
public void onSuccess(Dataset dataset, final List<Record> newRecords) {
    printDataset();
    callingActivity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            dialog.dismiss();
            Log.i("Sync", String.format("%d records synced", newRecords.size()));
            Toast.makeText(callingActivity,
                "Sync Successful!", Toast.LENGTH_LONG).show();
        }
    });
}
项目:aws-mobile-self-paced-labs-samples    文件:CognitoSyncTask.java   
public void doSync() {

        ProgressDialog dialog = ProgressDialog.show(callingActivity,
                "Syncing", "Please wait");
        Dataset dataset = AWSClientManager.getDataset();
        printDataset();

        dataset.synchronize(new SimpleCallback(dialog));
    }
项目:aws-mobile-self-paced-labs-samples    文件:CognitoSyncTask.java   
@Override
public void onSuccess(Dataset dataset, final List<Record> newRecords) {
    printDataset();
    callingActivity.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            dialog.dismiss();
            Log.i("Sync", String.format("%d records synced", newRecords.size()));
            Toast.makeText(callingActivity,
                "Sync Successful!", Toast.LENGTH_LONG).show();
        }
    });
}
项目: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;
}
项目:aws-cognito-sync-issues    文件:CustomSyncCallBack.java   
@Override
public void onSuccess(Dataset dataset, List<Record> updatedRecords) {
    if (observer != null) {
        observer.onDatasetDidSync(dataset.getDatasetMetadata().getDatasetName());
    }
}
项目:aws-cognito-sync-issues    文件:CustomSyncCallBack.java   
@Override
public boolean onDatasetDeleted(Dataset dataset, String datasetName) {
    return false;
}
项目:snake-game-aws    文件:CognitoSyncTask.java   
void printDataset() {
    Dataset dataset = AWSClientManager.getDataset();
    for (Record record : dataset.getAllRecords()) {
        Log.i("sync", record.toString());
    }
}
项目: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;
}
项目:snake-game-aws    文件:CognitoSyncTask.java   
@Override
public boolean onDatasetDeleted(Dataset arg0, String arg1) { return false; }
项目:snake-game-aws    文件:CognitoSyncTask.java   
@Override
public boolean onDatasetsMerged(Dataset arg0, List<String> arg1) {
    dialog.dismiss();
    return false;
}
项目:snake-game-aws    文件:AWSClientManager.java   
public static Dataset getDataset()
{
       return cognitosync.openOrCreateDataset(COGNITO_SYNC_DATASET_NAME);
}
项目:aws-mobile-self-paced-labs-samples    文件:CognitoSyncTask.java   
void printDataset() {
    Dataset dataset = AWSClientManager.getDataset();
    for (Record record : dataset.getAllRecords()) {
        Log.i("sync", record.toString());
    }
}
项目:aws-mobile-self-paced-labs-samples    文件:CognitoSyncTask.java   
@Override
public boolean onDatasetDeleted(Dataset arg0, String arg1) { return false; }
项目:aws-mobile-self-paced-labs-samples    文件:CognitoSyncTask.java   
@Override
public boolean onDatasetsMerged(Dataset arg0, List<String> arg1) { return false; }
项目:aws-mobile-self-paced-labs-samples    文件:AWSClientManager.java   
public static Dataset getDataset()
{
       return cognitosync.openOrCreateDataset(COGNITO_SYNC_DATASET_NAME);
}
项目:aws-sdk-android-samples    文件:CognitoSyncClientManager.java   
/**
 * Opens or creates a dataset. If the dataset doesn't exist, an empty one
 * with the given name will be created. Otherwise, dataset is loaded from
 * local storage. If a dataset is marked as deleted but hasn't been deleted
 * on remote via refreshDatasetMetadata(), it will throw
 * IllegalStateException.
 * 
 * @param datasetName a name of your dataset
 * @return an instance of dataset loaded from local storage
 */
public static Dataset openOrCreateDataset(String datasetName) {
    checkSyncAvailability();
    return client.openOrCreateDataset(datasetName);
}