当前位置: 首页>>代码示例>>Java>>正文


Java MetadataBuffer类代码示例

本文整理汇总了Java中com.google.android.gms.drive.MetadataBuffer的典型用法代码示例。如果您正苦于以下问题:Java MetadataBuffer类的具体用法?Java MetadataBuffer怎么用?Java MetadataBuffer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MetadataBuffer类属于com.google.android.gms.drive包,在下文中一共展示了MetadataBuffer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDriveFile

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的package包/类
/**
 * Returns the app specific {@link DriveFile} if it has already been created. Else
 * returns null.
 */
protected final DriveFile getDriveFile() {
    DebugLog.logMethod();

    DriveApi.MetadataBufferResult metadataBufferResult = Drive.DriveApi.getAppFolder(getGoogleApiClient())
            .listChildren(getGoogleApiClient())
            .await();
    DebugLog.logMessage("Status code: " + metadataBufferResult.getStatus().getStatusCode()
            + "\nStatus message: " + metadataBufferResult.getStatus().getStatusMessage());
    if (!metadataBufferResult.getStatus().isSuccess()) {
        metadataBufferResult.release();
        DebugLog.logMessage("MetadataBufferResult failure");
        return null;
    }

    MetadataBuffer metadataBuffer = metadataBufferResult.getMetadataBuffer();
    DebugLog.logMessage("MetadataBuffer count: " + metadataBuffer.getCount());
    if (metadataBuffer.getCount() == 0) {
        metadataBuffer.release();
        return null;
    }
    DriveId driveId = metadataBuffer.get(0).getDriveId();
    metadataBuffer.release();
    metadataBufferResult.release();
    return driveId.asDriveFile();
}
 
开发者ID:darsh2,项目名称:CouponsTracker,代码行数:30,代码来源:GoogleDriveService.java

示例2: getDriveFile

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的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;
}
 
开发者ID:ultramega,项目名称:flavordex,代码行数:27,代码来源:PhotoSyncHelper.java

示例3: onResult

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的package包/类
/**
 * Handles the result of the query. If the results are nonzero, passes up the {@link Metadata}
 * out of the result one at a time through {@link QuerierResultCallback#onQuerierResult(Metadata)}
 * with the {@link QuerierResultCallback} registered in ths {@link Querier}. If the results are
 * null, calls {@link QuerierResultCallback#onNoQuerierResult()}
 *
 * @param result the result of the query
 */
@Override
public void onResult(DriveApi.MetadataBufferResult result) {
    if (!result.getStatus().isSuccess()) {
        Log.e("Querier", "Problem while retrieving files");
        return;
    }

    // Get the metadata buffer
    MetadataBuffer buffer = result.getMetadataBuffer();

    // Check for file dne
    if (buffer.getCount() == 0) {
        // Call null result callback
        callback.onNoQuerierResult();
    }

    // Get the metadata
    for (Metadata m : buffer) {
        if (m.isInAppFolder() && !m.isTrashed()) {
            callback.onQuerierResult(m);
            break;
        }
    }
}
 
开发者ID:akilawickey,项目名称:pinPotha,代码行数:33,代码来源:Querier.java

示例4: onResult

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的package包/类
/**
 * Handles the result of the query. If the results are nonzero, passes up the {@link Metadata}
 * out of the result one at a time through {@link QuerierResultCallback#onQuerierResult(Metadata)}
 * with the {@link QuerierResultCallback} registered in ths {@link Querier}. If the results are
 * null, calls {@link QuerierResultCallback#onNoQuerierResult()}
 * @param result the result of the query
 */
@Override
public void onResult(DriveApi.MetadataBufferResult result) {
    if (!result.getStatus().isSuccess()) {
        Log.e("Querier", "Problem while retrieving files");
        return;
    }

    // Get the metadata buffer
    MetadataBuffer buffer = result.getMetadataBuffer();

    // Check for file dne
    if (buffer.getCount() == 0) {
        // Call null result callback
        callback.onNoQuerierResult();
    }

    // Get the metadata
    for (Metadata m : buffer) {
        if (m.isInAppFolder() && !m.isTrashed()) {
            callback.onQuerierResult(m);
            break;
        }
    }
}
 
开发者ID:akilawickey,项目名称:pinPotha,代码行数:32,代码来源:Querier.java

示例5: deleteFolder

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的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);
		}
	});
}
 
开发者ID:FauDroids,项目名称:BabyFace,代码行数:23,代码来源:GoogleDriveManager.java

示例6: readFileContent

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的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);
                }
            });
}
 
开发者ID:codlab,项目名称:amiibo,代码行数:23,代码来源:FileManager.java

示例7: readFileFromDrive

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的package包/类
@DebugLog
private void readFileFromDrive(final MetadataBuffer meta_data, final DriveId drive_id) {
    Drive.DriveApi.getFile(_parent.getClient(), drive_id)
            .open(_parent.getClient(), DriveFile.MODE_READ_ONLY, null)
            .setResultCallback(new ResultCallback<DriveApi.DriveContentsResult>() {
                @Override
                public void onResult(DriveApi.DriveContentsResult driveContentsResult) {
                    try {
                        InputStream input = driveContentsResult.getDriveContents()
                                .getInputStream();
                        String total = consumeStream(input);

                        AmiiboFile amiibo_file = AmiiboFile.fromString(total.toString());
                        _parent.onFileRead(amiibo_file);
                        if (!meta_data.isClosed()) meta_data.release();
                    } catch (IOException e) {
                        e.printStackTrace();
                        _parent.onFileRead(null);
                    }
                }
            });
}
 
开发者ID:codlab,项目名称:amiibo,代码行数:23,代码来源:FileManager.java

示例8: getServerItems

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的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;
}
 
开发者ID:BoD,项目名称:bikey,代码行数:26,代码来源:GoogleDriveSyncManager.java

示例9: refresh

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的package包/类
/**
 * Invokes calls to query user's Google Drive root folder's children with
 * the currently selected query.
 */
private void refresh() {
    mResultsAdapter.clear();
    getDriveResourceClient()
            .query(sQueries[mSelectedIndex])
            .continueWith(new Continuation<MetadataBuffer, Void>() {
                @Override
                public Void then(@NonNull Task<MetadataBuffer> task) throws Exception {
                    MetadataBuffer metadata = task.getResult();
                    Log.d(TAG, "Retrieved file count: " + metadata.getCount());
                    mResultsAdapter.append(metadata);
                    return null;
                }
            })
            .addOnFailureListener(new OnFailureListener() {
                @Override
                public void onFailure(@NonNull Exception e) {
                    Log.e(TAG, "Error while retrieving files", e);
                    showMessage(getString(R.string.msg_errorretrieval));
                }
            });
}
 
开发者ID:googledrive,项目名称:android-querying,代码行数:26,代码来源:HomeActivity.java

示例10: findChild

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的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;
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:25,代码来源:GDrive.java

示例11: readRelativeDir

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的package包/类
void readRelativeDir(Context context, Icons.IconType iconType, Icons.IconState state, MetadataBuffer children) {
    for (int i = 0; i < children.getCount(); ++i) {
        Metadata d = children.get(i);
        if (!d.isFolder()) {
            DriveFile file = Drive.DriveApi.getFile(mClient, d.getDriveId());
            DriveApi.ContentsResult contentsResult =
                    file.openContents(mClient, DriveFile.MODE_READ_ONLY, null).await();
            if (!contentsResult.getStatus().isSuccess()) {
                continue;
            }
            Contents r = contentsResult.getContents();
            Icons.saveIcon(context, d.getTitle(), iconType, state, r.getInputStream());
        }
    }
    children.close();
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:17,代码来源:GDriveRestoreBackupTask.java

示例12: doInBackground

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的package包/类
@Override
protected String doInBackground(Void... params) {
    DriveHelper helper = new DriveHelper(mGoogleApiClient);
    StringBuilder result = new StringBuilder();
    MetadataBuffer buffer = Drive.DriveApi.getAppFolder(mGoogleApiClient)
            .listChildren(mGoogleApiClient).await().getMetadataBuffer();
    try {
        result.append("found ").append(buffer.getCount())
                .append(" file(s):").append(EOL)
                .append("----------").append(EOL);

        for (Metadata m : buffer) {
            DriveId id = m.getDriveId();
            result.append("Name: ").append(m.getTitle()).append(EOL);
            result.append("MimeType: ").append(m.getMimeType()).append(EOL);
            result.append(id.encodeToString()).append(EOL);
            result.append("LastModified: ").append(m.getModifiedDate().getTime())
                    .append(EOL);
            String content = helper.getContentsFromDrive(id);
            result.append("--------").append(EOL)
                    .append(content).append(EOL);
            result.append("--------");
        }
    } catch (IOException io) {
        result.append("Exception fetching content").append(EOL);
    } finally {
        buffer.close();
    }
    return result.toString();
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:31,代码来源:ViewFilesInAppFolderActivity.java

示例13: getDriveFile

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的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();
        }
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:32,代码来源:DriveHelper.java

示例14: getBackupsFromDrive

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的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);
    }
}
 
开发者ID:friendsofagape,项目名称:Autographa-Go,代码行数:38,代码来源:BackupActivity.java

示例15: scanGoogleDriveForFaces

import com.google.android.gms.drive.MetadataBuffer; //导入依赖的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);
		}
	});
}
 
开发者ID:FauDroids,项目名称:BabyFace,代码行数:37,代码来源:FacesScanner.java


注:本文中的com.google.android.gms.drive.MetadataBuffer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。