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

项目: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   
@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-sdk-android-samples    文件:ListRecordsActivity.java   
private void refreshGuiWithData(final List<Record> newRecords) {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            dialog.dismiss();
            refreshListData();
            Log.i("Sync", String.format("%d records synced", newRecords.size()));
            Toast.makeText(ListRecordsActivity.this,
                    "Successful!", Toast.LENGTH_LONG).show();
        }
    });
}
项目:aws-sdk-android-samples    文件:ListRecordsActivity.java   
private void refreshListData() {
    adapter.clear();
    for (Record record : dataset.getAllRecords()) {
        adapter.add(record);
    }
    adapter.notifyDataSetChanged();
    updateTitle();
}
项目:aws-sdk-android-samples    文件:ListRecordsActivity.java   
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(
                R.layout.record_list_item, parent, false);
        holder = new ViewHolder(convertView);
        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    Record record = getItem(position);
    // record key
    holder.tvKey.setText(record.getKey());
    // if the record is modified, mark it blue
    holder.tvKey.setTextColor(record.isModified() ? Color.BLUE
            : Color.BLACK);
    // if the record is deleted, put a strike
    if (record.isDeleted()) {
        holder.tvKey.setPaintFlags(holder.tvKey.getPaintFlags()
                | Paint.STRIKE_THRU_TEXT_FLAG);
    } else {
        holder.tvKey.setPaintFlags(holder.tvKey.getPaintFlags()
                & ~Paint.STRIKE_THRU_TEXT_FLAG);
    }
    // record value
    holder.tvValue.setText(record.getValue() == null ? "" : record
            .getValue());
    // record sync count
    holder.tvSyncCount.setText(String.valueOf(record.getSyncCount()));

    return convertView;
}
项目:aws-cognito-sync-issues    文件:CustomSyncCallBack.java   
@Override
public void onSuccess(Dataset dataset, List<Record> updatedRecords) {
    if (observer != null) {
        observer.onDatasetDidSync(dataset.getDatasetMetadata().getDatasetName());
    }
}
项目: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;
}
项目:aws-mobile-self-paced-labs-samples    文件:CognitoSyncTask.java   
void printDataset() {
    Dataset dataset = AWSClientManager.getDataset();
    for (Record record : dataset.getAllRecords()) {
        Log.i("sync", record.toString());
    }
}