Merge branch 'v_3.0'

pull/330/head
AriaLyy 7 years ago
commit a63cc11966
  1. 36
      Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java
  2. 17
      Aria/src/main/java/com/arialyy/aria/core/download/BaseGroupTarget.java
  3. 21
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java
  4. 20
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/AbsGroupUtil.java
  5. 12
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadGroupUtil.java
  6. 1
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpDirDownloadUtil.java
  7. 38
      app/src/main/java/com/arialyy/simple/download/DownloadModule.java
  8. 4
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java
  9. 3
      app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java
  10. 27
      app/src/main/java/com/arialyy/simple/download/multi_download/FileListAdapter.java
  11. 5
      app/src/main/java/com/arialyy/simple/download/multi_download/FileListEntity.java
  12. 32
      app/src/main/java/com/arialyy/simple/download/multi_download/MultiTaskActivity.java
  13. 30
      app/src/main/res/values/strings.xml
  14. 6
      build.gradle

@ -140,8 +140,7 @@ public abstract class AbsThreadTask<ENTITY extends AbsEntity, TASK_ENTITY extend
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
if (mConfig.SUPPORT_BP) { if (mConfig.SUPPORT_BP) {
STATE.CANCEL_NUM++; STATE.CANCEL_NUM++;
Log.d(TAG, Log.d(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】thread__" + mConfig.THREAD_ID + "__取消");
"任务【" + mConfig.TEMP_FILE.getName() + "】thread__" + mConfig.THREAD_ID + "__取消下载");
if (STATE.isCancel()) { if (STATE.isCancel()) {
File configFile = new File(mConfigFPath); File configFile = new File(mConfigFPath);
if (configFile.exists()) { if (configFile.exists()) {
@ -168,9 +167,9 @@ public abstract class AbsThreadTask<ENTITY extends AbsEntity, TASK_ENTITY extend
protected void fail(long currentLocation, String msg, Exception ex) { protected void fail(long currentLocation, String msg, Exception ex) {
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
try { try {
STATE.FAIL_NUM++; //STATE.FAIL_NUM++;
STATE.isRunning = false; //STATE.isRunning = false;
STATE.isStop = true; //STATE.isStop = true;
if (ex != null) { if (ex != null) {
Log.e(TAG, msg + "\n" + CommonUtil.getPrintException(ex)); Log.e(TAG, msg + "\n" + CommonUtil.getPrintException(ex));
} else { } else {
@ -178,10 +177,11 @@ public abstract class AbsThreadTask<ENTITY extends AbsEntity, TASK_ENTITY extend
} }
if (mConfig.SUPPORT_BP) { if (mConfig.SUPPORT_BP) {
writeConfig(false, currentLocation); writeConfig(false, currentLocation);
if (STATE.isFail()) { //if (STATE.isFail()) {
Log.e(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】执行失败"); // Log.e(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】执行失败");
mListener.onFail(true); // mListener.onFail(true);
} //}
retryThis(true);
} else { } else {
Log.e(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】执行失败"); Log.e(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】执行失败");
mListener.onFail(true); mListener.onFail(true);
@ -193,20 +193,32 @@ public abstract class AbsThreadTask<ENTITY extends AbsEntity, TASK_ENTITY extend
} }
/** /**
* 重试当前线程 * 重试当前线程如果其中一条线程已经下载失败则任务该任务下载失败并且停止该任务的所有线程
*
* @param needRetry 是否可以重试
*/ */
private void retryThis(boolean needRetry) { private void retryThis(boolean needRetry) {
if (mFailNum < RETRY_NUM && needRetry) { if (mFailNum < RETRY_NUM && needRetry) {
if (mFailTimer != null){ if (mFailTimer != null) {
mFailTimer.purge(); mFailTimer.purge();
mFailTimer.cancel(); mFailTimer.cancel();
} }
mFailTimer = new Timer(); mFailTimer = new Timer(true);
mFailTimer.schedule(new TimerTask() { mFailTimer.schedule(new TimerTask() {
@Override public void run() { @Override public void run() {
mFailNum++;
Log.w(TAG,
"任务【" + mConfig.TEMP_FILE.getName() + "】thread__" + mConfig.THREAD_ID + "__正在重试");
mConfig.START_LOCATION = mChildCurrentLocation;
AbsThreadTask.this.run(); AbsThreadTask.this.run();
} }
}, RETRY_INTERVAL); }, RETRY_INTERVAL);
} else {
STATE.FAIL_NUM++;
STATE.isRunning = false;
STATE.isStop = true;
Log.e(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】执行失败");
mListener.onFail(true);
} }
} }

@ -138,10 +138,20 @@ abstract class BaseGroupTarget<TARGET extends AbsTarget, TASK_ENTITY extends Abs
} }
} }
/**
* 设置子任务文件名该方法必须在{@link #setDownloadDirPath(String)}之后调用否则不生效
*
* @see #setSubFileName(List)
*/
@Deprecated public TARGET setSubTaskFileName(List<String> subTaskFileName) {
return setSubFileName(subTaskFileName);
}
/** /**
* 设置子任务文件名该方法必须在{@link #setDownloadDirPath(String)}之后调用否则不生效 * 设置子任务文件名该方法必须在{@link #setDownloadDirPath(String)}之后调用否则不生效
*/ */
public TARGET setSubTaskFileName(List<String> subTaskFileName) { public TARGET setSubFileName(List<String> subTaskFileName) {
if (subTaskFileName == null || subTaskFileName.isEmpty()) return (TARGET) this; if (subTaskFileName == null || subTaskFileName.isEmpty()) return (TARGET) this;
mSubTaskFileName.addAll(subTaskFileName); mSubTaskFileName.addAll(subTaskFileName);
if (mUrls.size() != subTaskFileName.size()) { if (mUrls.size() != subTaskFileName.size()) {
@ -187,8 +197,8 @@ abstract class BaseGroupTarget<TARGET extends AbsTarget, TASK_ENTITY extends Abs
for (int i = 0, len = mUrls.size(); i < len; i++) { for (int i = 0, len = mUrls.size(); i < len; i++) {
DownloadEntity entity = new DownloadEntity(); DownloadEntity entity = new DownloadEntity();
entity.setUrl(mUrls.get(i)); entity.setUrl(mUrls.get(i));
String fileName = mSubTaskFileName.isEmpty() ? createFileName(entity.getUrl()) String fileName =
: mSubTaskFileName.get(i); mSubTaskFileName.isEmpty() ? createFileName(entity.getUrl()) : mSubTaskFileName.get(i);
entity.setDownloadPath(mEntity.getDirPath() + "/" + fileName); entity.setDownloadPath(mEntity.getDirPath() + "/" + fileName);
entity.setGroupName(mGroupName); entity.setGroupName(mGroupName);
entity.setGroupChild(true); entity.setGroupChild(true);
@ -198,5 +208,4 @@ abstract class BaseGroupTarget<TARGET extends AbsTarget, TASK_ENTITY extends Abs
} }
return list; return list;
} }
} }

@ -16,6 +16,7 @@
package com.arialyy.aria.core.download; package com.arialyy.aria.core.download;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
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;
@ -59,6 +60,26 @@ public class DownloadGroupTarget
mEntity = mTaskEntity.entity; mEntity = mTaskEntity.entity;
} }
/**
* 任务组总任务大小任务组是一个抽象的概念没有真实的数据实体任务组的大小是Aria动态获取子任务大小相加而得到的
* 如果你知道当前任务组总大小你也可以调用该方法给任务组设置大小
*
* 为了更好的用户体验建议直接设置任务组文件大小
*
* @param fileSize 任务组总大小
*/
public DownloadGroupTarget setFileSize(long fileSize) {
if (fileSize <= 0) {
Log.w(TAG, "文件大小不能小于 0");
return this;
}
if (mEntity.getFileSize() <= 1 || mEntity.getFileSize() != fileSize) {
mEntity.setFileSize(fileSize);
mEntity.update();
}
return this;
}
/** /**
* 如果你是使用{@link DownloadReceiver#load(DownloadGroupEntity)}进行下载操作那么你需要设置任务组的下载地址 * 如果你是使用{@link DownloadReceiver#load(DownloadGroupEntity)}进行下载操作那么你需要设置任务组的下载地址
*/ */

@ -44,7 +44,7 @@ abstract class AbsGroupUtil implements IUtil {
* 任务组所有任务总大小 * 任务组所有任务总大小
*/ */
long mTotalSize = 0; long mTotalSize = 0;
protected long mCurrentLocation = 0; long mCurrentLocation = 0;
private ExecutorService mExePool; private ExecutorService mExePool;
protected IDownloadGroupListener mListener; protected IDownloadGroupListener mListener;
protected DownloadGroupTaskEntity mTaskEntity; protected DownloadGroupTaskEntity mTaskEntity;
@ -83,6 +83,10 @@ abstract class AbsGroupUtil implements IUtil {
private int mFailNum = 0; private int mFailNum = 0;
//实际的下载任务数 //实际的下载任务数
int mActualTaskNum = 0; int mActualTaskNum = 0;
/**
* 是否需要读取文件长度{@code true}需要
*/
boolean isNeedLoadFileSize = true;
AbsGroupUtil(IDownloadGroupListener listener, DownloadGroupTaskEntity taskEntity) { AbsGroupUtil(IDownloadGroupListener listener, DownloadGroupTaskEntity taskEntity) {
mListener = listener; mListener = listener;
@ -95,6 +99,8 @@ abstract class AbsGroupUtil implements IUtil {
mTasksMap.put(te.getEntity().getUrl(), te); mTasksMap.put(te.getEntity().getUrl(), te);
} }
} }
mTotalSize = taskEntity.getEntity().getFileSize();
isNeedLoadFileSize = mTotalSize <= 1;
for (DownloadEntity entity : mTaskEntity.entity.getSubTask()) { for (DownloadEntity entity : mTaskEntity.entity.getSubTask()) {
File file = new File(entity.getDownloadPath()); File file = new File(entity.getDownloadPath());
if (entity.getState() == IEntity.STATE_COMPLETE && file.exists()) { if (entity.getState() == IEntity.STATE_COMPLETE && file.exists()) {
@ -106,7 +112,17 @@ abstract class AbsGroupUtil implements IUtil {
mCurrentLocation += file.exists() ? entity.getCurrentProgress() : 0; mCurrentLocation += file.exists() ? entity.getCurrentProgress() : 0;
mActualTaskNum++; mActualTaskNum++;
} }
mTotalSize += entity.getFileSize(); if (isNeedLoadFileSize) {
mTotalSize += entity.getFileSize();
}
}
updateFileSize();
}
void updateFileSize() {
if (isNeedLoadFileSize) {
mTaskEntity.getEntity().setFileSize(mTotalSize);
mTaskEntity.getEntity().update();
} }
} }

@ -91,12 +91,16 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
@Override public void onComplete(String url, int code) { @Override public void onComplete(String url, int code) {
DownloadTaskEntity te = mExeMap.get(url); DownloadTaskEntity te = mExeMap.get(url);
if (te != null) { if (te != null) {
mTotalSize += te.getEntity().getFileSize(); if (isNeedLoadFileSize) {
mTotalSize += te.getEntity().getFileSize();
}
startChildDownload(te); startChildDownload(te);
} }
mInitNum++; mInitNum++;
if (mInitNum + mInitFailNum >= mTaskEntity.getEntity().getSubTask().size()) { if (mInitNum + mInitFailNum >= mTaskEntity.getEntity().getSubTask().size()
|| !isNeedLoadFileSize) {
startRunningFlow(); startRunningFlow();
updateFileSize();
} }
} }
@ -116,8 +120,10 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
if (mActualTaskNum < 0) mActualTaskNum = 0; if (mActualTaskNum < 0) mActualTaskNum = 0;
} }
failNum++; failNum++;
if (mInitNum + mInitFailNum >= mTaskEntity.getEntity().getSubTask().size()) { if (mInitNum + mInitFailNum >= mTaskEntity.getEntity().getSubTask().size()
|| !isNeedLoadFileSize) {
startRunningFlow(); startRunningFlow();
updateFileSize();
} }
} }
}; };

@ -37,7 +37,6 @@ public class FtpDirDownloadUtil extends AbsGroupUtil {
new FtpDirInfoThread(mTaskEntity, new OnFileInfoCallback() { new FtpDirInfoThread(mTaskEntity, new OnFileInfoCallback() {
@Override public void onComplete(String url, int code) { @Override public void onComplete(String url, int code) {
if (code >= 200 && code < 300) { if (code >= 200 && code < 300) {
mTotalSize = mTaskEntity.getEntity().getFileSize();
for (DownloadEntity entity : mTaskEntity.entity.getSubTask()) { for (DownloadEntity entity : mTaskEntity.entity.getSubTask()) {
mExeMap.put(entity.getUrl(), createChildDownloadTask(entity)); mExeMap.put(entity.getUrl(), createChildDownloadTask(entity));
} }

@ -20,10 +20,12 @@ import android.content.Context;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Environment; import android.os.Environment;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.simple.R; import com.arialyy.simple.R;
import com.arialyy.simple.download.multi_download.FileListEntity;
import com.arialyy.simple.base.BaseModule; import com.arialyy.simple.base.BaseModule;
import com.arialyy.simple.download.multi_download.FileListEntity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -54,14 +56,14 @@ public class DownloadModule extends BaseModule {
* 创建下载地址 * 创建下载地址
*/ */
public List<FileListEntity> createMultiTestList() { public List<FileListEntity> createMultiTestList() {
String[] names = getContext().getResources().getStringArray(R.array.file_nams); String[] names = getStringArray(R.array.file_nams);
String[] downloadUrl = getContext().getResources().getStringArray(R.array.download_url); String[] downloadUrl = getStringArray(R.array.download_url);
List<FileListEntity> list = new ArrayList<>(); List<FileListEntity> list = new ArrayList<>();
int i = 0; int i = 0;
for (String name : names) { for (String name : names) {
FileListEntity entity = new FileListEntity(); FileListEntity entity = new FileListEntity();
entity.name = name; entity.name = name;
entity.downloadUrl = downloadUrl[i]; entity.key = downloadUrl[i];
entity.downloadPath = Environment.getExternalStorageDirectory() + "/Download/" + name; entity.downloadPath = Environment.getExternalStorageDirectory() + "/Download/" + name;
list.add(entity); list.add(entity);
i++; i++;
@ -69,6 +71,33 @@ public class DownloadModule extends BaseModule {
return list; return list;
} }
private String[] getStringArray(int array) {
return getContext().getResources().getStringArray(array);
}
/**
* 创建任务组
*/
public List<FileListEntity> createGroupTestList() {
List<FileListEntity> list = new ArrayList<>();
list.add(createGroupEntity(R.array.group_urls, R.array.group_names, "任务组_0"));
list.add(createGroupEntity(R.array.group_urls_1, R.array.group_names_1, "任务组_1"));
list.add(createGroupEntity(R.array.group_urls_2, R.array.group_names_2, "任务组_2"));
list.add(createGroupEntity(R.array.group_urls_3, R.array.group_names_3, "任务组_3"));
return list;
}
private FileListEntity createGroupEntity(int urls, int names, String alias) {
FileListEntity entity = new FileListEntity();
entity.urls = getStringArray(urls);
entity.names = getStringArray(names);
entity.isGroup = true;
entity.name = alias;
entity.key = CommonUtil.getMd5Code(Arrays.asList(entity.urls));
entity.downloadPath = Environment.getExternalStorageDirectory() + "/Download/" + alias;
return entity;
}
/** /**
* 创建下载实体Aria也可以通过下载实体启动下载 * 创建下载实体Aria也可以通过下载实体启动下载
*/ */
@ -80,5 +109,4 @@ public class DownloadModule extends BaseModule {
entity.setDownloadPath(path); entity.setDownloadPath(path);
return entity; return entity;
} }
} }

@ -30,10 +30,13 @@ import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadTarget; import com.arialyy.aria.core.download.DownloadTarget;
import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.download.DownloadTask;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.util.show.L;
import com.arialyy.frame.util.show.T; import com.arialyy.frame.util.show.T;
import com.arialyy.simple.R; import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivitySingleBinding; import com.arialyy.simple.databinding.ActivitySingleBinding;
import java.io.File;
public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
@ -157,6 +160,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
mCancel.setEnabled(false); mCancel.setEnabled(false);
setBtState(true); setBtState(true);
getBinding().setSpeed(""); getBinding().setSpeed("");
L.d(TAG, "md5Code ==> " + CommonUtil.getFileMD5(new File(task.getDownloadPath())));
} }
@Download.onNoSupportBreakPoint(DOWNLOAD_URL) @Download.onNoSupportBreakPoint(DOWNLOAD_URL)

@ -74,7 +74,8 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
.setDownloadDirPath( .setDownloadDirPath(
Environment.getExternalStorageDirectory().getPath() + "/Download/group_test_3") Environment.getExternalStorageDirectory().getPath() + "/Download/group_test_3")
.setGroupAlias("任务组测试") .setGroupAlias("任务组测试")
.setSubTaskFileName(getModule(GroupModule.class).getSubName()) .setSubFileName(getModule(GroupModule.class).getSubName())
.setFileSize(32895492)
.start(); .start();
break; break;
case R.id.stop: case R.id.stop:

@ -26,6 +26,7 @@ import com.arialyy.aria.core.Aria;
import com.arialyy.simple.R; import com.arialyy.simple.R;
import com.arialyy.simple.base.adapter.AbsHolder; import com.arialyy.simple.base.adapter.AbsHolder;
import com.arialyy.simple.base.adapter.AbsRVAdapter; import com.arialyy.simple.base.adapter.AbsRVAdapter;
import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -43,8 +44,8 @@ final class FileListAdapter extends AbsRVAdapter<FileListEntity, FileListAdapter
public FileListAdapter(Context context, List<FileListEntity> data) { public FileListAdapter(Context context, List<FileListEntity> data) {
super(context, data); super(context, data);
for (int i = 0, len = data.size(); i < len; i++) { for (int i = 0, len = data.size(); i < len; i++) {
mBtStates.put(data.get(i).downloadUrl, true); mBtStates.put(data.get(i).key, true);
mPositions.put(data.get(i).downloadUrl, i); mPositions.put(data.get(i).key, i);
} }
} }
@ -59,17 +60,27 @@ final class FileListAdapter extends AbsRVAdapter<FileListEntity, FileListAdapter
@Override @Override
protected void bindData(FileListHolder holder, int position, final FileListEntity item) { protected void bindData(FileListHolder holder, int position, final FileListEntity item) {
holder.name.setText("文件名:" + item.name); holder.name.setText("文件名:" + item.name);
holder.url.setText("下载地址:" + item.downloadUrl); holder.url.setText("下载地址:" + item.key);
holder.url.setVisibility(item.isGroup ? View.GONE : View.VISIBLE);
holder.path.setText("保存路径:" + item.downloadPath); holder.path.setText("保存路径:" + item.downloadPath);
if (mBtStates.get(item.downloadUrl)) { if (mBtStates.get(item.key)) {
holder.bt.setEnabled(true); holder.bt.setEnabled(true);
holder.bt.setOnClickListener(new View.OnClickListener() { holder.bt.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) { @Override public void onClick(View v) {
Toast.makeText(getContext(), "开始下载:" + item.name, Toast.LENGTH_SHORT).show(); Toast.makeText(getContext(), "开始下载:" + item.name, Toast.LENGTH_SHORT).show();
Aria.download(getContext()) if (item.isGroup) {
.load(item.downloadUrl) Aria.download(getContext())
.setDownloadPath(item.downloadPath) .load(Arrays.asList(item.urls))
.start(); .setSubFileName(Arrays.asList(item.names))
.setDownloadDirPath(item.downloadPath)
.setGroupAlias(item.name)
.start();
} else {
Aria.download(getContext())
.load(item.key)
.setDownloadPath(item.downloadPath)
.start();
}
} }
}); });
} else { } else {

@ -21,5 +21,8 @@ package com.arialyy.simple.download.multi_download;
*/ */
public class FileListEntity { public class FileListEntity {
public String name, downloadUrl, downloadPath; public String name, key, downloadPath;
public boolean isGroup = false;
public String[] urls, names;
} }

@ -24,14 +24,14 @@ import android.support.v7.widget.Toolbar;
import android.view.View; import android.view.View;
import butterknife.Bind; import butterknife.Bind;
import com.arialyy.annotations.Download; import com.arialyy.annotations.Download;
import com.arialyy.annotations.DownloadGroup;
import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadGroupTask;
import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.download.DownloadTask;
import com.arialyy.frame.util.show.T;
import com.arialyy.simple.R; import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivityMultiBinding; import com.arialyy.simple.databinding.ActivityMultiBinding;
import com.arialyy.simple.download.DownloadModule; import com.arialyy.simple.download.DownloadModule;
import com.arialyy.simple.download.SingleTaskActivity;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -52,6 +52,7 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
super.init(savedInstanceState); super.init(savedInstanceState);
Aria.download(this).register(); Aria.download(this).register();
setTitle("多任务下载"); setTitle("多任务下载");
mData.addAll(getModule(DownloadModule.class).createGroupTestList());
mData.addAll(getModule(DownloadModule.class).createMultiTestList()); mData.addAll(getModule(DownloadModule.class).createMultiTestList());
mAdapter = new FileListAdapter(this, mData); mAdapter = new FileListAdapter(this, mData);
mList.setLayoutManager(new LinearLayoutManager(this)); mList.setLayoutManager(new LinearLayoutManager(this));
@ -93,7 +94,32 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
mAdapter.updateBtState(task.getKey(), true); mAdapter.updateBtState(task.getKey(), true);
} }
@Download.onTaskComplete void taskComplete(DownloadTask task) { //############################### 任务组 ##############################
@DownloadGroup.onTaskComplete void groupTaskComplete(DownloadGroupTask task) {
mAdapter.updateBtState(task.getKey(), true);
}
@DownloadGroup.onTaskStart void groupTaskStart(DownloadGroupTask task) {
mAdapter.updateBtState(task.getKey(), false);
}
@DownloadGroup.onTaskResume void groupTaskResume(DownloadGroupTask task) {
mAdapter.updateBtState(task.getKey(), false);
}
@DownloadGroup.onTaskStop void groupTaskStop(DownloadGroupTask task) {
mAdapter.updateBtState(task.getKey(), true);
}
@DownloadGroup.onTaskCancel void groupTaskCancel(DownloadGroupTask task) {
mAdapter.updateBtState(task.getKey(), true);
}
@DownloadGroup.onTaskFail void groupTaskFail(DownloadGroupTask task) {
mAdapter.updateBtState(task.getKey(), true);
}
@DownloadGroup.onTaskComplete void taskComplete(DownloadGroupTask task) {
mAdapter.updateBtState(task.getKey(), true); mAdapter.updateBtState(task.getKey(), true);
} }

@ -50,10 +50,23 @@
<!--<item>https://res5.d.cn/5a6a3384c1b2be1a65d84b914e6a6fef697637578b6db2eb1056d50b09cf1dcf289d4045df7ef95746e498e3d6a848ab84c89b77aa60194e2c48e5a7cb748265.apk</item>--> <!--<item>https://res5.d.cn/5a6a3384c1b2be1a65d84b914e6a6fef697637578b6db2eb1056d50b09cf1dcf289d4045df7ef95746e498e3d6a848ab84c89b77aa60194e2c48e5a7cb748265.apk</item>-->
<!--<item>https://res5.d.cn/5a6a3384c1b2be1a52034c72752e8475414630ebc69318b84ef584115ebf5eaaab945ae07b7fe3596afc72a7940ff328d4a9553f6ae92d6c09ba4bfb533137f6.apk</item>--> <!--<item>https://res5.d.cn/5a6a3384c1b2be1a52034c72752e8475414630ebc69318b84ef584115ebf5eaaab945ae07b7fe3596afc72a7940ff328d4a9553f6ae92d6c09ba4bfb533137f6.apk</item>-->
<!--<item>https://res5.d.cn/5a6a3384c1b2be1a426f06bfc69034d69c44ae1a01da180cab8e59bd1a5e1a784bac46ba0c64579d14f0e80a4ce4f068af89b0369a393456f4f449a8829cad5c.apk</item>--> <!--<item>https://res5.d.cn/5a6a3384c1b2be1a426f06bfc69034d69c44ae1a01da180cab8e59bd1a5e1a784bac46ba0c64579d14f0e80a4ce4f068af89b0369a393456f4f449a8829cad5c.apk</item>-->
<item>http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk</item> <item>http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk</item>
<item>http://static.ilongyuan.cn/rayark/RayarkFZ_2.0.7.apk</item> <item>http://static.ilongyuan.cn/rayark/RayarkFZ_2.0.7.apk</item>
</string-array>
<string-array name="group_urls_1">
<item>http://droidweb.smartgame-down.com/201708171123/C183E9C2010C7CABACFB398250A3DB75/new/game1/1/107001/qq_1502875308555.apk?f=web_1</item>
<item>http://droidweb.smartgame-down.com/201708171124/6E5AF91791661236D0A2F60125D3B45F/new/game1/93/113093/00D42A6AA63A039485F510C2E4D69BAA_1498831237.apk?f=web_1</item>
</string-array>
<string-array name="group_urls_2">
<item>http://droidweb.smartgame-down.com/201708171125/005BCF0FFBB75510958D14074286B25F/new/game1/2/106202/qqkj_1502868291416.apk?f=web_1</item>
<item>http://droidweb.smartgame-down.com/201708171126/05FAAA4FD294BC63AA8F792636961D19/new/game1/72/110472/com.taobao.taobao-6.9.0-157-0629_1498744826.apk?f=web_1</item>
</string-array>
<string-array name="group_urls_3">
<item>http://droidweb.smartgame-down.com/201708171127/F55445FD8B7BBA8D72CA4B7D7BD91F90/new/game1/84/33184/txtim_1502854269836.apk?f=web_1</item>
<item>http://droidweb.smartgame-down.com/201708171128/5C4D0289F0B83690BF252420F473FB9F/new/game1/46/108046/com.shuqi.controller-10.5.2.50-137-0703_1499083244.apk?f=web_1</item>
</string-array> </string-array>
<string-array name="group_names"> <string-array name="group_names">
@ -62,4 +75,19 @@
<!--<item>天魔幻想.apk</item>--> <!--<item>天魔幻想.apk</item>-->
</string-array> </string-array>
<string-array name="group_names_1">
<item>QQ.apk</item>
<item>百度贴吧.apk</item>
</string-array>
<string-array name="group_names_2">
<item>QQ空间.apk</item>
<item>淘宝.apk</item>
</string-array>
<string-array name="group_names_3">
<item>TIM.apk</item>
<item>书旗小说.apk</item>
</string-array>
</resources> </resources>

@ -5,8 +5,8 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
// classpath 'com.android.tools.build:gradle:2.3.0' classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:2.2.2' // classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.novoda:bintray-release:0.5.0' classpath 'com.novoda:bintray-release:0.5.0'
// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7' // classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
// classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' // classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
@ -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.20' publishVersion = '3.2.22'
repoName='maven' repoName='maven'
desc = 'android 下载框架' desc = 'android 下载框架'
website = 'https://github.com/AriaLyy/Aria' website = 'https://github.com/AriaLyy/Aria'

Loading…
Cancel
Save