AriaLyy
2017-08-11 10:56:23 +08:00
parent 2febe641a7
commit a8f183363e
7 changed files with 11 additions and 8 deletions

View File

@@ -15,6 +15,7 @@
*/
package com.arialyy.aria.core.download;
import android.text.TextUtils;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
@@ -51,8 +52,9 @@ public class DownloadGroupTarget
mTaskEntity.entity = getDownloadGroupEntity();
mTaskEntity.insert();
}
if (mTaskEntity.entity == null) {
if (mTaskEntity.entity == null || TextUtils.isEmpty(mTaskEntity.entity.getKey())) {
mTaskEntity.entity = getDownloadGroupEntity();
mTaskEntity.save();
}
mEntity = mTaskEntity.entity;
}

View File

@@ -54,9 +54,11 @@ public class DownloadTarget
mTaskEntity.entity = entity;
mTaskEntity.save();
}
if (mTaskEntity.entity == null) {
if (mTaskEntity.entity == null || TextUtils.isEmpty(mTaskEntity.entity.getUrl())) {
mTaskEntity.entity = entity;
mTaskEntity.save();
}
mEntity = mTaskEntity.entity;
}

View File

@@ -17,6 +17,7 @@
package com.arialyy.aria.core.download;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.common.IUtil;

View File

@@ -46,7 +46,6 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
private final String BOUNDARY = UUID.randomUUID().toString(); // 边界标识 随机生成
private final String PREFIX = "--", LINE_END = "\r\n";
private HttpURLConnection mHttpConn;
private long mCurrentLocation = 0;
private OutputStream mOutputStream;
HttpThreadTask(StateConstance constance, IUploadListener listener,
@@ -152,12 +151,11 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
byte[] buffer = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(buffer)) != -1) {
mCurrentLocation += bytesRead;
STATE.CURRENT_LOCATION += bytesRead;
mOutputStream.write(buffer, 0, bytesRead);
if (STATE.isCancel) {
break;
}
mListener.onProgress(mCurrentLocation);
}
mOutputStream.flush();
@@ -166,7 +164,6 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
writer.append(LINE_END);
writer.flush();
if (STATE.isCancel) {
mListener.onCancel();
STATE.isRunning = false;
return;
}