use of com.microsoft.live.LiveOperation in project LiveSDK-for-Android by liveservices.
the class UploadTest method testSyncResponseBodyValid.
@Override
public void testSyncResponseBodyValid() throws Exception {
this.loadUploadLocationResponseBody();
this.loadValidResponseBody();
String requestPath = Paths.ME_SKYDRIVE;
LiveOperation operation = this.liveConnectClient.upload(requestPath, FILENAME, FILE);
this.checkOperationMembers(operation, getMethod(), requestPath);
this.checkValidResponseBody(operation);
}
use of com.microsoft.live.LiveOperation in project LiveSDK-for-Android by liveservices.
the class PutTest method testSyncResponseBodyValid.
@Override
public void testSyncResponseBodyValid() throws Exception {
this.loadValidResponseBody();
String requestPath = this.calendarId;
LiveOperation operation = this.liveConnectClient.put(requestPath, CALENDAR);
this.checkOperationMembers(operation, METHOD, requestPath);
this.checkValidResponseBody(operation);
}
use of com.microsoft.live.LiveOperation in project LiveSDK-for-Android by liveservices.
the class PutTest method testAsyncResponseBodyValid.
@Override
public void testAsyncResponseBodyValid() throws Throwable {
this.loadValidResponseBody();
String requestPath = this.calendarId;
this.runTestOnUiThread(createAsyncRunnable(requestPath, CALENDAR));
LiveOperation fromMethod = this.responseQueue.take();
LiveOperation fromCallback = this.pollResponseQueue();
this.checkReturnedOperations(fromMethod, fromCallback);
this.checkOperationMembers(fromMethod, METHOD, requestPath);
this.checkValidResponseBody(fromMethod);
}
use of com.microsoft.live.LiveOperation in project LiveSDK-for-Android by liveservices.
the class SkyDriveActivity method loadFolder.
private void loadFolder(String folderId) {
assert folderId != null;
mCurrentFolderId = folderId;
final ProgressDialog progressDialog = ProgressDialog.show(this, "", "Loading. Please wait...", true);
mClient.getAsync(folderId + "/files", new LiveOperationListener() {
@Override
public void onComplete(LiveOperation operation) {
progressDialog.dismiss();
JSONObject result = operation.getResult();
if (result.has(JsonKeys.ERROR)) {
JSONObject error = result.optJSONObject(JsonKeys.ERROR);
String message = error.optString(JsonKeys.MESSAGE);
String code = error.optString(JsonKeys.CODE);
showToast(code + ": " + message);
return;
}
ArrayList<SkyDriveObject> skyDriveObjs = mPhotoAdapter.getSkyDriveObjs();
skyDriveObjs.clear();
JSONArray data = result.optJSONArray(JsonKeys.DATA);
for (int i = 0; i < data.length(); i++) {
SkyDriveObject skyDriveObj = SkyDriveObject.create(data.optJSONObject(i));
if (skyDriveObj != null) {
skyDriveObjs.add(skyDriveObj);
}
}
mPhotoAdapter.notifyDataSetChanged();
}
@Override
public void onError(LiveOperationException exception, LiveOperation operation) {
progressDialog.dismiss();
showToast(exception.getMessage());
}
});
}
use of com.microsoft.live.LiveOperation in project LiveSDK-for-Android by liveservices.
the class SkyDriveActivity method onActivityResult.
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == FilePicker.PICK_FILE_REQUEST) {
if (resultCode == RESULT_OK) {
String filePath = data.getStringExtra(FilePicker.EXTRA_FILE_PATH);
if (TextUtils.isEmpty(filePath)) {
showToast("No file was choosen.");
return;
}
File file = new File(filePath);
final ProgressDialog uploadProgressDialog = new ProgressDialog(SkyDriveActivity.this);
uploadProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
uploadProgressDialog.setMessage("Uploading...");
uploadProgressDialog.setCancelable(true);
uploadProgressDialog.show();
final LiveOperation operation = mClient.uploadAsync(mCurrentFolderId, file.getName(), file, new LiveUploadOperationListener() {
@Override
public void onUploadProgress(int totalBytes, int bytesRemaining, LiveOperation operation) {
int percentCompleted = computePrecentCompleted(totalBytes, bytesRemaining);
uploadProgressDialog.setProgress(percentCompleted);
}
@Override
public void onUploadFailed(LiveOperationException exception, LiveOperation operation) {
uploadProgressDialog.dismiss();
showToast(exception.getMessage());
}
@Override
public void onUploadCompleted(LiveOperation operation) {
uploadProgressDialog.dismiss();
JSONObject result = operation.getResult();
if (result.has(JsonKeys.ERROR)) {
JSONObject error = result.optJSONObject(JsonKeys.ERROR);
String message = error.optString(JsonKeys.MESSAGE);
String code = error.optString(JsonKeys.CODE);
showToast(code + ": " + message);
return;
}
loadFolder(mCurrentFolderId);
}
});
uploadProgressDialog.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
operation.cancel();
}
});
}
}
}
Aggregations