This commit is contained in:
@ -154,8 +154,8 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
|||||||
|
|
||||||
@Override public void cancel() {
|
@Override public void cancel() {
|
||||||
closeTimer();
|
closeTimer();
|
||||||
mConstance.isCancel = true;
|
|
||||||
mConstance.isRunning = false;
|
mConstance.isRunning = false;
|
||||||
|
mConstance.isCancel = true;
|
||||||
if (mFixedThreadPool != null) {
|
if (mFixedThreadPool != null) {
|
||||||
mFixedThreadPool.shutdown();
|
mFixedThreadPool.shutdown();
|
||||||
}
|
}
|
||||||
|
@ -134,6 +134,7 @@ class BaseDListener<ENTITY extends AbsEntity, TASK extends AbsTask<ENTITY>>
|
|||||||
private void saveData(int state, long location) {
|
private void saveData(int state, long location) {
|
||||||
mEntity.setComplete(state == IEntity.STATE_COMPLETE);
|
mEntity.setComplete(state == IEntity.STATE_COMPLETE);
|
||||||
if (state == IEntity.STATE_CANCEL) {
|
if (state == IEntity.STATE_CANCEL) {
|
||||||
|
mEntity.setState(state);
|
||||||
mEntity.deleteData();
|
mEntity.deleteData();
|
||||||
} else if (state == IEntity.STATE_COMPLETE) {
|
} else if (state == IEntity.STATE_COMPLETE) {
|
||||||
mEntity.setState(state);
|
mEntity.setState(state);
|
||||||
|
@ -33,18 +33,27 @@ public abstract class AbsDownloadTarget<TARGET extends AbsTarget, ENTITY extends
|
|||||||
* key默认值为:Content-MD5
|
* key默认值为:Content-MD5
|
||||||
* 获取md5信息:{@link DownloadEntity#getMd5Code()}
|
* 获取md5信息:{@link DownloadEntity#getMd5Code()}
|
||||||
*/
|
*/
|
||||||
public void setHeaderMd5Key(String md5Key) {
|
public TARGET setHeaderMd5Key(String md5Key) {
|
||||||
if (TextUtils.isEmpty(md5Key)) return;
|
if (TextUtils.isEmpty(md5Key)) return (TARGET) this;
|
||||||
mTaskEntity.md5Key = md5Key;
|
mTaskEntity.md5Key = md5Key;
|
||||||
|
if (TextUtils.isEmpty(mTaskEntity.md5Key) || !mTaskEntity.md5Key.equals(md5Key)) {
|
||||||
|
mTaskEntity.update();
|
||||||
|
}
|
||||||
|
return (TARGET) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 如果你的文件长度是放在header中,那么你需要配置key来让Aria知道正确的文件长度
|
* 如果你的文件长度是放在header中,那么你需要配置key来让Aria知道正确的文件长度
|
||||||
* key默认值为:Content-Length
|
* key默认值为:Content-Length
|
||||||
*/
|
*/
|
||||||
public void setHeaderContentLengthKey(String contentLength) {
|
public TARGET setHeaderContentLengthKey(String contentLength) {
|
||||||
if (TextUtils.isEmpty(contentLength)) return;
|
if (TextUtils.isEmpty(contentLength)) return (TARGET) this;
|
||||||
mTaskEntity.contentLength = contentLength;
|
mTaskEntity.contentLength = contentLength;
|
||||||
|
if (TextUtils.isEmpty(mTaskEntity.contentLength) || !mTaskEntity.contentLength.equals(
|
||||||
|
contentLength)) {
|
||||||
|
mTaskEntity.update();
|
||||||
|
}
|
||||||
|
return (TARGET) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,9 +61,14 @@ public abstract class AbsDownloadTarget<TARGET extends AbsTarget, ENTITY extends
|
|||||||
* key默认值为:Content-Disposition
|
* key默认值为:Content-Disposition
|
||||||
* 获取文件描述信息:{@link DownloadEntity#getDisposition()}
|
* 获取文件描述信息:{@link DownloadEntity#getDisposition()}
|
||||||
*/
|
*/
|
||||||
public void setHeaderDispositionKey(String dispositionKey) {
|
public TARGET setHeaderDispositionKey(String dispositionKey) {
|
||||||
if (TextUtils.isEmpty(dispositionKey)) return;
|
if (TextUtils.isEmpty(dispositionKey)) return (TARGET) this;
|
||||||
mTaskEntity.dispositionKey = dispositionKey;
|
mTaskEntity.dispositionKey = dispositionKey;
|
||||||
|
if (TextUtils.isEmpty(mTaskEntity.dispositionKey) || !mTaskEntity.dispositionKey.equals(
|
||||||
|
dispositionKey)) {
|
||||||
|
mTaskEntity.save();
|
||||||
|
}
|
||||||
|
return (TARGET) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -62,9 +76,14 @@ public abstract class AbsDownloadTarget<TARGET extends AbsTarget, ENTITY extends
|
|||||||
* key默认值为:attachment;filename
|
* key默认值为:attachment;filename
|
||||||
* 获取文件名信息:{@link DownloadEntity#getServerFileName()}
|
* 获取文件名信息:{@link DownloadEntity#getServerFileName()}
|
||||||
*/
|
*/
|
||||||
public void setHeaderDispositionFileKey(String dispositionFileKey) {
|
public TARGET setHeaderDispositionFileKey(String dispositionFileKey) {
|
||||||
if (TextUtils.isEmpty(dispositionFileKey)) return;
|
if (TextUtils.isEmpty(dispositionFileKey)) return (TARGET) this;
|
||||||
mTaskEntity.dispositionFileKey = dispositionFileKey;
|
mTaskEntity.dispositionFileKey = dispositionFileKey;
|
||||||
|
if (TextUtils.isEmpty(mTaskEntity.dispositionFileKey) || !mTaskEntity.dispositionFileKey.equals(
|
||||||
|
dispositionFileKey)) {
|
||||||
|
mTaskEntity.save();
|
||||||
|
}
|
||||||
|
return (TARGET) this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -42,6 +42,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
private static final String DOWNLOAD_URL =
|
private static final String DOWNLOAD_URL =
|
||||||
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
|
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
|
||||||
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
|
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
|
||||||
|
//"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
|
||||||
"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
|
"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
|
||||||
//"http://down2.xiaoshuofuwuqi.com/d/file/filetxt/20170608/14/%BA%DA%CE%D7%CA%A6%E1%C8%C6%F0.txt";
|
//"http://down2.xiaoshuofuwuqi.com/d/file/filetxt/20170608/14/%BA%DA%CE%D7%CA%A6%E1%C8%C6%F0.txt";
|
||||||
//"http://tinghuaapp.oss-cn-shanghai.aliyuncs.com/20170612201739607815";
|
//"http://tinghuaapp.oss-cn-shanghai.aliyuncs.com/20170612201739607815";
|
||||||
|
@ -93,7 +93,8 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void updateState(AbsEntity entity) {
|
public synchronized void updateState(AbsEntity entity) {
|
||||||
if (entity.getState() == DownloadEntity.STATE_CANCEL) {
|
if (entity.getState() == IEntity.STATE_CANCEL) {
|
||||||
|
mData.remove(entity);
|
||||||
mPositions.clear();
|
mPositions.clear();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (AbsEntity entity_1 : mData) {
|
for (AbsEntity entity_1 : mData) {
|
||||||
|
Reference in New Issue
Block a user