• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Contents类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.google.android.gms.drive.Contents的典型用法代码示例。如果您正苦于以下问题:Java Contents类的具体用法?Java Contents怎么用?Java Contents使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Contents类属于com.google.android.gms.drive包,在下文中一共展示了Contents类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: commitAndCloseContents

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
public PendingResult<Status> commitAndCloseContents(GoogleApiClient paramGoogleApiClient, final Contents paramContents)
{
  // Byte code:
  //   0: aload_2
  //   1: ifnonnull +13 -> 14
  //   4: new 14	java/lang/IllegalArgumentException
  //   7: dup
  //   8: ldc 16
  //   10: invokespecial 19	java/lang/IllegalArgumentException:<init>	(Ljava/lang/String;)V
  //   13: athrow
  //   14: aload_1
  //   15: new 21	com/google/android/gms/drive/internal/k$2
  //   18: dup
  //   19: aload_0
  //   20: aload_2
  //   21: invokespecial 24	com/google/android/gms/drive/internal/k$2:<init>	(Lcom/google/android/gms/drive/internal/k;Lcom/google/android/gms/drive/Contents;)V
  //   24: invokevirtual 30	com/google/android/gms/common/api/GoogleApiClient:b	(Lcom/google/android/gms/common/api/a$a;)Lcom/google/android/gms/common/api/a$a;
  //   27: areturn
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:20,代码来源:k.java


示例2: discardContents

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
public PendingResult<Status> discardContents(GoogleApiClient paramGoogleApiClient, final Contents paramContents)
{
  return paramGoogleApiClient.b(new b(paramContents)
  {
    protected void a(j paramAnonymousj)
    {
      try
      {
        paramAnonymousj.cN().a(new CloseContentsRequest(paramContents, false), new z(this));
        return;
      }
      catch (RemoteException localRemoteException)
      {
        a(new Status(8, localRemoteException.getLocalizedMessage(), null));
      }
    }
  });
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:19,代码来源:h.java


示例3: write

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
public String write(File file, DriveFile mDriveFile) {
	
	ContentsResult mContentsResult = mDriveFile.openContents(mGoogleApiClient, DriveFile.MODE_WRITE_ONLY, null).await();
	if (!mContentsResult.getStatus().isSuccess()) return null;
	
       Contents contents = mContentsResult.getContents();
       try {	
           contents.getOutputStream().write(toByteArray(file));
       } catch (IOException e) {
           e.printStackTrace();
       }
       
       // Commits and closes 
       if (mDriveFile.commitAndCloseContents(mGoogleApiClient, contents).await().isSuccess()) {
       	return mDriveFile.getDriveId().getResourceId();
       } else {
       	return null;
       }
}
 
开发者ID:kanpol,项目名称:omni-note,代码行数:20,代码来源:DriveHelper.java


示例4: readRelativeDir

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


示例5: CreateFileRequest

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
CreateFileRequest(int paramInt, DriveId paramDriveId, MetadataBundle paramMetadataBundle, Contents paramContents)
{
  this.kg = paramInt;
  this.ra = ((DriveId)eg.f(paramDriveId));
  this.qZ = ((MetadataBundle)eg.f(paramMetadataBundle));
  this.qX = ((Contents)eg.f(paramContents));
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:8,代码来源:CreateFileRequest.java


示例6: createFile

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
public PendingResult<DriveFolder.DriveFileResult> createFile(GoogleApiClient paramGoogleApiClient, final MetadataChangeSet paramMetadataChangeSet, final Contents paramContents)
{
  if (paramMetadataChangeSet == null)
    throw new IllegalArgumentException("MetatadataChangeSet must be provided.");
  if (paramContents == null)
    throw new IllegalArgumentException("Contents must be provided.");
  if ("application/vnd.google-apps.folder".equals(paramMetadataChangeSet.getMimeType()))
    throw new IllegalArgumentException("May not create folders (mimetype: application/vnd.google-apps.folder) using this method. Use DriveFolder.createFolder() instead.");
  return paramGoogleApiClient.b(new i()
  {
    protected void a(j paramAnonymousj)
    {
      try
      {
        paramContents.close();
        paramAnonymousj.cN().a(new CreateFileRequest(l.this.getDriveId(), paramMetadataChangeSet.cM(), paramContents), new l.a(this));
        return;
      }
      catch (RemoteException localRemoteException)
      {
        a(new l.d(new Status(8, localRemoteException.getLocalizedMessage(), null), null));
      }
    }

    public DriveFolder.DriveFileResult q(Status paramAnonymousStatus)
    {
      return new l.d(paramAnonymousStatus, null);
    }
  });
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:31,代码来源:l.java


示例7: createNewDriveFile

import com.google.android.gms.drive.Contents; //导入依赖的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: save

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
/**
 * Saves meta data and content changes.
 */
private void save() {
    Log.d(TAG, "Saving...");
    if (mCurrentDriveId == null) {
        return;
    }
    new EditDriveFileAsyncTask(mGoogleApiClient) {
        @Override
        public Changes edit(Contents contents) {
            MetadataChangeSet metadataChangeSet = new MetadataChangeSet.Builder()
                    .setTitle(mTitleEditText.getText().toString()).build();
            try {
                byte[] body = mContentsEditText.getText().toString().getBytes();
                contents.getOutputStream().write(body);
            } catch (IOException e) {
                Log.e(TAG, "IOException while reading from contents output stream", e);
            }
            return new Changes(metadataChangeSet, contents);
        }

        @Override
        protected void onPostExecute(com.google.android.gms.common.api.Status status) {
            if (!status.getStatus().isSuccess()) {
                showToast(R.string.msg_errsaving);
                return;
            }
            showToast(R.string.msg_saved);
        }
    }.execute(mCurrentDriveId);
}
 
开发者ID:TerribleDev,项目名称:XamarinAdmobTutorial,代码行数:33,代码来源:HomeActivity.java


示例9: doInBackground

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


示例10: createFile

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


示例11: discardContents

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
public PendingResult<Status> discardContents(GoogleApiClient paramGoogleApiClient, Contents paramContents)
{
  return Drive.DriveApi.discardContents(paramGoogleApiClient, paramContents);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:k.java


示例12: CloseContentsRequest

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
CloseContentsRequest(int paramInt, Contents paramContents, Boolean paramBoolean)
{
  this.kg = paramInt;
  this.qX = paramContents;
  this.qY = paramBoolean;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:7,代码来源:CloseContentsRequest.java


示例13: OnContentsResponse

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
OnContentsResponse(int paramInt, Contents paramContents)
{
  this.kg = paramInt;
  this.qK = paramContents;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:6,代码来源:OnContentsResponse.java


示例14: cQ

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
public Contents cQ()
{
  return this.qK;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:OnContentsResponse.java


示例15: a

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
public a(Status paramStatus, Contents paramContents)
{
  this.jY = paramStatus;
  this.qK = paramContents;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:6,代码来源:h.java


示例16: getContents

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
public Contents getContents()
{
  return this.qK;
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:h.java


示例17: onCreate

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mLogArea = new TextView(this);

    ApiClientAsyncTask<Void, Void, String> task = new ApiClientAsyncTask<Void, Void, String>(this) {
        @Override
        protected String doInBackgroundConnected(Void[] params) {
            StringBuffer result = new StringBuffer();
            MetadataBuffer buffer = Drive.DriveApi.getAppFolder(getGoogleApiClient())
                    .listChildren(getGoogleApiClient()).await().getMetadataBuffer();

            result.append("found " + buffer.getCount() + " files:\n");
            for (Metadata m: buffer) {
                DriveId id = m.getDriveId();
                DriveFile file = Drive.DriveApi.getFile(getGoogleApiClient(), id);

                Contents contents = file.openContents( getGoogleApiClient(),
                        DriveFile.MODE_READ_ONLY, null).await().getContents();

                FileInputStream is = new FileInputStream(contents.getParcelFileDescriptor().getFileDescriptor());
                try {
                    BufferedReader bf = new BufferedReader(new InputStreamReader(is, Charsets.UTF_8));
                    String line=null; StringBuffer sb=new StringBuffer();
                    while ((line=bf.readLine()) != null ) {
                        sb.append(line);
                    }
                    file.discardContents(getGoogleApiClient(), contents);
                    result.append("*** " + m.getTitle() + "/" + id + "/" + m.getFileSize() + "B:\n   [" + sb.toString() + "]\n");
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            buffer.close();
            return result.toString();
        }

        @Override
        protected void onPostExecute(String s) {
            if (mLogArea != null) {
                mLogArea.append(s);
            }
        }
    };
    task.execute();

}
 
开发者ID:ramonrabello,项目名称:devfestnorte-app,代码行数:48,代码来源:ViewFilesInAppFolderActivity.java


示例18: doInBackgroundConnected

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
@Override
protected Metadata doInBackgroundConnected(Void... arg0) {

    // First we start by creating a new contents, and blocking on the
    // result by calling await().
    ContentsResult contentsResult =
            Drive.DriveApi.newContents(getGoogleApiClient()).await();
    if (!contentsResult.getStatus().isSuccess()) {
        // We failed, stop the task and return.
        return null;
    }

    // Read the contents and open its output stream for writing, then
    // write a short message.
    Contents originalContents = contentsResult.getContents();
    OutputStream os = originalContents.getOutputStream();
    try {
        os.write("Hello world!\n".getBytes());
    } catch (IOException e) {
        e.printStackTrace();
        return null;
    }

    // Create the metadata for the new file including title and MIME
    // type.
    MetadataChangeSet originalMetadata = new MetadataChangeSet.Builder()
            .setTitle("AsyncTaskFile.txt")
            .setMimeType("text/plain").build();

    // Create the file in the root folder, again calling await() to
    // block until the request finishes.
    DriveFolder rootFolder = Drive.DriveApi.getRootFolder(getGoogleApiClient());
    DriveFileResult fileResult = rootFolder.createFile(
            getGoogleApiClient(), originalMetadata, originalContents).await();
    if (!fileResult.getStatus().isSuccess()) {
        // We failed, stop the task and return.
        return null;
    }

    // Finally, fetch the metadata for the newly created file, again
    // calling await to block until the request finishes.
    MetadataResult metadataResult = fileResult.getDriveFile()
            .getMetadata(getGoogleApiClient())
            .await();
    if (!metadataResult.getStatus().isSuccess()) {
        // We failed, stop the task and return.
        return null;
    }
    // We succeeded, return the newly created metadata.
    return metadataResult.getMetadata();
}
 
开发者ID:TerribleDev,项目名称:XamarinAdmobTutorial,代码行数:52,代码来源:SyncRequestsActivity.java


示例19: Changes

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
public Changes(MetadataChangeSet metadataChangeSet, Contents contents) {
  mMetadataChangeSet = metadataChangeSet;
  mContents = contents;
}
 
开发者ID:TerribleDev,项目名称:XamarinAdmobTutorial,代码行数:5,代码来源:EditDriveFileAsyncTask.java


示例20: getContents

import com.google.android.gms.drive.Contents; //导入依赖的package包/类
public Contents getContents() {
  return mContents;
}
 
开发者ID:TerribleDev,项目名称:XamarinAdmobTutorial,代码行数:4,代码来源:EditDriveFileAsyncTask.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ObjectType类代码示例发布时间:2022-05-23
下一篇:
Java WrapperIterator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap