com.google.android.gms.drive.DriveResource Java Examples

The following examples show how to use com.google.android.gms.drive.DriveResource. 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: MainActivity.java    From android-samples with Apache License 2.0 6 votes vote down vote up
/**
 * 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]
}