From a8f183363e2303c84b8ab0fe4db6f3252f905863 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Fri, 11 Aug 2017 10:56:23 +0800 Subject: [PATCH] fix bug https://github.com/AriaLyy/Aria/issues/89#issuecomment-321558633 --- .../com/arialyy/aria/core/download/DownloadGroupTarget.java | 4 +++- .../java/com/arialyy/aria/core/download/DownloadTarget.java | 4 +++- .../java/com/arialyy/aria/core/download/DownloadTask.java | 1 + .../arialyy/aria/core/upload/uploader/HttpThreadTask.java | 5 +---- .../java/com/arialyy/simple/upload/HttpUploadActivity.java | 2 +- .../main/java/com/arialyy/aria/core/upload/UploadTask.java | 1 + build.gradle | 2 +- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java index 33d0529b..1dbbf2ff 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java @@ -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; } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java index 27aea5dc..6303a43b 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java @@ -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; } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java index 78738926..f54b6ffc 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java @@ -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; diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java index c6f2db22..f32a8d69 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java @@ -46,7 +46,6 @@ class HttpThreadTask extends AbsThreadTask { 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 { 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 { writer.append(LINE_END); writer.flush(); if (STATE.isCancel) { - mListener.onCancel(); STATE.isRunning = false; return; } diff --git a/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java b/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java index e8a1b419..669d8909 100644 --- a/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java +++ b/app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java @@ -50,7 +50,7 @@ public class HttpUploadActivity extends BaseActivity { @OnClick(R.id.upload) void upload() { Aria.upload(this) .load(FILE_PATH) - .setUploadUrl("http://172.18.104.129:8080/upload/sign_file") + .setUploadUrl("http://172.18.104.66:8080/upload/sign_file") .setAttachment("file") .start(); } diff --git a/aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java b/aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java index d9e182ee..438a4dc0 100644 --- a/aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java +++ b/aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java @@ -16,6 +16,7 @@ package com.arialyy.aria.core.upload; import android.os.Handler; +import android.os.Looper; import android.util.Log; import com.arialyy.aria.core.inf.AbsNormalTask; import com.arialyy.aria.core.inf.IEntity; diff --git a/build.gradle b/build.gradle index 50c4f2fd..3c54e7fd 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' - publishVersion = '3.2.15' + publishVersion = '3.2.16' repoName='maven' desc = 'android 下载框架' website = 'https://github.com/AriaLyy/Aria'