Skip to content

Commit

Permalink
删除老的下载库filedownloader和okdownload
Browse files Browse the repository at this point in the history
  • Loading branch information
hss01248 committed Sep 3, 2024
1 parent 537c6df commit acef022
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 191 deletions.
1 change: 1 addition & 0 deletions downloader-m3u8/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
api project(path: ':downloader')
api 'io.lindstrom:m3u8-parser:0.27'
implementation 'com.liulishuo.filedownloader:library:1.7.7'
}
4 changes: 2 additions & 2 deletions downloader/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ dependencies {
api project(path: ':compressor')


api 'com.liulishuo.filedownloader:library:1.7.7'
/*api 'com.liulishuo.filedownloader:library:1.7.7'
api "com.liulishuo.okdownload:okdownload:1.0.7"
api 'com.liulishuo.okdownload:sqlite:1.0.7'
api 'com.liulishuo.okdownload:okhttp:1.0.7'
api 'com.liulishuo.okdownload:okhttp:1.0.7'*/
//api "com.github.skyNet2017.FileDownloader-fork2:okhttp-no-service:2.0.2"
api "com.github.hss01248.simple-file-downloder:download-okhttp-android:1.0.6"

Expand Down
12 changes: 3 additions & 9 deletions downloader/src/main/java/com/hss/downloader/MyDownloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
import com.hss.downloader.download.CompressEvent;
import com.hss.downloader.download.DownloadInfo;
import com.hss.downloader.download.DownloadInfoUtil;
import com.hss.downloader.event.DownloadResultEvent;

import com.hss.downloader.download.db.DownloadInfoDao;
import com.hss.downloader.event.DownloadResultEvent;
import com.hss.downloader.list.DownloadRecordListHolder;
import com.hss.utils.enhance.foregroundservice.CommonProgressService;
import com.hss01248.img.compressor.ImageCompressor;
import com.liulishuo.okdownload.StatusUtil;

import org.greenrobot.eventbus.EventBus;

Expand Down Expand Up @@ -201,12 +199,8 @@ public List<DownloadInfo> doInBackground() throws Throwable {
load.genFilePath();
//load.name = load.name;//避免多级目录,非法字符,文件过长等情况
if(load.status == DownloadInfo.STATUS_DOWNLOADING){
StatusUtil.Status status = StatusUtil.getStatus(info.url, load.dir, load.name);
if( status == StatusUtil.Status.RUNNING
|| status == StatusUtil.Status.PENDING){
toShow.add(load);
continue;
}
toShow.add(load);
continue;
}
load.status = DownloadInfo.STATUS_ORIGINAL;
load.createTime = System.currentTimeMillis();
Expand Down
116 changes: 0 additions & 116 deletions downloader/src/main/java/com/hss/downloader/OkDownloadImpl.java

This file was deleted.

42 changes: 41 additions & 1 deletion downloader/src/main/java/com/hss/downloader/OkDownloadImpl2.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import androidx.annotation.NonNull;

import com.hss.downloader.api.DownloadApi;
import com.hss.downloader.api.IDownload2;
import com.hss01248.download_okhttp.OkhttpDownloadUtil;
import com.liulishuo.filedownloader2.AndroidDownloader;
import com.liulishuo.filedownloader2.DownloadCallbackOnMainThreadWrapper;
Expand All @@ -15,7 +17,7 @@
* @Date 8/27/24 7:22 PM
* @Version 1.0
*/
public class OkDownloadImpl2 implements IDownload{
public class OkDownloadImpl2 implements IDownload, IDownload2 {

public static void setUserAgent(String userAgent) {
OkDownloadImpl2.userAgent = userAgent;
Expand Down Expand Up @@ -62,4 +64,42 @@ public void onProgress(String url, String path, long total, long alreadyReceived
public void stopDownload(String url) {
OkhttpDownloadUtil.pauseOrStop(url);
}

@Override
public void download(DownloadApi api) {
AndroidDownloader.prepareDownload(api.getUrl())
.filePath(api.getRealPath())
.headers(api.getHeaders())
.start(new DownloadCallbackOnMainThreadWrapper(new com.hss01248.download_okhttp.IDownloadCallback() {
@Override
public void onCodeStart(String url, String path) {
com.hss01248.download_okhttp.IDownloadCallback.super.onCodeStart(url, path);
api.getCallback().onStart(url, path);
}

@Override
public void onStartReal(String url, String path) {
com.hss01248.download_okhttp.IDownloadCallback.super.onStartReal(url, path);
}

@Override
public void onSuccess(String url, String path) {
api.getCallback().onSuccess(url,path);
}

@Override
public void onFailed(String url, String path, String code, String msg, Throwable e) {
api.getCallback().onFail(url,path,code+" "+msg,e);
}
@Override
public void onProgress(String url, String path, long total, long alreadyReceived,long speed) {
api.getCallback().onProgress(url, path, total, alreadyReceived, speed);
}

@Override
public void onCancel(String url, String path) {
com.hss01248.download_okhttp.IDownloadCallback.super.onCancel(url, path);
}
}));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.blankj.utilcode.util.Utils;
import com.hss.downloader.IDownload;
import com.hss.downloader.IDownloadCallback;
import com.hss.downloader.OkDownloadImpl2;
import com.hss.downloader.callback.DefaultUIDownloadCallback;
import com.hss.downloader.callback.DownloadCallbackDbDecorator;
import com.hss.downloader.callback.ExeOnMainDownloadCallback;
Expand Down Expand Up @@ -81,7 +82,7 @@ public IDownloadCallback getCallback() {
}

private IDownloadCallback callback;
public static IDownload2 downlodImpl = new DownloadImplByFileDownloader();
public static IDownload2 downlodImpl = new OkDownloadImpl2();

public DownloadApi setDir(String dir) {
this.dir = dir;
Expand Down

This file was deleted.

0 comments on commit acef022

Please sign in to comment.