本文整理汇总了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!");
}
}
示例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;
}
}
示例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());
}
示例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);
}
}
示例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;
}
}