本文整理汇总了Java中com.google.android.gms.drive.query.Query类的典型用法代码示例。如果您正苦于以下问题:Java Query类的具体用法?Java Query怎么用?Java Query使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Query类属于com.google.android.gms.drive.query包,在下文中一共展示了Query类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: queryFile
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
private void queryFile() {
Query query = new Query.Builder()
.addFilter(Filters.contains(SearchableField.TITLE, "Note.json"))
.build();
Drive.DriveApi.query(
mGoogleApiClient, query).setResultCallback(result -> {
if (!result.getStatus().isSuccess()) {
if (BuildConfig.DEBUG)
Log.d(TAG, "Problem while retrieving results");
return;
}
Metadata metadata = result.getMetadataBuffer().get(0);
if (BuildConfig.DEBUG)
Log.d(TAG, "metadata.getDriveId():" + metadata.getDriveId());
readFileFromDrive(metadata.getDriveId());
});
}
示例2: getDriveFile
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
/**
* Get a file from the Drive folder.
*
* @param hash The file hash
* @return The DriveFile or null if it doesn't exist.
*/
@Nullable
private DriveFile getDriveFile(@NonNull String hash) {
if(mResourceClient == null || mDriveFolder == null) {
return null;
}
try {
final Query query = new Query.Builder().addFilter(Filters.eq(sHashKey, hash)).build();
final MetadataBuffer buffer =
Tasks.await(mResourceClient.queryChildren(mDriveFolder, query));
if(buffer != null && buffer.getCount() > 0) {
final DriveFile driveFile = buffer.get(0).getDriveId().asDriveFile();
buffer.release();
return driveFile;
}
} catch(ExecutionException | InterruptedException ignored) {
}
return null;
}
示例3: deleteFolder
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
public Observable<Void> deleteFolder(final String folderName) {
return Observable.defer(new Func0<Observable<Void>>() {
@Override
public Observable<Void> call() {
GoogleApiClient client = googleApiClientManager.getGoogleApiClient();
// find folder drive id
DriveFolder appFolder = getAppRootFolder();
MetadataBuffer queryResult = appFolder.queryChildren(
client,
new Query.Builder().addFilter(Filters.eq(SearchableField.TITLE, folderName)).build())
.await().getMetadataBuffer();
if (queryResult.getCount() == 0) throw new IllegalArgumentException("no folder with name " + folderName);
DriveId folderId = queryResult.get(0).getDriveId();
// delete folder
DriveFile folder = Drive.DriveApi.getFile(client, folderId);
folder.delete(client).await();
return Observable.just(null);
}
});
}
示例4: readFileContent
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
@DebugLog
public void readFileContent(final String file_name, final List<Metadata> remainings) {
Query query = new Query.Builder()
.addFilter(Filters.eq(SearchableField.TITLE, file_name))
.build();
app_folder_for_user.queryChildren(_parent.getClient(), query)
.setResultCallback(new ResultCallback<DriveApi.MetadataBufferResult>() {
@Override
public void onResult(DriveApi.MetadataBufferResult metadataBufferResult) {
MetadataBuffer buffer = metadataBufferResult.getMetadataBuffer();
int count = buffer.getCount();
if (count > 0) {
readFileFromDrive(buffer, buffer.get(0).getDriveId());
} else {
_parent.onFileRead(null);
}
readFileContent(remainings);
}
});
}
示例5: query
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
public PendingResult<DriveApi.MetadataBufferResult> query(GoogleApiClient paramGoogleApiClient, final Query paramQuery)
{
if (paramQuery == null)
throw new IllegalArgumentException("Query must be provided.");
return paramGoogleApiClient.a(new j(paramQuery)
{
protected void a(j paramAnonymousj)
{
try
{
paramAnonymousj.cN().a(new QueryRequest(paramQuery), new h.i(this));
return;
}
catch (RemoteException localRemoteException)
{
a(new h.f(new Status(8, localRemoteException.getLocalizedMessage(), null), null));
}
}
});
}
示例6: getServerItems
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
@WorkerThread
@Nullable
public ArrayList<ServerItem> getServerItems(GoogleApiClient googleApiClient) {
Log.d();
Query query = new Query.Builder().build();
DriveApi.MetadataBufferResult metadataBufferResult =
Drive.DriveApi.getAppFolder(googleApiClient).queryChildren(googleApiClient, query).await(AWAIT_DELAY_SHORT, AWAIT_UNIT_SHORT);
Status status = metadataBufferResult.getStatus();
Log.d("status=" + status);
if (!status.isSuccess()) {
Log.w("Could not query app folder");
metadataBufferResult.release();
return null;
}
MetadataBuffer metadataBuffer = metadataBufferResult.getMetadataBuffer();
int count = metadataBuffer.getCount();
Log.d("count=" + count);
ArrayList<ServerItem> res = new ArrayList<>(count);
for (Metadata metadata : metadataBuffer) {
res.add(new ServerItem(metadata));
}
metadataBufferResult.release();
Log.d(res.toString());
return res;
}
示例7: findChild
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
public static DriveId findChild(GoogleApiClient mClient, String title, DriveFolder baseFolder) {
ArrayList<Filter> fltrs = new ArrayList<>();
fltrs.add(Filters.eq(SearchableField.TRASHED, false));
if (title != null) fltrs.add(Filters.eq(SearchableField.TITLE, title));
Query qry = new Query.Builder().addFilter(Filters.and(fltrs)).build();
DriveApi.MetadataBufferResult rslt = (baseFolder == null) ?
Drive.DriveApi.query(mClient, qry).await() :
baseFolder.queryChildren(mClient, qry).await();
if (rslt.getStatus().isSuccess()) {
MetadataBuffer mdb = null;
try {
mdb = rslt.getMetadataBuffer();
if (mdb != null) {
for (Metadata md : mdb) {
if (md == null) continue;
return md.getDriveId(); // here is the "Drive ID"
}
}
} finally {
if (mdb != null) mdb.close();
}
}
return null;
}
示例8: getDriveFile
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
/**
* 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();
}
}
}
示例9: findFile
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
/**
* Asynchronously queries Drive within the passed params to find a DriveFile
*
* @param driveClient the {@link GoogleApiClient} to use for this Drive request
* @param folder the {@link DriveFolder} to query within
* @param filename the filename to query for
*/
public void findFile(GoogleApiClient driveClient, DriveFolder folder, String filename) {
// Make filename filter
Filter filenameFilter = Filters.eq(SearchableField.TITLE, filename);
// Build query with filter
Query query = new Query.Builder()
.addFilter(filenameFilter)
.build();
// Execute query on folder
folder.queryChildren(driveClient, query).setResultCallback(this);
}
示例10: findFile
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
/**
* Asynchronously queries Drive within the passed params to find a DriveFile
* @param driveClient the {@link GoogleApiClient} to use for this Drive request
* @param folder the {@link DriveFolder} to query within
* @param filename the filename to query for
*/
public void findFile(GoogleApiClient driveClient, DriveFolder folder, String filename) {
// Make filename filter
Filter filenameFilter = Filters.eq(SearchableField.TITLE, filename);
// Build query with filter
Query query = new Query.Builder()
.addFilter(filenameFilter)
.build();
// Execute query on folder
folder.queryChildren(driveClient, query).setResultCallback(this);
}
示例11: getBackupsFromDrive
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
private void getBackupsFromDrive() {
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
final Activity activity = this;
SortOrder sortOrder = new SortOrder.Builder()
.addSortDescending(SortableField.MODIFIED_DATE).build();
Query query = new Query.Builder()
.addFilter(Filters.eq(SearchableField.TITLE, Constants.EXPORT_REALM_FILE_NAME))
.addFilter(Filters.eq(SearchableField.TRASHED, false))
.setSortOrder(sortOrder)
.build();
Drive.DriveApi.getAppFolder(mGoogleApiClient)
.queryChildren(mGoogleApiClient, query)
.setResultCallback(new ResultCallback<DriveApi.MetadataBufferResult>() {
private ArrayList<AutographaGoBackup> backupsArray = new ArrayList<>();
@Override
public void onResult(@NonNull 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 AutographaGoBackup(driveId, modifiedDate, backupSize));
}
mAdapter = new BackupAdapter(BackupActivity.this, backupsArray);
backupRecyclerView.setAdapter(mAdapter);
}
});
} else {
showConnectionError();
reinitializeGoogleApiClient(true, false, false, null);
}
}
示例12: getFileForName
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
public Metadata getFileForName(DriveFolder driveFolder, String filename) {
Query query = new Query.Builder()
.addFilter(Filters.eq(SearchableField.TITLE, filename))
.addFilter(Filters.eq(SearchableField.TRASHED, false))
.build();
DriveApi.MetadataBufferResult r = driveFolder.queryChildren(mClient, query).await();
if (r.getMetadataBuffer().getCount()==0) {
r.release();
return null;
} else {
Metadata r2 = r.getMetadataBuffer().get(0);
r.release();
return r2;
}
}
示例13: scanGoogleDriveForFaces
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
public Observable<List<ImportableFace>> scanGoogleDriveForFaces() {
return Observable.defer(new Func0<Observable<List<ImportableFace>>>() {
@Override
public Observable<List<ImportableFace>> call() {
GoogleApiClient client = googleApiClientManager.getGoogleApiClient();
List<ImportableFace> result = Lists.newArrayList();
// get exiting faces
List<Face> existingFaces = facesManager.getFaces();
Set<String> existingFaceFolders = new HashSet<>();
for (Face existingFace : existingFaces) existingFaceFolders.add(existingFace.getPhotoFolderName());
// search for folders in app root folder
DriveFolder rootFolder = driveManager.getAppRootFolder();
MetadataBuffer queryResult = rootFolder
.queryChildren(client, new Query.Builder().addFilter(Filters.eq(SearchableField.MIME_TYPE, "application/vnd.google-apps.folder")).build())
.await()
.getMetadataBuffer();
// search for images in those folders
Timber.d("found " + queryResult.getCount() + " potential face dirs");
for (Metadata folderMetadata : queryResult) {
// if face is already "imported" then skip it
if (existingFaceFolders.contains(folderMetadata.getTitle())) continue;
List<ImportablePhoto> photos = getPhotos(folderMetadata.getDriveId());
if (!photos.isEmpty()) {
result.add(new ImportableFace(folderMetadata.getTitle(), photos));
}
}
queryResult.release();
return Observable.just(result);
}
});
}
示例14: onConnected
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
@Override
public void onConnected(Bundle bundle) {
final Query query = new Query.Builder()
.addFilter(Filters.eq(SearchableField.MIME_TYPE, "text/xml"))
.addFilter(Filters.eq(SearchableField.TRASHED, false))
.build();
dialog.setMessage(getResources().getString(R.string.dialogBackup2));
Drive.DriveApi.requestSync(mGoogleApiClient)
.setResultCallback(new ResultCallback<Status>() {
@Override
public void onResult(Status result) {
if (!result.isSuccess()) {
showMessage(getResources().getString(R.string.errBackup1));
dialog.dismiss();
return;
}
Drive.DriveApi.query(getGoogleApiClient(), query).setResultCallback(genListFiles);
}
});
}
示例15: queryChildren
import com.google.android.gms.drive.query.Query; //导入依赖的package包/类
public PendingResult<DriveApi.MetadataBufferResult> queryChildren(GoogleApiClient paramGoogleApiClient, Query paramQuery)
{
Query.Builder localBuilder = new Query.Builder().addFilter(Filters.in(SearchableField.PARENTS, getDriveId()));
if (paramQuery != null)
{
if (paramQuery.getFilter() != null)
localBuilder.addFilter(paramQuery.getFilter());
localBuilder.setPageToken(paramQuery.getPageToken());
}
return new h().query(paramGoogleApiClient, localBuilder.build());
}