This commit is contained in:
hyb1996
2017-12-30 17:18:38 +08:00
parent 123f86aa27
commit 403e19f568

View File

@@ -105,7 +105,7 @@ public class DownloadManager {
mProgress = PublishSubject.create();
}
public void start(ResponseBody body) throws IOException {
private void startImpl(ResponseBody body) throws IOException {
byte[] buffer = new byte[4096];
mFileOutputStream = new FileOutputStream(mPath);
mInputStream = body.byteStream();
@@ -130,6 +130,14 @@ public class DownloadManager {
recycle();
}
public void start(ResponseBody body) {
try {
startImpl(body);
} catch (Exception e) {
mProgress.onError(e);
}
}
private void onCancel() throws IOException {
recycle();
// TODO: 2017/12/6 notify?