Skip to content

Commit acef022

Browse files
committed
删除老的下载库filedownloader和okdownload
1 parent 537c6df commit acef022

File tree

7 files changed

+49
-191
lines changed

7 files changed

+49
-191
lines changed

downloader-m3u8/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ dependencies {
3434
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
3535
api project(path: ':downloader')
3636
api 'io.lindstrom:m3u8-parser:0.27'
37+
implementation 'com.liulishuo.filedownloader:library:1.7.7'
3738
}

downloader/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ dependencies {
6161
api project(path: ':compressor')
6262

6363

64-
api 'com.liulishuo.filedownloader:library:1.7.7'
64+
/*api 'com.liulishuo.filedownloader:library:1.7.7'
6565
api "com.liulishuo.okdownload:okdownload:1.0.7"
6666
api 'com.liulishuo.okdownload:sqlite:1.0.7'
67-
api 'com.liulishuo.okdownload:okhttp:1.0.7'
67+
api 'com.liulishuo.okdownload:okhttp:1.0.7'*/
6868
//api "com.github.skyNet2017.FileDownloader-fork2:okhttp-no-service:2.0.2"
6969
api "com.github.hss01248.simple-file-downloder:download-okhttp-android:1.0.6"
7070

downloader/src/main/java/com/hss/downloader/MyDownloader.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,11 @@
99
import com.hss.downloader.download.CompressEvent;
1010
import com.hss.downloader.download.DownloadInfo;
1111
import com.hss.downloader.download.DownloadInfoUtil;
12-
import com.hss.downloader.event.DownloadResultEvent;
13-
1412
import com.hss.downloader.download.db.DownloadInfoDao;
13+
import com.hss.downloader.event.DownloadResultEvent;
1514
import com.hss.downloader.list.DownloadRecordListHolder;
1615
import com.hss.utils.enhance.foregroundservice.CommonProgressService;
1716
import com.hss01248.img.compressor.ImageCompressor;
18-
import com.liulishuo.okdownload.StatusUtil;
1917

2018
import org.greenrobot.eventbus.EventBus;
2119

@@ -201,12 +199,8 @@ public List<DownloadInfo> doInBackground() throws Throwable {
201199
load.genFilePath();
202200
//load.name = load.name;//避免多级目录,非法字符,文件过长等情况
203201
if(load.status == DownloadInfo.STATUS_DOWNLOADING){
204-
StatusUtil.Status status = StatusUtil.getStatus(info.url, load.dir, load.name);
205-
if( status == StatusUtil.Status.RUNNING
206-
|| status == StatusUtil.Status.PENDING){
207-
toShow.add(load);
208-
continue;
209-
}
202+
toShow.add(load);
203+
continue;
210204
}
211205
load.status = DownloadInfo.STATUS_ORIGINAL;
212206
load.createTime = System.currentTimeMillis();

downloader/src/main/java/com/hss/downloader/OkDownloadImpl.java

Lines changed: 0 additions & 116 deletions
This file was deleted.

downloader/src/main/java/com/hss/downloader/OkDownloadImpl2.java

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import androidx.annotation.NonNull;
44

5+
import com.hss.downloader.api.DownloadApi;
6+
import com.hss.downloader.api.IDownload2;
57
import com.hss01248.download_okhttp.OkhttpDownloadUtil;
68
import com.liulishuo.filedownloader2.AndroidDownloader;
79
import com.liulishuo.filedownloader2.DownloadCallbackOnMainThreadWrapper;
@@ -15,7 +17,7 @@
1517
* @Date 8/27/24 7:22 PM
1618
* @Version 1.0
1719
*/
18-
public class OkDownloadImpl2 implements IDownload{
20+
public class OkDownloadImpl2 implements IDownload, IDownload2 {
1921

2022
public static void setUserAgent(String userAgent) {
2123
OkDownloadImpl2.userAgent = userAgent;
@@ -62,4 +64,42 @@ public void onProgress(String url, String path, long total, long alreadyReceived
6264
public void stopDownload(String url) {
6365
OkhttpDownloadUtil.pauseOrStop(url);
6466
}
67+
68+
@Override
69+
public void download(DownloadApi api) {
70+
AndroidDownloader.prepareDownload(api.getUrl())
71+
.filePath(api.getRealPath())
72+
.headers(api.getHeaders())
73+
.start(new DownloadCallbackOnMainThreadWrapper(new com.hss01248.download_okhttp.IDownloadCallback() {
74+
@Override
75+
public void onCodeStart(String url, String path) {
76+
com.hss01248.download_okhttp.IDownloadCallback.super.onCodeStart(url, path);
77+
api.getCallback().onStart(url, path);
78+
}
79+
80+
@Override
81+
public void onStartReal(String url, String path) {
82+
com.hss01248.download_okhttp.IDownloadCallback.super.onStartReal(url, path);
83+
}
84+
85+
@Override
86+
public void onSuccess(String url, String path) {
87+
api.getCallback().onSuccess(url,path);
88+
}
89+
90+
@Override
91+
public void onFailed(String url, String path, String code, String msg, Throwable e) {
92+
api.getCallback().onFail(url,path,code+" "+msg,e);
93+
}
94+
@Override
95+
public void onProgress(String url, String path, long total, long alreadyReceived,long speed) {
96+
api.getCallback().onProgress(url, path, total, alreadyReceived, speed);
97+
}
98+
99+
@Override
100+
public void onCancel(String url, String path) {
101+
com.hss01248.download_okhttp.IDownloadCallback.super.onCancel(url, path);
102+
}
103+
}));
104+
}
65105
}

downloader/src/main/java/com/hss/downloader/api/DownloadApi.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import com.blankj.utilcode.util.Utils;
1010
import com.hss.downloader.IDownload;
1111
import com.hss.downloader.IDownloadCallback;
12+
import com.hss.downloader.OkDownloadImpl2;
1213
import com.hss.downloader.callback.DefaultUIDownloadCallback;
1314
import com.hss.downloader.callback.DownloadCallbackDbDecorator;
1415
import com.hss.downloader.callback.ExeOnMainDownloadCallback;
@@ -81,7 +82,7 @@ public IDownloadCallback getCallback() {
8182
}
8283

8384
private IDownloadCallback callback;
84-
public static IDownload2 downlodImpl = new DownloadImplByFileDownloader();
85+
public static IDownload2 downlodImpl = new OkDownloadImpl2();
8586

8687
public DownloadApi setDir(String dir) {
8788
this.dir = dir;

downloader/src/main/java/com/hss/downloader/api/DownloadImplByFileDownloader.java

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)