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


Java MetadataBuffer.get方法代码示例

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


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

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

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

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


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