Java源码示例:com.google.android.gms.drive.DriveResource

示例1
/**
 * Trashes or untrashes the given item.
 *
 * @param metadata Item to (un)trash
 */
private void toggleTrashStatus(Metadata metadata) {
    // [START drive_android_trash]
    if (!metadata.isTrashable()) {
        showMessage(R.string.trashable_error);
        return;
    }
    DriveResource driveResource = metadata.getDriveId().asDriveResource();
    Task<Void> toggleTrashTask;
    if (metadata.isTrashed()) {
        toggleTrashTask = mDriveResourceClient.untrash(driveResource);
    } else {
        toggleTrashTask = mDriveResourceClient.trash(driveResource);
    }
    toggleTrashTask = updateUiAfterTask(toggleTrashTask);
    handleTaskError(toggleTrashTask, R.string.unexpected_error);
    // [END drive_android_trash]
}