Skip to content

Commit

Permalink
fix #333
Browse files Browse the repository at this point in the history
  • Loading branch information
jeasonlzy committed Jun 28, 2017
1 parent e854793 commit 050801b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ protected void onCreate(Bundle savedInstanceState) {

initData();
OkDownload.getInstance().setFolder(Environment.getExternalStorageDirectory().getAbsolutePath() + "/aaa/");
OkDownload.getInstance().getThreadPool().setCorePoolSize(1);
OkDownload.getInstance().getThreadPool().setCorePoolSize(3);

folder.setText(String.format("下载路径: %s", OkDownload.getInstance().getFolder()));
recyclerView.setLayoutManager(new LinearLayoutManager(this));
Expand Down
10 changes: 5 additions & 5 deletions okserver/src/main/java/com/lzy/okserver/OkDownload.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
* ================================================
Expand All @@ -44,9 +44,9 @@
*/
public class OkDownload {

private String folder; //下载的默认文件夹
private DownloadThreadPool threadPool; //下载的线程池
private Map<String, DownloadTask> taskMap; //所有任务
private String folder; //下载的默认文件夹
private DownloadThreadPool threadPool; //下载的线程池
private ConcurrentHashMap<String, DownloadTask> taskMap; //所有任务

public static OkDownload getInstance() {
return OkDownloadHolder.instance;
Expand All @@ -60,7 +60,7 @@ private OkDownload() {
folder = Environment.getExternalStorageDirectory() + File.separator + "download" + File.separator;
IOUtils.createFolder(folder);
threadPool = new DownloadThreadPool();
taskMap = new LinkedHashMap<>();
taskMap = new ConcurrentHashMap<>();

//校验数据的有效性,防止下载过程中退出,第二次进入的时候,由于状态没有更新导致的状态错误
List<Progress> taskList = DownloadManager.getInstance().getDownloading();
Expand Down

0 comments on commit 050801b

Please sign in to comment.