本文整理汇总了Java中com.google.android.gms.drive.query.Filters类的典型用法代码示例。如果您正苦于以下问题:Java Filters类的具体用法?Java Filters怎么用?Java Filters使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Filters类属于com.google.android.gms.drive.query包,在下文中一共展示了Filters类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showGDriveFolderSelector
import com.google.android.gms.drive.query.Filters; //导入依赖的package包/类
private static void showGDriveFolderSelector(Activity activity) {
if (activity == null)
return;
OpenFileActivityBuilder openFileActivityBuilder = Drive.DriveApi
.newOpenFileActivityBuilder();
if (openFileActivityBuilder != null) {
IntentSender intentSender = openFileActivityBuilder.setActivityTitle(AndiCar.getAppResources().getString(R.string.pref_secure_backup_gdrive_folder_selector_title))
.setSelectionFilter(Filters.eq(SearchableField.MIME_TYPE, DriveFolder.MIME_TYPE))
.build(mGoogleApiClient);
try {
activity.startIntentSenderForResult(
intentSender, ConstantValues.REQUEST_OPEN_DRIVE_FOLDER, null, 0, 0, 0);
}
catch (IntentSender.SendIntentException e) {
Log.i("AndiCar", "Failed to launch file chooser.");
}
}
else {
Toast.makeText(activity, "Unable to open folder selector!", Toast.LENGTH_LONG).show();
}
}
示例2: queryFile
import com.google.android.gms.drive.query.Filters; //导入依赖的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());
});
}
示例3: getDriveFile
import com.google.android.gms.drive.query.Filters; //导入依赖的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;
}
示例4: deleteFolder
import com.google.android.gms.drive.query.Filters; //导入依赖的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);
}
});
}
示例5: readFileContent
import com.google.android.gms.drive.query.Filters; //导入依赖的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);
}
});
}
示例6: findChild
import com.google.android.gms.drive.query.Filters; //导入依赖的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;
}
示例7: getDriveFile
import com.google.android.gms.drive.query.Filters; //导入依赖的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();
}
}
}
示例8: findFile
import com.google.android.gms.drive.query.Filters; //导入依赖的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);
}
示例9: findFile
import com.google.android.gms.drive.query.Filters; //导入依赖的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: getBackupsFromDrive
import com.google.android.gms.drive.query.Filters; //导入依赖的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);
}
}
示例11: getFileForName
import com.google.android.gms.drive.query.Filters; //导入依赖的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;
}
}
示例12: scanGoogleDriveForFaces
import com.google.android.gms.drive.query.Filters; //导入依赖的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);
}
});
}
示例13: onConnected
import com.google.android.gms.drive.query.Filters; //导入依赖的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);
}
});
}
示例14: queryChildren
import com.google.android.gms.drive.query.Filters; //导入依赖的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());
}
示例15: onConnected
import com.google.android.gms.drive.query.Filters; //导入依赖的package包/类
@Override
public void onConnected(Bundle connectionHint) {
super.onConnected(connectionHint);
Query query = new Query.Builder()
.addFilter(Filters.eq(SearchableField.MIME_TYPE, "text/plain"))
.build();
Drive.DriveApi.query(getGoogleApiClient(), query)
.setResultCallback(metadataCallback);
}