Java多线程文件下载管理器详解编程语言

[Java]代码    

String mUrl1 = "https://codeload.github.com/cheyiliu/android-multithread-downloader-lib/zip/master"; 
String mLocalPath1 = "/mnt/sdcard/android-multithread-downloader-lib.zip"; 
 
DownloadManager.from(this).download(mUrl1, mLocalPath1, new DownloadListener() { 
            private long mProgress = 0; 
 
            @Override 
            public void onSucess() { 
                Log.e("test1", this + "onSucess"); 
                mFinshed[0] = true; 
                if (mFinshed[0] && mFinshed[1] && mFinshed[2]) { 
                    mStartEndTime[1] = System.currentTimeMillis(); 
                    mHandler.sendEmptyMessage(4); 
                } 
 
            } 
 
            @Override 
            public void onProgress(long step, long max) { 
                mProgress += step; 
                Log.i("test1", this + "onProgress, " + mProgress + "/" + max); 
                Message msg = mHandler.obtainMessage(1); 
                msg.arg1 = (int) mProgress; 
                msg.arg2 = (int) max; 
                mHandler.sendMessage(msg); 
            } 
 
            @Override 
            public void onFail(int reason) { 
                Log.e("test1", this + "onFail, " + reason); 
            } 
        });

原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/10392.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论