You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
AriaLyy 1cdd216d8f Create README.md 10 years ago
.idea 修复目录结构 10 years ago
app 修复目录结构 10 years ago
downloadutil 修复目录结构 10 years ago
gradle/wrapper 修复目录结构 10 years ago
img Added files via upload 10 years ago
.gitignore 修复目录结构 10 years ago
README.md Create README.md 10 years ago
build.gradle 修复目录结构 10 years ago
gradle.properties 修复目录结构 10 years ago
gradlew 修复目录结构 10 years ago
gradlew.bat 修复目录结构 10 years ago
settings.gradle 修复目录结构 10 years ago

README.md

DownloadUtil

这是android 文件下载工具类,实现了多线程断点续传功能

#使用

DownloadUtil mUtil;

/**
 * 初始化下载工具类
 */
 private void init(){
 	mUtil = new DownloadUtile();
 }
 
private void download(){
	mUtil.download(this, mDownloadUrl, Environment.getExternalStorageDirectory().getPath() + "/test.apk"
                , new DownloadListener() {
                    long fileSize = 1;

                    @Override
                    public void onPreDownload(HttpURLConnection connection) {
                        super.onPreDownload(connection);
                        mPb.setMax(100);
                        fileSize = connection.getContentLength();
                        mUpdateHandler.obtainMessage(DOWNLOAD_PRE, fileSize).sendToTarget();
                    }

                    @Override
                    public void onStart(long startLocation) {
                        super.onStart(startLocation);
                    }

                    @Override
                    public void onChildResume(long resumeLocation) {
                        super.onChildResume(resumeLocation);
                    }

                    @Override
                    public void onChildComplete(long finishLocation) {
                        super.onChildComplete(finishLocation);
                    }

                    @Override
                    public void onProgress(long currentLocation) {
                        super.onProgress(currentLocation);
                        mPb.setProgress((int) (currentLocation * 100 / fileSize));
                    }

                    @Override
                    public void onStop(long stopLocation) {
                        super.onStop(stopLocation);
                        mUpdateHandler.obtainMessage(DOWNLOAD_STOP).sendToTarget();
                    }

                    @Override
                    public void onCancel() {
                        super.onCancel();
                        mUpdateHandler.obtainMessage(DOWNLOAD_CANCEL).sendToTarget();
                    }

                    @Override
                    public void onResume(long resumeLocation) {
                        super.onResume(resumeLocation);
                        mUpdateHandler.obtainMessage(DOWNLOAD_RESUME, resumeLocation).sendToTarget();
                    }

                    @Override
                    public void onFail() {
                        super.onFail();
                        mUpdateHandler.obtainMessage(DOWNLOAD_FAILE).sendToTarget();
                    }

                    @Override
                    public void onComplete() {
                        super.onComplete();
                        mUpdateHandler.obtainMessage(DOWNLOAD_COMPLETE).sendToTarget();
                    }
                });
}

#示例 例子图

#下载