MCPcopy Create free account
hub / github.com/aa112901/remusic / DownloadTask

Class DownloadTask

app/src/main/java/com/wm/remusic/downmusic/DownloadTask.java:33–549  ·  view source on GitHub ↗

Created by dzc on 15/11/21.

Source from the content-addressed store, hash-verified

31 * Created by dzc on 15/11/21.
32 */
33public class DownloadTask implements Runnable {
34 private DownloadDBEntity dbEntity;
35 private DownFileStore downFileStore;
36 private OkHttpClient client;
37 private Context mContext;
38
39 private String id;
40 private long totalSize;
41 private long completedSize; // Download section has been completed
42 // private float percent; // Percent Complete
43 private String url;
44 private String saveDirPath;
45 private RandomAccessFile file;
46 private int UPDATE_SIZE = 50 * 1024; // The database is updated once every 50k
47 private int downloadStatus = DownloadStatus.DOWNLOAD_STATUS_INIT;
48
49 private String fileName; // File name when saving
50 private String artist;
51 private String temp = ".temp";
52 private boolean isPreparingDown;
53 private String TAG = "DownloadTask";
54
55
56 private List<DownloadTaskListener> listeners;
57
58 public DownloadTask(Context context) {
59 mContext = context.getApplicationContext();
60 listeners = new ArrayList<>();
61 downFileStore = DownFileStore.getInstance(context);
62 }
63
64 public DownloadTask(Context context, Builder builder) {
65 // mContext = context.getApplicationContext();
66 listeners = new ArrayList<>();
67 downFileStore = DownFileStore.getInstance(context);
68 init(builder);
69 }
70
71 private void init(Builder builder) {
72 mContext = builder.context;
73 fileName = builder.fileName;
74 artist = builder.art;
75 saveDirPath = builder.saveDirPath;
76 completedSize = builder.completedSize;
77 dbEntity = builder.dbEntity;
78 url = builder.url;
79 totalSize = builder.totalSize;
80 completedSize = builder.completedSize;
81 id = builder.id;
82 downloadStatus = builder.downloadStatus;
83 UPDATE_SIZE = builder.UPDATE_SIZE;
84 listeners = builder.listeners;
85
86 }
87
88 public static class Builder {
89
90 private String url;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected