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


Java MediaHttpUploader.getProgress方法代码示例

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


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

示例1: progressChanged

import com.google.api.client.googleapis.media.MediaHttpUploader; //导入方法依赖的package包/类
@Override
public void progressChanged(MediaHttpUploader uploader) throws IOException {
    if (uploader == null) return;
    switch (uploader.getUploadState()) {
        case INITIATION_STARTED:
            //System.out.println("Initiation has started!");
            break;
        case INITIATION_COMPLETE:
            //System.out.println("Initiation is complete!");
            break;
        case MEDIA_IN_PROGRESS:
            int percent = (int) (uploader.getProgress() * 100);
            mBuilder.setProgress(100, percent, false);
            mNotifyMgr.notify(NOTIFICATION_ID, mBuilder.build());
            break;
        case MEDIA_COMPLETE:
            //System.out.println("Upload is complete!");
    }
}
 
开发者ID:rockwotj,项目名称:Cam2PDF,代码行数:20,代码来源:UpvertTask.java

示例2: progressChanged

import com.google.api.client.googleapis.media.MediaHttpUploader; //导入方法依赖的package包/类
@Override
public void progressChanged(MediaHttpUploader uploader) throws IOException {
	switch (uploader.getUploadState()) {
	case NOT_STARTED:
		break;
	case INITIATION_STARTED:
		worked = 0;
		monitor.subTask("Upload Initiation has started");
		break;
	case INITIATION_COMPLETE:
		monitor.subTask("Upload Initiation is complete");
		break;
	case MEDIA_IN_PROGRESS:
		monitor.subTask("Upload in progress");
		int progress = (int) (uploader.getProgress() * 100);
		monitor.worked(progress - worked);
		worked += progress - worked;
		break;
	case MEDIA_COMPLETE:
		monitor.subTask("Upload completed");
		monitor.done();
		break;

	default:
		break;
	}
}
 
开发者ID:cchabanois,项目名称:mesfavoris,代码行数:28,代码来源:FileUploadProgressListener.java

示例3: notifyProgress

import com.google.api.client.googleapis.media.MediaHttpUploader; //导入方法依赖的package包/类
private void notifyProgress(YouTubeUploader.UploadProgress uploadProgress) {
    Context context = application.getApplicationContext();

    NotificationCompat.Builder builder = baseBuilder(context, message)
            .setContentText(context.getString(R.string.sending_message))
            .setOngoing(true);

    // There are basically three states:
    //  1. uploader == null: indeterminate progress, no info.
    //  2. uploader != null AND uploader.getUploadState() in (INITIATION_STARTED, INITIATION_COMPLETE):
    //      indeterminate progress, no info.
    //  3. progress, info.
    double progress = 0;
    String contentInfo = null;
    boolean indeterminate = true;

    MediaHttpUploader uploader = uploadProgress.getMediaHttpUploader();

    if (uploader != null && (
            uploader.getUploadState() == MediaHttpUploader.UploadState.MEDIA_COMPLETE
            || uploader.getUploadState() == MediaHttpUploader.UploadState.MEDIA_IN_PROGRESS)) {
        try {
            progress = uploader.getProgress();
        } catch (IOException e) {
            // Do nothing.
        }
        // TODO Use localized percentage string (I guess NumberFormat does it)
        contentInfo = String.format("%.2f%%", progress * 100);
        indeterminate = false;
    }

    // XXX 1000 to make it smoother than 100.
    final int max = 1000;

    builder.setProgress(max, (int) (progress * max), indeterminate);
    builder.setContentInfo(contentInfo);

    notify(context, builder.build());
}
 
开发者ID:labhackercd,项目名称:edm,代码行数:40,代码来源:AddMessageTask.java

示例4: handleUploadProgress

import com.google.api.client.googleapis.media.MediaHttpUploader; //导入方法依赖的package包/类
private void handleUploadProgress(YouTubeUploader.UploadProgress progress) {
    // TODO Animate the progress bar in and out?
    if (progress.getInsertedVideo() != null) {
        progressBar.setVisibility(View.GONE);
    } else {
        double uploadProgress = 0;
        boolean indeterminate = true;

        MediaHttpUploader uploader = progress.getMediaHttpUploader();
        if (uploader != null && (
                uploader.getUploadState() == MediaHttpUploader.UploadState.MEDIA_IN_PROGRESS
                || uploader.getUploadState() == MediaHttpUploader.UploadState.MEDIA_COMPLETE)) {
            try {
                uploadProgress = uploader.getProgress();
                indeterminate = false;
            } catch (IOException e) {
                // Do nothing.
            }
        }

        // XXX 1000 to make it smoother than 100.
        final int max = 1000;
        progressBar.setMax(max);
        progressBar.setProgress((int) (uploadProgress * max));
        progressBar.setIndeterminate(indeterminate);
        progressBar.setVisibility(View.VISIBLE);
    }
}
 
开发者ID:labhackercd,项目名称:edm,代码行数:29,代码来源:MessageListAdapter.java

示例5: progressChanged

import com.google.api.client.googleapis.media.MediaHttpUploader; //导入方法依赖的package包/类
@Override
public void progressChanged(MediaHttpUploader mediaHttpUploader) throws IOException
{
	if (mediaHttpUploader == null) return;

	switch ( mediaHttpUploader.getUploadState() )
	{
		case INITIATION_COMPLETE:
			break;
		case INITIATION_STARTED:
		case MEDIA_IN_PROGRESS:

			this.connector.refreshCredential();

			double percent = mediaHttpUploader.getProgress() * 100;

			long currentTime = System.currentTimeMillis();

			String msg = "\r  " + df.format(Math.ceil(percent)) + "% (" + convertToKB(mediaHttpUploader.getNumBytesUploaded()) + " of "
					+ convertToKB(length) + " kb)";

			if (mediaHttpUploader.getUploadState().equals(UploadState.MEDIA_IN_PROGRESS))
			{
				long speed = convertToKB((mediaHttpUploader.getNumBytesUploaded() - lastBytes) / ((currentTime - lastTime) / 1000.0));
				msg += " - " + speed + " kb/s";
			}

			LOGGER.log(Level.FINEST, msg, true);

			lastTime = currentTime;
			lastBytes = mediaHttpUploader.getNumBytesUploaded();
			break;
		case MEDIA_COMPLETE:
			// System.out.println("Upload is complete!");
		default:
			break;
	}
}
 
开发者ID:HolgerHees,项目名称:cloudsync,代码行数:39,代码来源:RemoteGoogleDriveConnector.java


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