This commit is contained in:
@ -15,6 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.aria.core.download;
|
package com.arialyy.aria.core.download;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
import com.arialyy.aria.orm.DbEntity;
|
import com.arialyy.aria.orm.DbEntity;
|
||||||
import com.arialyy.aria.util.CheckUtil;
|
import com.arialyy.aria.util.CheckUtil;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
@ -51,8 +52,9 @@ public class DownloadGroupTarget
|
|||||||
mTaskEntity.entity = getDownloadGroupEntity();
|
mTaskEntity.entity = getDownloadGroupEntity();
|
||||||
mTaskEntity.insert();
|
mTaskEntity.insert();
|
||||||
}
|
}
|
||||||
if (mTaskEntity.entity == null) {
|
if (mTaskEntity.entity == null || TextUtils.isEmpty(mTaskEntity.entity.getKey())) {
|
||||||
mTaskEntity.entity = getDownloadGroupEntity();
|
mTaskEntity.entity = getDownloadGroupEntity();
|
||||||
|
mTaskEntity.save();
|
||||||
}
|
}
|
||||||
mEntity = mTaskEntity.entity;
|
mEntity = mTaskEntity.entity;
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,11 @@ public class DownloadTarget
|
|||||||
mTaskEntity.entity = entity;
|
mTaskEntity.entity = entity;
|
||||||
mTaskEntity.save();
|
mTaskEntity.save();
|
||||||
}
|
}
|
||||||
if (mTaskEntity.entity == null) {
|
if (mTaskEntity.entity == null || TextUtils.isEmpty(mTaskEntity.entity.getUrl())) {
|
||||||
mTaskEntity.entity = entity;
|
mTaskEntity.entity = entity;
|
||||||
|
mTaskEntity.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
mEntity = mTaskEntity.entity;
|
mEntity = mTaskEntity.entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package com.arialyy.aria.core.download;
|
package com.arialyy.aria.core.download;
|
||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import com.arialyy.aria.core.AriaManager;
|
import com.arialyy.aria.core.AriaManager;
|
||||||
import com.arialyy.aria.core.common.IUtil;
|
import com.arialyy.aria.core.common.IUtil;
|
||||||
|
@ -46,7 +46,6 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
|
|||||||
private final String BOUNDARY = UUID.randomUUID().toString(); // 边界标识 随机生成
|
private final String BOUNDARY = UUID.randomUUID().toString(); // 边界标识 随机生成
|
||||||
private final String PREFIX = "--", LINE_END = "\r\n";
|
private final String PREFIX = "--", LINE_END = "\r\n";
|
||||||
private HttpURLConnection mHttpConn;
|
private HttpURLConnection mHttpConn;
|
||||||
private long mCurrentLocation = 0;
|
|
||||||
private OutputStream mOutputStream;
|
private OutputStream mOutputStream;
|
||||||
|
|
||||||
HttpThreadTask(StateConstance constance, IUploadListener listener,
|
HttpThreadTask(StateConstance constance, IUploadListener listener,
|
||||||
@ -152,12 +151,11 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
|
|||||||
byte[] buffer = new byte[4096];
|
byte[] buffer = new byte[4096];
|
||||||
int bytesRead;
|
int bytesRead;
|
||||||
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
mCurrentLocation += bytesRead;
|
STATE.CURRENT_LOCATION += bytesRead;
|
||||||
mOutputStream.write(buffer, 0, bytesRead);
|
mOutputStream.write(buffer, 0, bytesRead);
|
||||||
if (STATE.isCancel) {
|
if (STATE.isCancel) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mListener.onProgress(mCurrentLocation);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mOutputStream.flush();
|
mOutputStream.flush();
|
||||||
@ -166,7 +164,6 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
|
|||||||
writer.append(LINE_END);
|
writer.append(LINE_END);
|
||||||
writer.flush();
|
writer.flush();
|
||||||
if (STATE.isCancel) {
|
if (STATE.isCancel) {
|
||||||
mListener.onCancel();
|
|
||||||
STATE.isRunning = false;
|
STATE.isRunning = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> {
|
|||||||
@OnClick(R.id.upload) void upload() {
|
@OnClick(R.id.upload) void upload() {
|
||||||
Aria.upload(this)
|
Aria.upload(this)
|
||||||
.load(FILE_PATH)
|
.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")
|
.setAttachment("file")
|
||||||
.start();
|
.start();
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
package com.arialyy.aria.core.upload;
|
package com.arialyy.aria.core.upload;
|
||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import com.arialyy.aria.core.inf.AbsNormalTask;
|
import com.arialyy.aria.core.inf.AbsNormalTask;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
import com.arialyy.aria.core.inf.IEntity;
|
||||||
|
@ -37,7 +37,7 @@ task clean(type: Delete) {
|
|||||||
ext {
|
ext {
|
||||||
userOrg = 'arialyy'
|
userOrg = 'arialyy'
|
||||||
groupId = 'com.arialyy.aria'
|
groupId = 'com.arialyy.aria'
|
||||||
publishVersion = '3.2.15'
|
publishVersion = '3.2.16'
|
||||||
repoName='maven'
|
repoName='maven'
|
||||||
desc = 'android 下载框架'
|
desc = 'android 下载框架'
|
||||||
website = 'https://github.com/AriaLyy/Aria'
|
website = 'https://github.com/AriaLyy/Aria'
|
||||||
|
Reference in New Issue
Block a user