本文整理匯總了Java中com.google.android.gms.drive.MetadataChangeSet類的典型用法代碼示例。如果您正苦於以下問題:Java MetadataChangeSet類的具體用法?Java MetadataChangeSet怎麽用?Java MetadataChangeSet使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
MetadataChangeSet類屬於com.google.android.gms.drive包,在下文中一共展示了MetadataChangeSet類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: saveDriveFile
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
/**
* Save the {@code DriveFile} with the specific driveId.
*
* @param id {@link DriveId} of the file.
* @param content The content to be saved in the {@code DriveFile}.
* @return Return value indicates whether the save was successful.
*/
public boolean saveDriveFile(DriveId id, String content) throws IOException {
DriveFile theFile = Drive.DriveApi.getFile(mGoogleApiClient, id);
DriveApi.DriveContentsResult result =
theFile.open(mGoogleApiClient, DriveFile.MODE_WRITE_ONLY, null).await();
try {
IOUtils.writeToStream(content, result.getDriveContents().getOutputStream());
// Update the last viewed.
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setLastViewedByMeDate(new Date())
.build();
return result.getDriveContents().commit(mGoogleApiClient, changeSet)
.await().isSuccess();
} catch (IOException io) {
result.getDriveContents().discard(mGoogleApiClient);
throw io;
}
}
示例2: onResult
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
@Override
public void onResult(DriveContentsResult result) {
if (!result.getStatus().isSuccess()) {
Log.i(TAG, "Error creating new file contents");
return;
}
final DriveContents driveContents = result.getDriveContents();
new Thread() {
@Override
public void run() {
OutputStream outputStream = driveContents.getOutputStream();
addTextfileToOutputStream(outputStream);
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle("testFile")
.setMimeType("text/plain")
.setDescription("This is a text file uploaded from device")
.setStarred(true).build();
Drive.DriveApi.getRootFolder(googleApiClient)
.createFile(googleApiClient, changeSet, driveContents)
.setResultCallback(fileCallback);
}
}.start();
}
示例3: createEmptyDriveFile
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
/**
* Create an empty file with the given {@code fileName} and {@code mimeType}.
*
* @return {@link DriveId} of the specific file.
*/
private DriveId createEmptyDriveFile(String fileName, String mimeType) {
DriveApi.DriveContentsResult result =
Drive.DriveApi.newDriveContents(mGoogleApiClient).await();
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle(fileName)
.setMimeType(mimeType)
.setStarred(true)
.build();
// Create a new file with the given changeSet in the AppData folder.
DriveFolder.DriveFileResult driveFileResult = Drive.DriveApi.getAppFolder(mGoogleApiClient)
.createFile(mGoogleApiClient, changeSet, result.getDriveContents())
.await();
return driveFileResult.getDriveFile().getDriveId();
}
示例4: commitToNewFile
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
/**
* Creates a new file and adds the {@link DriveContents} passed to this method.
* @return Returns a boolean stating the success of this operation
*/
private boolean commitToNewFile(DriveContents driveContents) {
DebugLog.logMethod();
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle("CouponsTrackerData.txt")
.setMimeType("text/plain")
.build();
DriveFolder.DriveFileResult driveFileResult = Drive.DriveApi
.getAppFolder(getGoogleApiClient())
.createFile(getGoogleApiClient(), changeSet, driveContents)
.await();
DebugLog.logMessage("DriveFileResult: statusCode - " + driveFileResult.getStatus().getStatusCode()
+ ", statusMessage: " + driveFileResult.getStatus().getStatusMessage());
return driveFileResult.getStatus().isSuccess();
}
示例5: onResult
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
@Override
public void onResult(@NonNull final DriveApi.DriveContentsResult driveContentsResult) {
new Thread(new Runnable() {
@Override
public void run() {
DriveFolder appFolder = Drive.DriveApi.getAppFolder(mGoogleApiClient);
MetadataChangeSet set = new MetadataChangeSet.Builder().setTitle(getString(R.string.drive_file_name)).setMimeType(getString(R.string.drive_file_mimetype)).build();
appFolder.createFile(mGoogleApiClient, set, driveContentsResult.getDriveContents()).setResultCallback(new ResultCallback<DriveFolder.DriveFileResult>() {
@Override
public void onResult(@NonNull DriveFolder.DriveFileResult driveFileResult) {
driveFileResult.getDriveFile().open(mGoogleApiClient, DriveFile.MODE_WRITE_ONLY, null).setResultCallback(writeDriveCallback);
loadingView.setVisibility(View.GONE);
}
});
}
}).start();
}
示例6: actionCreateFileForSync
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
@OnClick(R.id.btCreateFileForSync)
public void actionCreateFileForSync() {
try {
MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
.setMimeType("text/plain").build();
IntentSender intentSender = Drive.DriveApi.newCreateFileActivityBuilder()
.setInitialMetadata(metadataChangeSet)
.setInitialDriveContents(null)
.setActivityTitle("Create file for sync")
.build(mGoogleApiClient);
startIntentSenderForResult(intentSender, REQUEST_CODE_NEW_FILE, null, 0, 0, 0);
} catch (Exception e) {
Log.w(TAG, "Unable to send intent", e);
}
}
示例7: createNewFile
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
/**
* Create a new file on Drive.
*
* @param title The name of the file
* @param hash The file hash
* @param contents The file content
*/
private void createNewFile(@NonNull String title, @NonNull String hash,
@NonNull DriveContents contents) {
if(mResourceClient == null || mDriveFolder == null) {
return;
}
final MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle(title)
.setCustomProperty(sHashKey, hash).build();
final ExecutionOptions options = new ExecutionOptions.Builder()
.setNotifyOnCompletion(true).build();
try {
Tasks.await(mResourceClient.createFile(mDriveFolder, changeSet, contents, options));
} catch(ExecutionException | InterruptedException e) {
Log.w(TAG, "Failed to create remote file", e);
}
}
示例8: UploadFileExisting
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
private void UploadFileExisting(final DriveId driveId, final String contents, final String fileName, final OnFileUploaded callback) {
driveId.asDriveFile().open(getApiClient(), DriveFile.MODE_WRITE_ONLY, null).setResultCallback(new ResultCallback<DriveApi.DriveContentsResult>() {
@Override
public void onResult(DriveApi.DriveContentsResult driveContentsResult) {
Utils.writeToOutputStream(driveContentsResult.getDriveContents().getOutputStream(), contents);
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle(fileName)
.setPinned(true)
.build();
driveContentsResult.getDriveContents().commit(getApiClient(), changeSet).setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status result) {
if (result.getStatus().isSuccess())
callback.onFileUploaded(driveId);
else
callback.onFileUploaded(null);
activeOperations = false;
}
});
}
});
}
示例9: writeFile
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
public Observable<Void> writeFile(final DriveId driveId, final InputStream inputStream) {
return Observable.defer(new Func0<Observable<Void>>() {
@Override
public Observable<Void> call() {
// OutputStream outputStream = Drive.DriveApi.getFile(googleApiClientManager.getGoogleApiClient(), driveId)
DriveContents driveContents = Drive.DriveApi.getFile(googleApiClientManager.getGoogleApiClient(), driveId)
.open(googleApiClientManager.getGoogleApiClient(), DriveFile.MODE_WRITE_ONLY, null)
.await()
.getDriveContents();
// copy file to drive contents
try {
copyStream(inputStream, driveContents.getOutputStream());
} catch (IOException e) {
Timber.e(e, "failed to read image");
return Observable.error(e);
}
// commit changes
driveContents.commit(googleApiClientManager.getGoogleApiClient(), new MetadataChangeSet.Builder().build()).await();
return Observable.just(null);
}
});
}
示例10: onResult
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
@Override
public void onResult(DriveApi.DriveContentsResult result) {
MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
.setTitle("cumulustv_channels.json")
.setDescription("JSON list of channels that can be imported using CumulusTV to view live streams")
.setMimeType("application/json").build();
IntentSender intentSender = Drive.DriveApi
.newCreateFileActivityBuilder()
.setActivityTitle("cumulustv_channels.json")
.setInitialMetadata(metadataChangeSet)
.setInitialDriveContents(result.getDriveContents())
.build(CloudStorageProvider.getInstance().getClient());
try {
mActivity.startIntentSenderForResult(
intentSender, REQUEST_CODE_CREATOR, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.w(TAG, "Unable to send intent", e);
}
}
示例11: onResult
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
@Override
public void onResult(DriveApi.DriveContentsResult result) {
MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
.setTitle("cumulustv_channels.json")
.setDescription("JSON list of channels that can be imported using " +
"CumulusTV to view live streams")
.setMimeType("application/json").build();
IntentSender intentSender = Drive.DriveApi
.newCreateFileActivityBuilder()
.setActivityTitle("cumulustv_channels.json")
.setInitialMetadata(metadataChangeSet)
.setInitialDriveContents(result.getDriveContents())
.build(CloudStorageProvider.getInstance().getClient());
try {
startIntentSenderForResult(
intentSender, REQUEST_CODE_CREATOR, null, 0, 0, 0);
} catch (IntentSender.SendIntentException e) {
Log.w(TAG, "Unable to send intent", e);
}
}
示例12: createFile
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
private void createFile() {
setUiInteractionsEnabled(false);
int fileCount = mFileFolderAdapter.getCount();
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle("sample file " + (fileCount + 1))
.setMimeType("text/plain")
.build();
DriveFolder driveFolder = mNavigationPath.peek().asDriveFolder();
Task<DriveFile> createFileTask =
mDriveResourceClient.createFile(driveFolder, changeSet, null);
Task<Void> updateTask = updateUiAfterTask(createFileTask);
handleTaskError(updateTask, R.string.unexpected_error);
}
示例13: createFolder
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
private void createFolder() {
setUiInteractionsEnabled(false);
int fileCount = mFileFolderAdapter.getCount();
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle("sample folder " + (fileCount + 1))
.build();
DriveFolder driveFolder = mNavigationPath.peek().asDriveFolder();
Task<DriveFolder> createFolderTask =
mDriveResourceClient.createFolder(driveFolder, changeSet);
Task<Void> updateTask = updateUiAfterTask(createFolderTask);
handleTaskError(updateTask, R.string.unexpected_error);
}
示例14: createAmiiboFolder
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
@DebugLog
private void createAmiiboFolder() {
MetadataChangeSet changeSet = new MetadataChangeSet.Builder()
.setTitle(AMIIBO_FOLDER).build();
Drive.DriveApi.getRootFolder(_parent.getClient())
.createFolder(_parent.getClient(), changeSet)
.setResultCallback(new ResultCallback<DriveFolder.DriveFolderResult>() {
@Override
public void onResult(DriveFolder.DriveFolderResult driveFolderResult) {
if (driveFolderResult.getStatus().isSuccess()) {
app_folder_for_user = driveFolderResult.getDriveFolder();
listFiles();
} else {
app_folder_for_user = null;
_parent.onPushFinished();
}
}
});
}
示例15: updateMetadata
import com.google.android.gms.drive.MetadataChangeSet; //導入依賴的package包/類
public PendingResult<DriveResource.MetadataResult> updateMetadata(GoogleApiClient paramGoogleApiClient, final MetadataChangeSet paramMetadataChangeSet)
{
// Byte code:
// 0: aload_2
// 1: ifnonnull +13 -> 14
// 4: new 35 java/lang/IllegalArgumentException
// 7: dup
// 8: ldc 37
// 10: invokespecial 40 java/lang/IllegalArgumentException:<init> (Ljava/lang/String;)V
// 13: athrow
// 14: aload_1
// 15: new 42 com/google/android/gms/drive/internal/m$2
// 18: dup
// 19: aload_0
// 20: aload_2
// 21: invokespecial 45 com/google/android/gms/drive/internal/m$2:<init> (Lcom/google/android/gms/drive/internal/m;Lcom/google/android/gms/drive/MetadataChangeSet;)V
// 24: invokevirtual 48 com/google/android/gms/common/api/GoogleApiClient:b (Lcom/google/android/gms/common/api/a$a;)Lcom/google/android/gms/common/api/a$a;
// 27: areturn
}