Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Feat/switch okdownload #1297

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
buildscript {
repositories {
mavenLocal()
jcenter()
google()
}
Expand All @@ -11,6 +12,7 @@ buildscript {

allprojects {
repositories {
mavenLocal()
jcenter()
google()
}
Expand Down
9 changes: 8 additions & 1 deletion demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ android {
// which is harmless for us.
warning 'InvalidPackage'
}
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}

dependencies {
Expand All @@ -49,7 +53,10 @@ dependencies {
implementation 'com.android.support:design:28.0.0'
debugImplementation 'cn.dreamtobe.threaddebugger:threaddebugger:1.3.3'
releaseImplementation 'cn.dreamtobe.threaddebugger:threaddebugger-no-op:1.3.3'
implementation project(':library')
// implementation "com.liulishuo.filedownloader:library:1.7.7"
// for testing
implementation 'com.squareup.okio:okio:1.14.0'
implementation "com.liulishuo.okdownload:okdownload:1.0.7-SNAPSHOT"
implementation "com.liulishuo.okdownload:filedownloader:1.0.7-SNAPSHOT"
implementation "com.liulishuo.okdownload:sqlite:1.0.7-SNAPSHOT"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@

import com.liulishuo.filedownloader.FileDownloader;
import com.liulishuo.filedownloader.connection.FileDownloadUrlConnection;
import com.liulishuo.filedownloader.util.FileDownloadLog;
//import com.liulishuo.filedownloader.util.FileDownloadLog;
import com.liulishuo.filedownloader.util.FileDownloadUtils;
import com.liulishuo.okdownload.core.Util;

import cn.dreamtobe.threaddebugger.IThreadDebugger;
import cn.dreamtobe.threaddebugger.ThreadDebugger;
Expand All @@ -27,7 +28,8 @@ public void onCreate() {
CONTEXT = this;

// just for open the log in this demo project.
FileDownloadLog.NEED_LOG = BuildConfig.DOWNLOAD_NEED_LOG;
// FileDownloadLog.NEED_LOG = BuildConfig.DOWNLOAD_NEED_LOG;
Util.enableConsoleLog();

/**
* just for cache Application's Context, and ':filedownloader' progress will NOT be launched
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ public void onBindViewHolder(TaskItemViewHolder holder, int position) {


if (TasksManager.getImpl().isReady()) {
final int status = TasksManager.getImpl().getStatus(model.getId(), model.getPath());
// final int status = TasksManager.getImpl().getStatus(model.getId(), model.getPath());
final int status = TasksManager.getImpl().getStatus(model.getUrl(), model.getPath());
if (status == FileDownloadStatus.pending || status == FileDownloadStatus.started ||
status == FileDownloadStatus.connected) {
// start task, but file not created yet
Expand Down Expand Up @@ -420,6 +421,8 @@ private void initDemo() {
final String url = Constant.BIG_FILE_URLS[i];
addTask(url);
}
} else {
correctModelId();
}
}

Expand Down Expand Up @@ -492,6 +495,15 @@ public void onCreate(final WeakReference<TasksManagerDemoActivity> activityWeakR
}
}

private void correctModelId() {
for (TasksManagerModel model : modelList) {
final BaseDownloadTask task = FileDownloader.getImpl().create(model.getUrl());
model.id = task.getId();
model.name = DemoApplication.CONTEXT
.getString(R.string.tasks_manager_demo_name, model.id);
}
}

public void onDestroy() {
unregisterServiceConnectionListener();
releaseTask();
Expand Down Expand Up @@ -524,10 +536,15 @@ public boolean isDownloaded(final int status) {
return status == FileDownloadStatus.completed;
}

@Deprecated
public int getStatus(final int id, String path) {
return FileDownloader.getImpl().getStatus(id, path);
}

public int getStatus(final String url, final String path) {
return FileDownloader.getImpl().getStatus(url, path);
}

public long getTotal(final int id) {
return FileDownloader.getImpl().getTotal(id);
}
Expand Down