断点续传的mvp

来源:互联网 发布:河北网络干部学院官网 编辑:程序博客网 时间:2024/06/05 16:36

view层

//断点续传void progress(int max,int prog);
model层

@Overridepublic void Progggs() {    Toast.makeText(MyApp.context, "开始", Toast.LENGTH_SHORT).show();    String fileName = "bbbbb.jpg";    String path ="http://c.hiphotos.baidu.com/image/pic/item/b90e7bec54e736d1e51217c292504fc2d46269f3.jpg";    //String path = "http://gdown.baidu.com/data/wisegame/df65a597122796a4/" + fileName;    HttpUtils http = new HttpUtils();    http.download(path, Environment.getExternalStorageDirectory() + "/"            + fileName, true, true, new RequestCallBack<File>() {        @Override        public void onSuccess(ResponseInfo<File> arg0) {            // isDowloding = false;            // 下载成功            Toast.makeText(MyApp.context, arg0.result.getPath(), Toast.LENGTH_SHORT).show();        }        @Override        public void onFailure(HttpException arg0, String arg1) {            // 下载失败            Toast.makeText(MyApp.context,"下载失败" + arg1, Toast.LENGTH_SHORT).show();        }        @Override        public void onLoading(long total, long current, boolean isUploading) {            super.onLoading(total, current, isUploading);            if (current < total) {            } else {                // isDowloding = false;            }            // 下载任务            if (mOnProgressChangeListener != null){                mOnProgressChangeListener.onProgressChnage((int) total,(int) current);            }            /*pb.setMax((int) total);            pb.setProgress((int) current);            tv_progress.setText(current * 100 / total + "%");*/        }    });}public interface onProgressChangeListener{    void onProgressChnage(int max,int progress);}private onProgressChangeListener mOnProgressChangeListener;public void setOnProgressChangeListener(onProgressChangeListener mOnProgressChangeListener){    this.mOnProgressChangeListener = mOnProgressChangeListener;}

原创粉丝点击