本文整理汇总了Java中com.google.android.gms.drive.Metadata.isFolder方法的典型用法代码示例。如果您正苦于以下问题:Java Metadata.isFolder方法的具体用法?Java Metadata.isFolder怎么用?Java Metadata.isFolder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.drive.Metadata
的用法示例。
在下文中一共展示了Metadata.isFolder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readRelativeDir
import com.google.android.gms.drive.Metadata; //导入方法依赖的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();
}
示例2: readIconsDir
import com.google.android.gms.drive.Metadata; //导入方法依赖的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();
}
示例3: doInBackground
import com.google.android.gms.drive.Metadata; //导入方法依赖的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;
}
示例4: sync_getFile
import com.google.android.gms.drive.Metadata; //导入方法依赖的package包/类
/**
* Looks for the specified file name (or title).<br><br>
*
* <b>Note</b><br>
* Only returns the first found file if there is more than one file
* with the same filename/title.
*
* @param fileName The file name or title of the desired file.
* @returns DriveFile The desired file or null if there is none. See
* {@link DriveFile}.
*
*/
public synchronized DriveFile sync_getFile(String fileName) throws TBDriveException {
DriveFile driveFile = null;
//Look for a file with title/filename
SortOrder sortOrder = new SortOrder.Builder()
.addSortAscending(SortableField.TITLE)
.addSortDescending(SortableField.MODIFIED_DATE).build();
Query query = new Query.Builder().addFilter(
Filters.and(
Filters.eq(SearchableField.TITLE, fileName)
, Filters.eq(SearchableField.TRASHED, false)
//, Filters.eq(SearchableField.MIME_TYPE, "text/plain")
//, Filters.eq(customPropertyKey, "world")
)
)
.setSortOrder(sortOrder)
.build();
MetadataBufferResult result = Drive.DriveApi.query(getGoogleApiClient(), query).await();
if (!result.getStatus().isSuccess()) {
Log.e(TAG, "Problem while retrieving files: '" + result.getStatus().getStatusMessage() + "'");
result.release();
throw new TBDriveException("Problem while retrieving files: '" + result.getStatus().getStatusMessage() + "'");
}
Iterator<Metadata> iterator = result.getMetadataBuffer().iterator();
Metadata mData = null;
while(iterator.hasNext()) {
mData = iterator.next();
if(!mData.isFolder()){
driveFile = Drive.DriveApi.getFile(getGoogleApiClient(), mData.getDriveId());
if(driveFile==null) {
//Error getting Drive File from id. Should never happen
Log.e(TAG, "Problem while retrieving file with DriveId: " + mData.getDriveId());
result.release();
throw new TBDriveException("Problem while retrieving file with DriveId: " + mData.getDriveId() + ". Not found in Drive!!");
}
}
break; //Should only be one.
}
result.release();
return driveFile;
}