Android Open Source - VideoExtand Progress Output Stream






From Project

Back to project page VideoExtand.

License

The source code is released under:

Apache License

If you think the Android project VideoExtand listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * //from   w w w . j a  v a  2s  . c o m
 */
package com.yuninfo.videoextand.uploader;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * ??????????
 * @author zhangyy@yuninfo.com
 *
 */
public class ProgressOutputStream extends FilterOutputStream {

  private ProgressListener<Long> mProgressListener = null;
  private long mContentLength = 0L;
  private long mProgress = 0L;
  
  public ProgressOutputStream(OutputStream out) {
    super(out);
  }
  
  public ProgressOutputStream(OutputStream out, long contentLength, final ProgressListener<Long> listener) {
    super(out);
    this.mProgressListener = listener;
    this.mContentLength = contentLength;
    this.mProgress = 0;
  }
  
  @Override
  public void write(byte[] buffer) throws IOException {
    out.write(buffer);
    mProgress += buffer.length;
    //?????????????????????
    if(mProgressListener != null) {
      mProgressListener.onProgressUpdate(mProgress, mContentLength);
    }
  }
  
  @Override
  public void write(byte[] buffer, int offset, int length) throws IOException {
    out.write(buffer, offset, length);
    mProgress += length;
    //?????????????????????
    if(mProgressListener != null) {
      mProgressListener.onProgressUpdate(mProgress, mContentLength);
    }
  }
  
  @Override
  public void write(int oneByte) throws IOException {
    out.write(oneByte);
    mProgress++;
    //?????????????????????
    if(mProgressListener != null) {
      mProgressListener.onProgressUpdate(mProgress, mContentLength);
    }
  }
  
}




Java Source Code List

com.example.androidtest.MainActivity.java
com.yuninfo.videoextand.BaseActivity.java
com.yuninfo.videoextand.Config.java
com.yuninfo.videoextand.ReadCardActivity.java
com.yuninfo.videoextand.SendCardActivity.java
com.yuninfo.videoextand.bean.CommonReq.java
com.yuninfo.videoextand.bean.ReadVideoResp.java
com.yuninfo.videoextand.bean.SendVideoResp.java
com.yuninfo.videoextand.bean.UploadReq.java
com.yuninfo.videoextand.bean.UploadResp.java
com.yuninfo.videoextand.player.VideoPlayerActivity.java
com.yuninfo.videoextand.recorder.RecorderActivity.java
com.yuninfo.videoextand.uploader.ProgressListener.java
com.yuninfo.videoextand.uploader.ProgressMultipartEntity.java
com.yuninfo.videoextand.uploader.ProgressOutputStream.java
com.yuninfo.videoextand.uploader.UploadHandler.java
com.yuninfo.videoextand.uploader.UploadThread.java
com.yuninfo.videoextand.utils.BeanRefUtil.java
com.yuninfo.videoextand.utils.DateUtil.java
com.yuninfo.videoextand.utils.FileUtil.java
com.yuninfo.videoextand.utils.HttpUtil.java
com.yuninfo.videoextand.utils.LogUtil.java
com.yuninfo.videoextand.utils.StringUtil.java
com.yuninfo.videoextand.widget.CustomPopupWindow.java
com.yuninfo.videoextand.widget.TitleBar.java
com.yuninfo.videoextand.widget.dialog.MenuDialog.java