com.google.android.gms.drive.DriveApi.DriveContentsResult Java Examples

The following examples show how to use com.google.android.gms.drive.DriveApi.DriveContentsResult. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TGDriveBrowser.java    From tuxguitar with GNU Lesser General Public License v2.1 6 votes vote down vote up
public void getOutputStream(final TGBrowserCallBack<OutputStream> cb, final TGBrowserElement element) {
	try {
		DriveFile driveFile = ((TGDriveBrowserFile) element).getFile();
		driveFile.open(TGDriveBrowser.this.client, DriveFile.MODE_WRITE_ONLY, null).setResultCallback(new ResultCallback<DriveContentsResult>() {
			public void onResult(final DriveContentsResult result) {
				if( result.getStatus().isSuccess() ) {
					cb.onSuccess(new TGDriveBrowserOutputStream(result.getDriveContents().getOutputStream(), new Runnable() {
						public void run() {
							result.getDriveContents().commit(TGDriveBrowser.this.client, null);
						}
					}));
				} else {
					cb.handleError(new TGBrowserException(findActivity().getString(R.string.gdrive_write_file_error)));
				}
			}
		});
	} catch (Throwable e) {
		cb.handleError(e);
	}
}