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


Java MetadataBuffer.getCount方法代码示例

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


在下文中一共展示了MetadataBuffer.getCount方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例6: 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

示例7: 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

示例8: doInBackground

import com.google.android.gms.drive.MetadataBuffer; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Void... params) {
	Log.d("DEBUG", "Performing Drive first sync.");
	
	Query q = new Query.Builder()
					   .addFilter(Filters.eq(SearchableField.TRASHED, false))
					   .addFilter(Filters.eq(SearchableField.MIME_TYPE, "text/plain"))
					   .build();
	
	MetadataBuffer mb = Inbox_DriveFolder.queryChildren(mGoogleApiClient, q).await().getMetadataBuffer();
	
	if (mb.getCount() > 0) { 
		for (Metadata m : mb) {
			Log.d("DEBUG", "Retriving " + m.getTitle() + " from Drive.");
			long uid = Long.parseLong(m.getTitle().split("_")[1]);
			DriveFile f = Drive.DriveApi.getFile(mGoogleApiClient, m.getDriveId());
			Contents b = f.openContents(mGoogleApiClient, DriveFile.MODE_READ_ONLY, null).await().getContents();
			try {
				MimeMessage msg = new MimeMessage((Session)null, b.getInputStream());
				storeSingleMessageFromDrive(msg, uid, true);
			} catch (MessagingException e) {
				e.printStackTrace();
			}
		}
	}
	else {
		Log.d("DEBUG", "No email found in Inbox folder.");
	}
	
	return null;
}
 
开发者ID:ruvolof,项目名称:battleclient-android,代码行数:32,代码来源:EmailClientService.java

示例9: readIconsDir

import com.google.android.gms.drive.MetadataBuffer; //导入方法依赖的package包/类
void readIconsDir(Context context, MetadataBuffer children) {
    for (int i = 0; i < children.getCount(); ++i) {
        Metadata d = children.get(i);
        if (!d.isFolder())
            continue;

        boolean found = false;
        for (Icons.IconType iconType : Icons.IconType.values()) {
            for (Icons.IconState state : Icons.IconState.values()) {
                String relativePath = iconType.name() + state.name();
                if (d.getTitle().equals(relativePath)) {
                    DriveFolder iconsDir = Drive.DriveApi.getFolder(mClient, d.getDriveId());
                    DriveApi.MetadataBufferResult resultIconsDir = iconsDir.listChildren(mClient).await();
                    if (!resultIconsDir.getStatus().isSuccess()) {
                        continue;
                    }
                    readRelativeDir(context, iconType, state, resultIconsDir.getMetadataBuffer());
                    found = true;
                    break;
                }
            }
            if (found)
                break;
        }
    }
    children.close();
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:28,代码来源:GDriveRestoreBackupTask.java

示例10: doInBackground

import com.google.android.gms.drive.MetadataBuffer; //导入方法依赖的package包/类
@Override
protected Boolean doInBackground(Void... params) {

    // Create folder
    DriveFolder backupDir = Drive.DriveApi.getFolder(mClient, driveId);
    DriveApi.MetadataBufferResult result = backupDir.listChildren(mClient).await();
    if (!result.getStatus().isSuccess()) {
        // We failed, stop the task and return.
        return false;
    }

    MetadataBuffer b = null;
    try {
        b = result.getMetadataBuffer();
        for (int i = 0; i < b.getCount(); ++i) {
            Metadata d = b.get(i);
            if (d.getTitle().equals("scenes.json")) {
                scenes = readFile(d);
            } else if (d.getTitle().equals("groups.json")) {
                groups = readFile(d);
            } else if (d.getTitle().equals("devices.json")) {
                devices = readFile(d);
            } else if (d.isFolder() && d.getTitle().equals("icons")) {
                DriveFolder iconsDir = Drive.DriveApi.getFolder(mClient, d.getDriveId());
                DriveApi.MetadataBufferResult resultIconsDir = iconsDir.listChildren(mClient).await();
                if (!resultIconsDir.getStatus().isSuccess()) {
                    // We failed, stop the task and return.
                    continue;
                }
                readIconsDir(context, resultIconsDir.getMetadataBuffer());
            }
        }
    } finally {
        if (b != null) b.close();
    }

    return true;
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:39,代码来源:GDriveRestoreBackupTask.java

示例11: onResult

import com.google.android.gms.drive.MetadataBuffer; //导入方法依赖的package包/类
@Override
public void onResult(DriveApi.MetadataBufferResult result) {

    if (!result.getStatus().isSuccess()) {

        return;
    }


    itemsName.clear();
    itemsId.clear();

    MetadataBuffer files = result.getMetadataBuffer();
    if (files.getCount() > 0) {
        for (int i = files.getCount() - 1; i >= 0; i--) {
            itemsName.add(files.get(i).getTitle().replace("-", "/").replace(".xml", "").replace(".", ":").replace("PL", "Backup"));
            itemsId.add(files.get(i).getDriveId().getResourceId());
        }

        ArrayAdapter<String> filesXML = new ArrayAdapter<String>(MainActivity.this, R.layout.list_item_backup, itemsName);


        new AlertDialog.Builder(MainActivity.this)
                .setAdapter(filesXML, new DialogInterface.OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialogList, int which) {

                        dialog.setMessage(getResources().getString(R.string.dialogBackup4));
                        dialog.show();
                        Drive.DriveApi.fetchDriveId(getGoogleApiClient(), itemsId.get(which))
                                .setResultCallback(idCallback);
                    }
                })
                .setCancelable(true).setTitle(R.string.RestoreTitle)
                .show();


    } else {
        Toast.makeText(MainActivity.this, getResources().getString(R.string.noBackups), Toast.LENGTH_SHORT).show();
    }
    dialog.dismiss();


}
 
开发者ID:rulogarcillan,项目名称:PainLog,代码行数:46,代码来源:MainActivity.java


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