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


Java DriveApi.MetadataBufferResult方法代码示例

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


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

示例1: getDriveFile

import com.google.android.gms.drive.DriveApi; //导入方法依赖的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: onResult

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
@Override
        public void onResult(@NonNull final DriveApi.MetadataBufferResult metadataBufferResult) {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    if (metadataBufferResult.getMetadataBuffer().getCount() == 0) {
                        Drive.DriveApi.newDriveContents(mGoogleApiClient).setResultCallback(newDriveFileCallback);
                    } else {
                        if (metadataBufferResult.getMetadataBuffer().get(0).getOriginalFilename().equals(getString(R.string.drive_file_name))) {
                            DriveFile file = metadataBufferResult.getMetadataBuffer().get(0).getDriveId().asDriveFile();
//                              file.open(mGoogleApiClient, DriveFile.MODE_WRITE_ONLY, null).setResultCallback(deleteFileContentDriveCallback);
                            file.open(mGoogleApiClient, DriveFile.MODE_READ_ONLY, null).setResultCallback(updateDataDriveCallback);
                        }
                    }
                }
            }).start();
        }
 
开发者ID:JeanBarriere,项目名称:Note,代码行数:18,代码来源:MainActivity.java

示例3: onResult

import com.google.android.gms.drive.DriveApi; //导入方法依赖的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.DriveApi; //导入方法依赖的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: query

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
public PendingResult<DriveApi.MetadataBufferResult> query(GoogleApiClient paramGoogleApiClient, final Query paramQuery)
{
  if (paramQuery == null)
    throw new IllegalArgumentException("Query must be provided.");
  return paramGoogleApiClient.a(new j(paramQuery)
  {
    protected void a(j paramAnonymousj)
    {
      try
      {
        paramAnonymousj.cN().a(new QueryRequest(paramQuery), new h.i(this));
        return;
      }
      catch (RemoteException localRemoteException)
      {
        a(new h.f(new Status(8, localRemoteException.getLocalizedMessage(), null), null));
      }
    }
  });
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:21,代码来源:h.java

示例6: onResult

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
@Override
public void onResult(@NonNull DriveApi.MetadataBufferResult result) {
    if(!result.getStatus().isSuccess()) {
        Log.w(LOG_TAG, "Retrieving files received error");
    }
    else {
        for(Metadata data : result.getMetadataBuffer()) {
            String fileName = data.getTitle();
            if(fileName != null && fileName.equalsIgnoreCase(SAVED_DATA)) {
                mDriveId = data.getDriveId();
                break;
            }
        }
    }
    if(mDriveId!=null) {
        read();
    }
    else {
        mListener.onSyncFailed(CA.NO_DATA);
    }
    result.release();
}
 
开发者ID:zhuqianqian,项目名称:Passbook,代码行数:23,代码来源:DriveSyncService.java

示例7: getServerItems

import com.google.android.gms.drive.DriveApi; //导入方法依赖的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

示例8: findChild

import com.google.android.gms.drive.DriveApi; //导入方法依赖的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

示例9: onResult

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
@Override
public void onResult(DriveApi.MetadataBufferResult result) {
    if (!result.getStatus().isSuccess()) {
        showMessage("Problem while retrieving files");
        return;
    }

    if (result.getMetadataBuffer().getCount() == 0) {
        //now create a new file as it doesn't exist

        if (type != Constants.TYPE_RESTORE)
            createFile();
        else
           showMessage("No  backup found");

        return;
    }

    DriveId driveId = result.getMetadataBuffer().get(0).getDriveId();

    if (type == Constants.TYPE_RESTORE){
        //for retrieving the content of the file
        new RetrieveDriveFileContentsAsyncTask(SettingsActivity.this).execute(driveId);
    }
    else{
        //for editing the content of the file
        DriveFile file = driveId.asDriveFile();
        new EditContentsAsyncTask(SettingsActivity.this).execute(file);
    }

}
 
开发者ID:webianks,项目名称:HatkeMessenger,代码行数:32,代码来源:SettingsActivity.java

示例10: getFileForName

import com.google.android.gms.drive.DriveApi; //导入方法依赖的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;
    }
}
 
开发者ID:emmanuel-florent,项目名称:flowzr-android-black,代码行数:16,代码来源:ApiClientAsyncTask.java

示例11: getPhotos

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
private List<ImportablePhoto> getPhotos(DriveId faceFolderId) {
	final List<ImportablePhoto> result = Lists.newArrayList();
	final GoogleApiClient client = googleApiClientManager.getGoogleApiClient();

	// TODO pagination has been deprecated, but there is no info if there is a different pagination mechanism now
	DriveApi.MetadataBufferResult queryResult = Drive.DriveApi.getFolder(client, faceFolderId).listChildren(client).await();
	queryResult.getMetadataBuffer().getNextPageToken();
	for (Metadata file : queryResult.getMetadataBuffer()) {
		if (photoManager.isPhotoFileName(file.getTitle())) {
			result.add(new ImportablePhoto(file.getTitle(), file.getDriveId()));
		}
	}
	queryResult.getMetadataBuffer().release();
	return result;
}
 
开发者ID:FauDroids,项目名称:BabyFace,代码行数:16,代码来源:FacesScanner.java

示例12: createFolderIfNeeded

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
private DriveFolder createFolderIfNeeded(DriveFolder root) {
    DriveApi.MetadataBufferResult folders = root.queryChildren(mClient, new Query.Builder()
            .addFilter(Filters.eq(SearchableField.MIME_TYPE, DriveFolder.MIME_TYPE))
            .addFilter(Filters.eq(SearchableField.TITLE, FOLDER_NAME))
            .build()).await();

    if (!folders.getStatus().isSuccess()) {
        Log.d(TAG, "Failed to search metadata");
        return null;
    }
    try {
        if (folders.getMetadataBuffer().getCount() > 0) {
            Log.d(TAG, "Using Existing Folder");
            DriveId id = folders.getMetadataBuffer().get(0).getDriveId();
            return Drive.DriveApi.getFolder(mClient, id);

        } else {
            Log.d(TAG, "Creating Folder");
            DriveFolder.DriveFolderResult folderResult = root.createFolder(mClient,
                    new MetadataChangeSet.Builder()
                            .setTitle(FOLDER_NAME)
                            .build()
            )
                    .await();
            if (!folderResult.getStatus().isSuccess()) {
                Log.e(TAG, "Failed to create folder.");
                return null;
            }
            return folderResult.getDriveFolder();
        }
    } finally {
        folders.getMetadataBuffer().release();
    }
}
 
开发者ID:benbek,项目名称:HereAStory-Android,代码行数:35,代码来源:GameService.java

示例13: onResult

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
@Override
public void onResult(DriveApi.MetadataBufferResult result) {
    if (!result.getStatus().isSuccess()) {
        showMessage("Problem while retrieving results");
        return;
    }
    mResultsAdapter.clear();
    mResultsAdapter.append(result.getMetadataBuffer());
}
 
开发者ID:benbek,项目名称:HereAStory-Android,代码行数:10,代码来源:QuerySortedFilesActivity.java

示例14: readIconsDir

import com.google.android.gms.drive.DriveApi; //导入方法依赖的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

示例15: doInBackground

import com.google.android.gms.drive.DriveApi; //导入方法依赖的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.DriveApi.MetadataBufferResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。