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


Java DriveApi.ContentsResult方法代码示例

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


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

示例1: openContents

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
public PendingResult<DriveApi.ContentsResult> openContents(GoogleApiClient paramGoogleApiClient, final int paramInt, final DriveFile.DownloadProgressListener paramDownloadProgressListener)
{
  if ((paramInt != 268435456) && (paramInt != 536870912) && (paramInt != 805306368))
    throw new IllegalArgumentException("Invalid mode provided.");
  return paramGoogleApiClient.a(new c(paramInt, paramDownloadProgressListener)
  {
    protected void a(j paramAnonymousj)
    {
      try
      {
        paramAnonymousj.cN().a(new OpenContentsRequest(k.this.getDriveId(), paramInt), new k.b(this, paramDownloadProgressListener));
        return;
      }
      catch (RemoteException localRemoteException)
      {
        a(new h.a(new Status(8, localRemoteException.getLocalizedMessage(), null), null));
      }
    }
  });
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:21,代码来源:k.java

示例2: loadFromCloud

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
static public Set<String> loadFromCloud(DriveFile file, GoogleApiClient apiClient)
        throws IOException {
    DriveApi.ContentsResult contentsResult = file.openContents(apiClient,
            DriveFile.MODE_READ_ONLY, null).await();
    checkStatus("Open file for reading", contentsResult.getStatus());

    HashSet<String> result = new HashSet<String>();
    try {
        FileInputStream is = new FileInputStream(contentsResult.getContents()
                .getParcelFileDescriptor().getFileDescriptor());
        String contents = fromStreamToString(is);
        file.discardContents(apiClient, contentsResult.getContents());

        LOGD(TAG, "Contents in the cloud file: [" + contents + "]");

        return fromString(contents);

    } catch (Exception ex) {
        Log.w(TAG, "Ignoring invalid remote content.", ex);
        return null;
    }
}
 
开发者ID:ramonrabello,项目名称:devfestnorte-app,代码行数:23,代码来源:DriveHelper.java

示例3: readRelativeDir

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

示例4: readFile

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
private String readFile(Metadata d) {
    DriveFile file = Drive.DriveApi.getFile(mClient, d.getDriveId());
    DriveApi.ContentsResult contentsResult =
            file.openContents(mClient, DriveFile.MODE_READ_ONLY, null).await();
    if (!contentsResult.getStatus().isSuccess()) {
        return null;
    }
    BufferedReader reader = new BufferedReader(
            new InputStreamReader(contentsResult.getContents().getInputStream()));
    StringBuilder builder = new StringBuilder();
    String line;
    String contents = null;
    try {
        while ((line = reader.readLine()) != null) {
            builder.append(line);
        }
        contents = builder.toString();
    } catch (IOException e) {
        Log.e("GDriveRestoreBackupTask", "IOException while reading from the stream", e);
    }

    file.discardContents(mClient, contentsResult.getContents()).await();
    return contents;
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:25,代码来源:GDriveRestoreBackupTask.java

示例5: newContents

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
public PendingResult<DriveApi.ContentsResult> newContents(GoogleApiClient paramGoogleApiClient)
{
  // Byte code:
  //   0: aload_1
  //   1: new 82	com/google/android/gms/drive/internal/h$2
  //   4: dup
  //   5: aload_0
  //   6: invokespecial 85	com/google/android/gms/drive/internal/h$2:<init>	(Lcom/google/android/gms/drive/internal/h;)V
  //   9: invokevirtual 33	com/google/android/gms/common/api/GoogleApiClient:a	(Lcom/google/android/gms/common/api/a$a;)Lcom/google/android/gms/common/api/a$a;
  //   12: areturn
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:12,代码来源:h.java

示例6: saveToDrive

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
static void saveToDrive(DriveFile file, Set<String> contents,
        GoogleApiClient apiClient) throws IOException {
    DriveApi.ContentsResult contentsResult = file.openContents(apiClient,
            DriveFile.MODE_WRITE_ONLY, null).await();
    checkStatus("Open file for writing", contentsResult.getStatus());
    FileOutputStream os = new FileOutputStream(contentsResult.getContents()
            .getParcelFileDescriptor().getFileDescriptor());
    byte[] serializedContents = toByteArray(contents);
    Log.d(TAG, "Saving contents to drive file: "+new String(serializedContents));
    os.write(serializedContents);
    com.google.android.gms.common.api.Status status =
            file.commitAndCloseContents(apiClient, contentsResult.getContents()).await();
    checkStatus("Commit file contents", status);
}
 
开发者ID:ramonrabello,项目名称:devfestnorte-app,代码行数:15,代码来源:DriveHelper.java

示例7: createNewDriveFile

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
static void createNewDriveFile(Set<String> contents,
        GoogleApiClient apiClient) throws IOException {

    DriveApi.ContentsResult contentsResult = Drive.DriveApi.newContents(apiClient).await();
    checkStatus("creating new file", contentsResult.getStatus());

    //   query Drive for an AppFolder reference (might be slow: ~4s in my tests)
    DriveFolder appDataFolder = Drive.DriveApi.getAppFolder(apiClient);

    //   create a new file in AppFolder
    MetadataChangeSet metadataChangeSet =
            new MetadataChangeSet.Builder()
                    .setMimeType(MIMETYPE_JSON)
                    .setTitle(DRIVE_FILENAME)
                    .build();
    Contents contentsObj = contentsResult.getContents();

    FileOutputStream os = new FileOutputStream(contentsObj.getParcelFileDescriptor().getFileDescriptor());
    os.write(toByteArray(contents));

    DriveFolder.DriveFileResult fileResult = appDataFolder.createFile(
            apiClient, metadataChangeSet, contentsResult.getContents()).await();

    Log.d(TAG, "Content saved to new Drive file: "+new String(toByteArray(contents),
            Charsets.UTF_8));
    checkStatus("saving contents to new file", fileResult.getStatus());

    // DON'T DO THIS: It seems that a bug makes this driveID being unusable later:
    // params.setDriveId(fileResult.getDriveFile().getDriveId());
}
 
开发者ID:ramonrabello,项目名称:devfestnorte-app,代码行数:31,代码来源:DriveHelper.java

示例8: createFile

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
boolean createFile(InputStream input, String filename, DriveFolder target, String mimetype) {
    // New content
    DriveApi.ContentsResult contentsResult =
            Drive.DriveApi.newContents(mClient).await(3, TimeUnit.SECONDS);
    if (!contentsResult.getStatus().isSuccess()) {
        // We failed, stop the task and return.
        return false;
    }

    // Write content
    Contents originalContents = contentsResult.getContents();
    OutputStream os = originalContents.getOutputStream();
    try {
        int read;
        byte[] bytes = new byte[1024];

        while ((read = input.read(bytes)) != -1) {
            os.write(bytes, 0, read);
        }
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }

    // Create the metadata
    MetadataChangeSet originalMetadata = new MetadataChangeSet.Builder()
            .setTitle(filename)
            .setMimeType(mimetype).build();

    // Create the file
    DriveFolder.DriveFileResult fileResult = target.createFile(
            mClient, originalMetadata, originalContents).await(3, TimeUnit.SECONDS);
    return fileResult.getStatus().isSuccess();
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:35,代码来源:GDriveCreateBackupTask.java

示例9: b

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
public b(a.c<DriveApi.ContentsResult> paramc, DriveFile.DownloadProgressListener paramDownloadProgressListener)
{
  this.jW = paramc;
  this.rk = paramDownloadProgressListener;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:6,代码来源:k.java

示例10: o

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
public DriveApi.ContentsResult o(Status paramStatus)
{
  return new h.a(paramStatus, null);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:k.java

示例11: g

import com.google.android.gms.drive.DriveApi; //导入方法依赖的package包/类
public g(a.c<DriveApi.ContentsResult> paramc)
{
  this.jW = paramc;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:h.java


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