com.google.android.gms.drive.query.Query

Here are the examples of the java api class com.google.android.gms.drive.query.Query taken from open source projects.

1. BackupActivity#getBackupsFromDrive()

View license
private void getBackupsFromDrive(DriveFolder folder) {
    final Activity activity = this;
    SortOrder sortOrder = new SortOrder.Builder().addSortDescending(SortableField.MODIFIED_DATE).build();
    Query query = new Query.Builder().addFilter(Filters.eq(SearchableField.TITLE, "glucosio.realm")).addFilter(Filters.eq(SearchableField.TRASHED, false)).setSortOrder(sortOrder).build();
    folder.queryChildren(mGoogleApiClient, query).setResultCallback(new ResultCallback<DriveApi.MetadataBufferResult>() {

        private ArrayList<GlucosioBackup> backupsArray = new ArrayList<GlucosioBackup>();

        @Override
        public void onResult(DriveApi.MetadataBufferResult result) {
            MetadataBuffer buffer = result.getMetadataBuffer();
            int size = buffer.getCount();
            for (int i = 0; i < size; i++) {
                Metadata metadata = buffer.get(i);
                DriveId driveId = metadata.getDriveId();
                Date modifiedDate = metadata.getModifiedDate();
                long backupSize = metadata.getFileSize();
                backupsArray.add(new GlucosioBackup(driveId, modifiedDate, backupSize));
                backupListView.setAdapter(new BackupAdapter(activity, R.layout.preferences_backup, backupsArray));
            }
        }
    });
}

2. DriveHelper#getDriveFile()

Project: iosched
Source File: DriveHelper.java
View license
/**
     * Search for a file with the specific name and mimeType
     * @return driveId for the file it if exists.
     */
private DriveId getDriveFile(String fileName, String mimeType) {
    // Find the named file with the specific Mime type.
    Query query = new Query.Builder().addFilter(Filters.and(Filters.eq(SearchableField.TITLE, fileName), Filters.eq(SearchableField.MIME_TYPE, mimeType))).setSortOrder(new SortOrder.Builder().addSortDescending(SortableField.MODIFIED_DATE).build()).build();
    MetadataBuffer buffer = null;
    try {
        buffer = Drive.DriveApi.getAppFolder(mGoogleApiClient).queryChildren(mGoogleApiClient, query).await().getMetadataBuffer();
        if (buffer != null && buffer.getCount() > 0) {
            LOGD(TAG, "got buffer " + buffer.getCount());
            return buffer.get(0).getDriveId();
        }
        return null;
    } finally {
        if (buffer != null) {
            buffer.close();
        }
    }
}