diff --git a/Aria/build.gradle b/Aria/build.gradle index 3d928fe3..bb418815 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -7,8 +7,8 @@ android { defaultConfig { minSdkVersion 9 targetSdkVersion 23 - versionCode 317 - versionName "3.1.7" + versionCode 327 + versionName "3.2.7" } buildTypes { release { @@ -22,7 +22,6 @@ dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' -// compile project(':AriaCompiler') - compile project(':AriaAnnotations') //gradle 打包时打开这个 + compile project(':AriaAnnotations') } apply from: 'bintray-release.gradle' diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/ProxyHelper.java b/Aria/src/main/java/com/arialyy/aria/core/ProxyHelper.java similarity index 96% rename from Aria/src/main/java/com/arialyy/aria/core/upload/ProxyHelper.java rename to Aria/src/main/java/com/arialyy/aria/core/ProxyHelper.java index 7162301a..c1d1236f 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/ProxyHelper.java +++ b/Aria/src/main/java/com/arialyy/aria/core/ProxyHelper.java @@ -13,9 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package com.arialyy.aria.core.upload; +package com.arialyy.aria.core; -import com.arialyy.aria.core.AriaManager; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Set; diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java index 7da4a5ca..25e9a8e7 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java @@ -19,15 +19,9 @@ package com.arialyy.aria.core.command.normal; import android.text.TextUtils; import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.QueueMod; -import com.arialyy.aria.core.download.DownloadGroupTask; -import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.AbsTaskEntity; -import com.arialyy.aria.core.queue.DownloadGroupTaskQueue; -import com.arialyy.aria.core.queue.DownloadTaskQueue; -import com.arialyy.aria.core.scheduler.DQueueMapping; -import com.arialyy.aria.orm.Primary; /** * Created by lyy on 2016/8/22. diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DListener.java b/Aria/src/main/java/com/arialyy/aria/core/download/BaseListener.java similarity index 69% rename from Aria/src/main/java/com/arialyy/aria/core/download/DListener.java rename to Aria/src/main/java/com/arialyy/aria/core/download/BaseListener.java index 2d31b0d8..dbbed555 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DListener.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/BaseListener.java @@ -17,10 +17,10 @@ package com.arialyy.aria.core.download; import android.os.Handler; import com.arialyy.aria.core.AriaManager; -import com.arialyy.aria.core.download.downloader.DownloadListener; import com.arialyy.aria.core.inf.AbsEntity; import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.IEntity; +import com.arialyy.aria.core.inf.IEventListener; import com.arialyy.aria.core.scheduler.ISchedulers; import com.arialyy.aria.util.CommonUtil; import java.lang.ref.WeakReference; @@ -28,22 +28,23 @@ import java.lang.ref.WeakReference; /** * 下载监听类 */ -class DListener> - extends DownloadListener { +class BaseListener> + implements IEventListener { private WeakReference outHandler; - private long lastLen = 0; //上一次发送长度 + private long mLastLen = 0; //上一次发送长度 private boolean isFirst = true; - private ENTITY entity; - private TASK task; + protected ENTITY mEntity; + protected TASK mTask; private boolean isConvertSpeed = false; boolean isWait = false; - DListener(TASK task, Handler outHandler) { + BaseListener(TASK task, Handler outHandler) { this.outHandler = new WeakReference<>(outHandler); - this.task = new WeakReference<>(task).get(); - this.entity = this.task.getEntity(); + this.mTask = new WeakReference<>(task).get(); + this.mEntity = this.mTask.getEntity(); final AriaManager manager = AriaManager.getInstance(AriaManager.APP); isConvertSpeed = manager.getDownloadConfig().isConvertSpeed(); + mLastLen = mEntity.getCurrentProgress(); } @Override public void onPre() { @@ -52,8 +53,8 @@ class DListener> } @Override public void onPostPre(long fileSize) { - entity.setFileSize(fileSize); - entity.setConvertFileSize(CommonUtil.formatFileSize(fileSize)); + mEntity.setFileSize(fileSize); + mEntity.setConvertFileSize(CommonUtil.formatFileSize(fileSize)); saveData(IEntity.STATE_POST_PRE, -1); sendInState2Target(ISchedulers.POST_PRE); } @@ -69,15 +70,15 @@ class DListener> } @Override public void onProgress(long currentLocation) { - entity.setCurrentProgress(currentLocation); - long speed = currentLocation - lastLen; + mEntity.setCurrentProgress(currentLocation); + long speed = currentLocation - mLastLen; if (isFirst) { speed = 0; isFirst = false; } handleSpeed(speed); sendInState2Target(ISchedulers.RUNNING); - lastLen = currentLocation; + mLastLen = currentLocation; } @Override public void onStop(long stopLocation) { @@ -93,23 +94,23 @@ class DListener> } @Override public void onComplete() { - saveData(IEntity.STATE_COMPLETE, entity.getFileSize()); + saveData(IEntity.STATE_COMPLETE, mEntity.getFileSize()); handleSpeed(0); sendInState2Target(ISchedulers.COMPLETE); } @Override public void onFail() { - entity.setFailNum(entity.getFailNum() + 1); - saveData(IEntity.STATE_FAIL, -1); + mEntity.setFailNum(mEntity.getFailNum() + 1); + saveData(IEntity.STATE_FAIL, mEntity.getCurrentProgress()); handleSpeed(0); sendInState2Target(ISchedulers.FAIL); } private void handleSpeed(long speed) { if (isConvertSpeed) { - entity.setConvertSpeed(CommonUtil.formatFileSize(speed) + "/s"); + mEntity.setConvertSpeed(CommonUtil.formatFileSize(speed < 0 ? 0 : speed) + "/s"); } else { - entity.setSpeed(speed); + mEntity.setSpeed(speed < 0 ? 0 : speed); } } @@ -120,25 +121,25 @@ class DListener> */ private void sendInState2Target(int state) { if (outHandler.get() != null) { - outHandler.get().obtainMessage(state, task).sendToTarget(); + outHandler.get().obtainMessage(state, mTask).sendToTarget(); } } private void saveData(int state, long location) { + mEntity.setComplete(state == IEntity.STATE_COMPLETE); if (state == IEntity.STATE_CANCEL) { - entity.deleteData(); + mEntity.deleteData(); } else if (state == IEntity.STATE_COMPLETE) { - entity.setState(state); - entity.setComplete(true); - entity.setCompleteTime(System.currentTimeMillis()); - entity.setCurrentProgress(entity.getFileSize()); - entity.update(); + mEntity.setState(state); + mEntity.setCompleteTime(System.currentTimeMillis()); + mEntity.setCurrentProgress(mEntity.getFileSize()); + mEntity.update(); } else { - entity.setState(state); + mEntity.setState(state); if (location != -1) { - entity.setCurrentProgress(location); + mEntity.setCurrentProgress(location); } - entity.update(); + mEntity.update(); } } } \ No newline at end of file diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupListener.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupListener.java new file mode 100644 index 00000000..e590bd1a --- /dev/null +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupListener.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.arialyy.aria.core.download; + +import android.os.Handler; +import android.util.Log; +import com.arialyy.aria.core.download.downloader.IDownloadGroupListener; + +/** + * Created by Aria.Lao on 2017/7/20. + * 任务组下载事件 + */ +class DownloadGroupListener extends BaseListener + implements IDownloadGroupListener { + private final String TAG = "DownloadGroupListener"; + + DownloadGroupListener(DownloadGroupTask task, Handler outHandler) { + super(task, outHandler); + } + + @Override public void supportBreakpoint(boolean support, DownloadEntity subEntity) { + + } + + @Override public void onSubStart(DownloadEntity subEntity) { + + } + + @Override public void onSubStop(DownloadEntity subEntity) { + saveCurrentLocation(); + } + + @Override public void onSubComplete(DownloadEntity subEntity) { + saveCurrentLocation(); + } + + @Override public void onSubFail(DownloadEntity subEntity) { + saveCurrentLocation(); + } + + @Override public void onSubCancel(DownloadEntity entity) { + saveCurrentLocation(); + } + + private void saveCurrentLocation() { + long location = 0; + for (DownloadEntity e : mEntity.getSubTask()) { + location += e.getCurrentProgress(); + } + mEntity.setCurrentProgress(location); + mEntity.update(); + } +} 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 e77e1c06..90f6c7c8 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 @@ -207,10 +207,11 @@ public class DownloadGroupTarget if (!newName.equals(entity.getFileName())) { String oldPath = mEntity.getDirPath() + "/" + entity.getFileName(); String newPath = mEntity.getDirPath() + "/" + newName; - File file = new File(oldPath); - if (file.exists()) { - file.renameTo(new File(newPath)); + File oldFile = new File(oldPath); + if (oldFile.exists()) { + oldFile.renameTo(new File(newPath)); } + CommonUtil.renameDownloadConfig(oldFile.getName(), newName); DbEntity.exeSql( "UPDATE DownloadTaskEntity SET key='" + newPath + "' WHERE key='" + oldPath + "'"); entity.setDownloadPath(newPath); diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTask.java index 1a375bba..6c668ad2 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTask.java @@ -29,7 +29,7 @@ import com.arialyy.aria.util.CheckUtil; */ public class DownloadGroupTask extends AbsGroupTask { private final String TAG = "DownloadGroupTask"; - private DListener mListener; + private DownloadGroupListener mListener; private IDownloadUtil mUtil; private DownloadGroupTask(DownloadGroupTaskEntity taskEntity, Handler outHandler) { @@ -37,7 +37,7 @@ public class DownloadGroupTask extends AbsGroupTask(this, mOutHandler); + mListener = new DownloadGroupListener(this, mOutHandler); mUtil = new DownloadGroupUtil(mListener, mTaskEntity); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadListener.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadListener.java new file mode 100644 index 00000000..3d758029 --- /dev/null +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadListener.java @@ -0,0 +1,35 @@ +/* + * Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.arialyy.aria.core.download; + +import android.os.Handler; +import com.arialyy.aria.core.download.downloader.IDownloadListener; + +/** + * Created by Aria.Lao on 2017/7/20. + * 普通任务下载的事件监听器 + */ +class DownloadListener extends BaseListener + implements IDownloadListener { + DownloadListener(DownloadTask task, Handler outHandler) { + super(task, outHandler); + } + + @Override public void supportBreakpoint(boolean support) { + + } + +} diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java index ff289bd7..94bc57d9 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java @@ -24,7 +24,7 @@ import com.arialyy.aria.core.command.normal.NormalCmdFactory; import com.arialyy.aria.core.scheduler.DownloadGroupSchedulers; import com.arialyy.aria.core.scheduler.DownloadSchedulers; import com.arialyy.aria.core.scheduler.ISchedulerListener; -import com.arialyy.aria.core.upload.ProxyHelper; +import com.arialyy.aria.core.ProxyHelper; import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.util.CheckUtil; import com.arialyy.aria.util.CommonUtil; 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 c77e853c..68cbcd5e 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 @@ -21,6 +21,7 @@ import com.arialyy.aria.core.inf.AbsNormalTarget; import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.queue.DownloadTaskQueue; import com.arialyy.aria.orm.DbEntity; +import com.arialyy.aria.util.CommonUtil; import java.io.File; /** @@ -48,7 +49,7 @@ public class DownloadTarget if (mTaskEntity.entity == null) { mTaskEntity.entity = entity; } - mEntity = entity; + mEntity = mTaskEntity.entity; } /** @@ -102,42 +103,32 @@ public class DownloadTarget } /** - * 设置文件存储路径 + * 设置文件存储路径,如果需要修改新的文件名,修改路径便可。 + * 如:原文件路径 /mnt/sdcard/test.zip + * 如果需要将test.zip改为game.zip,只需要重新设置文件路径为:/mnt/sdcard/game.zip + * + * @param downloadPath 路径必须为文件路径,不能为文件夹路径 */ public DownloadTarget setDownloadPath(@NonNull String downloadPath) { if (TextUtils.isEmpty(downloadPath)) { throw new IllegalArgumentException("文件保持路径不能为null"); } File file = new File(downloadPath); - mEntity.setDownloadPath(downloadPath); - mEntity.setFileName(file.getName()); - mTaskEntity.key = downloadPath; - mEntity.update(); - mTaskEntity.update(); - return this; - } - - /** - * 设置文件名 - * - * @deprecated {@link #setFileName(String)} - */ - @Deprecated public DownloadTarget setDownloadName(@NonNull String downloadName) { - if (TextUtils.isEmpty(downloadName)) { - throw new IllegalArgumentException("文件名不能为null"); + if (file.isDirectory()) { + throw new IllegalArgumentException("文件不能为文件夹"); } - mEntity.setFileName(downloadName); - return this; - } - - /** - * 设置文件名 - */ - public DownloadTarget setFileName(@NonNull String fileName) { - if (TextUtils.isEmpty(fileName)) { - throw new IllegalArgumentException("文件名不能为null"); + if (!downloadPath.equals(mEntity.getDownloadPath())) { + File oldFile = new File(mEntity.getDownloadPath()); + File newFile = new File(downloadPath); + if (TextUtils.isEmpty(mEntity.getDownloadPath()) || oldFile.renameTo(newFile)) { + mEntity.setDownloadPath(downloadPath); + mEntity.setFileName(newFile.getName()); + mTaskEntity.key = downloadPath; + mEntity.update(); + mTaskEntity.update(); + CommonUtil.renameDownloadConfig(oldFile.getName(), newFile.getName()); + } } - mEntity.setFileName(fileName); return this; } 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 6e08b321..de0b2066 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 @@ -32,14 +32,14 @@ import java.io.File; public class DownloadTask extends AbsNormalTask { public static final String TAG = "DownloadTask"; - private DListener mListener; + private DownloadListener mListener; private SimpleDownloadUtil mUtil; private DownloadTask(DownloadTaskEntity taskEntity, Handler outHandler) { mEntity = taskEntity.getEntity(); mOutHandler = outHandler; mContext = AriaManager.APP; - mListener = new DListener<>(this, mOutHandler); + mListener = new DownloadListener(this, mOutHandler); mUtil = new SimpleDownloadUtil(taskEntity, mListener); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadGroupUtil.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadGroupUtil.java index d8a44363..fefe5a20 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadGroupUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadGroupUtil.java @@ -45,7 +45,7 @@ public class DownloadGroupUtil implements IDownloadUtil { private long mCurrentLocation = 0; private ExecutorService mInfoPool; private ExecutorService mExePool; - private IDownloadListener mListener; + private IDownloadGroupListener mListener; private DownloadGroupTaskEntity mTaskEntity; private boolean isRunning = true; private Timer mTimer; @@ -87,7 +87,7 @@ public class DownloadGroupUtil implements IDownloadUtil { //实际的下载任务数 private int mActualTaskNum = 0; - public DownloadGroupUtil(IDownloadListener listener, DownloadGroupTaskEntity taskEntity) { + public DownloadGroupUtil(IDownloadGroupListener listener, DownloadGroupTaskEntity taskEntity) { mListener = listener; mTaskEntity = taskEntity; mInfoPool = Executors.newCachedThreadPool(); @@ -102,8 +102,7 @@ public class DownloadGroupUtil implements IDownloadUtil { } for (DownloadEntity entity : mTaskEntity.entity.getSubTask()) { File file = new File(entity.getDownloadPath()); - if (entity.isComplete() && file.exists()) { - mTotalSize += entity.getFileSize(); + if (entity.getState() == IEntity.STATE_COMPLETE && file.exists()) { mCompleteNum++; mInitNum++; mCurrentLocation += entity.getFileSize(); @@ -111,6 +110,7 @@ public class DownloadGroupUtil implements IDownloadUtil { mExeMap.put(entity.getDownloadUrl(), createChildDownloadTask(entity)); mCurrentLocation += entity.getCurrentProgress(); } + mTotalSize += entity.getFileSize(); } } @@ -127,8 +127,7 @@ public class DownloadGroupUtil implements IDownloadUtil { } @Override public void cancelDownload() { - isRunning = false; - closeTimer(); + closeTimer(false); mListener.onCancel(); if (!mInfoPool.isShutdown()) { mInfoPool.shutdown(); @@ -161,8 +160,7 @@ public class DownloadGroupUtil implements IDownloadUtil { } @Override public void stopDownload() { - isRunning = false; - closeTimer(); + closeTimer(false); mListener.onStop(mCurrentLocation); if (!mInfoPool.isShutdown()) { mInfoPool.shutdown(); @@ -182,14 +180,23 @@ public class DownloadGroupUtil implements IDownloadUtil { @Override public void startDownload() { isRunning = true; + mFailNum = 0; Set keys = mExeMap.keySet(); mListener.onPre(); + int i = 0; for (String key : keys) { DownloadTaskEntity taskEntity = mExeMap.get(key); if (taskEntity != null) { - mInfoPool.execute(createFileInfoThread(taskEntity)); + if (taskEntity.getState() != IEntity.STATE_FAIL + && taskEntity.getState() != IEntity.STATE_WAIT) { + startChildDownload(taskEntity); + i++; + } else { + mInfoPool.execute(createFileInfoThread(taskEntity)); + } } } + if (i == mExeMap.size()) startRunningFlow(); } @Override public void resumeDownload() { @@ -214,7 +221,7 @@ public class DownloadGroupUtil implements IDownloadUtil { startChildDownload(te); } mInitNum++; - if (mInitNum + mInitFailNum == mTaskEntity.getEntity().getSubTask().size()) { + if (mInitNum + mInitFailNum >= mTaskEntity.getEntity().getSubTask().size()) { startRunningFlow(); } } @@ -235,7 +242,7 @@ public class DownloadGroupUtil implements IDownloadUtil { if (mActualTaskNum < 0) mActualTaskNum = 0; } failNum++; - if (mInitNum + mInitFailNum == mTaskEntity.getEntity().getSubTask().size()) { + if (mInitNum + mInitFailNum >= mTaskEntity.getEntity().getSubTask().size()) { startRunningFlow(); } } @@ -244,7 +251,8 @@ public class DownloadGroupUtil implements IDownloadUtil { return new FileInfoThread(taskEntity, callback); } - private void closeTimer() { + private void closeTimer(boolean isRunning) { + this.isRunning = isRunning; if (mTimer != null) { mTimer.purge(); mTimer.cancel(); @@ -255,13 +263,15 @@ public class DownloadGroupUtil implements IDownloadUtil { * 开始进度流程 */ private void startRunningFlow() { - closeTimer(); + closeTimer(true); mListener.onPostPre(mTotalSize); mListener.onStart(mCurrentLocation); mTimer = new Timer(true); mTimer.schedule(new TimerTask() { @Override public void run() { - if (mCurrentLocation >= 0) { + if (!isRunning) { + closeTimer(false); + } else if (mCurrentLocation >= 0) { mListener.onProgress(mCurrentLocation); } } @@ -304,7 +314,7 @@ public class DownloadGroupUtil implements IDownloadUtil { /** * 子任务事件监听 */ - private class ChildDownloadListener extends DownloadListener { + private class ChildDownloadListener implements IDownloadListener { DownloadTaskEntity taskEntity; DownloadEntity entity; @@ -314,6 +324,8 @@ public class DownloadGroupUtil implements IDownloadUtil { ChildDownloadListener(DownloadTaskEntity entity) { this.taskEntity = entity; this.entity = taskEntity.getEntity(); + lastLen = this.entity.getCurrentProgress(); + this.entity.setFailNum(0); } @Override public void onPre() { @@ -347,26 +359,35 @@ public class DownloadGroupUtil implements IDownloadUtil { @Override public void onStop(long stopLocation) { saveData(IEntity.STATE_STOP, stopLocation); handleSpeed(0); + mListener.onSubStop(entity); } @Override public void onCancel() { saveData(IEntity.STATE_CANCEL, -1); handleSpeed(0); + mListener.onSubCancel(entity); } @Override public void onComplete() { saveData(IEntity.STATE_COMPLETE, entity.getFileSize()); mCompleteNum++; + handleSpeed(0); + mListener.onSubComplete(entity); + //如果子任务完成的数量和总任务数一致,表示任务组任务已经完成 + if (mCompleteNum >= mTaskEntity.getEntity().getSubTask().size()){ + closeTimer(false); + mListener.onComplete(); + } + //如果子任务完成数量加上失败的数量和总任务数一致,则任务组停止下载 if (mCompleteNum + mFailNum >= mActualTaskNum) { - closeTimer(); + closeTimer(false); mListener.onComplete(); } - handleSpeed(0); } @Override public void onFail() { entity.setFailNum(entity.getFailNum() + 1); - saveData(IEntity.STATE_FAIL, -1); + saveData(IEntity.STATE_FAIL, lastLen); handleSpeed(0); reTry(); } @@ -376,13 +397,28 @@ public class DownloadGroupUtil implements IDownloadUtil { */ private void reTry() { if (entity.getFailNum() < 5) { - Downloader dt = mDownloaderMap.get(entity.getDownloadUrl()); - dt.startDownload(); + reStartTask(); } else { mFailNum++; + mListener.onSubFail(entity); + //如果失败的任务数大于实际的下载任务数,任务组停止下载 + if (mFailNum >= mActualTaskNum) { + closeTimer(false); + mListener.onStop(mCurrentLocation); + } } } + private void reStartTask() { + Timer timer = new Timer(); + timer.schedule(new TimerTask() { + @Override public void run() { + Downloader dt = mDownloaderMap.get(entity.getDownloadUrl()); + dt.startDownload(); + } + }, 3000); + } + private void handleSpeed(long speed) { entity.setSpeed(speed); entity.setConvertSpeed(speed <= 0 ? "" : CommonUtil.formatFileSize(speed) + "/s"); @@ -394,10 +430,14 @@ public class DownloadGroupUtil implements IDownloadUtil { if (entity.isComplete()) { entity.setCompleteTime(System.currentTimeMillis()); entity.setCurrentProgress(entity.getFileSize()); - } else { + } else if (location > 0) { entity.setCurrentProgress(location); } entity.update(); } + + @Override public void supportBreakpoint(boolean support) { + + } } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadListener.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadListener.java deleted file mode 100644 index f8d2349e..00000000 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadListener.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.arialyy.aria.core.download.downloader; - - -/** - * @author lyy - */ -public class DownloadListener implements IDownloadListener { - - @Override public void onResume(long resumeLocation) { - - } - - @Override public void supportBreakpoint(boolean support) { - - } - - @Override public void onCancel() { - - } - - @Override public void onFail() { - - } - - @Override public void onPre() { - - } - - @Override public void onPostPre(long fileSize) { - - } - - @Override public void onProgress(long currentLocation) { - - } - - @Override public void onChildComplete(long finishLocation) { - - } - - @Override public void onStart(long startLocation) { - - } - - @Override public void onChildResume(long resumeLocation) { - - } - - @Override public void onStop(long stopLocation) { - - } - - @Override public void onComplete() { - - } -} \ No newline at end of file diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/Downloader.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/Downloader.java index a7fa8721..172731e1 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/Downloader.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/Downloader.java @@ -111,7 +111,7 @@ class Downloader implements Runnable, IDownloadUtil { mTimer = new Timer(true); mTimer.schedule(new TimerTask() { @Override public void run() { - if (mConstance.isComplete()) { + if (mConstance.isComplete() || !mConstance.isDownloading) { closeTimer(); } else if (mConstance.CURRENT_LOCATION >= 0) { mListener.onProgress(mConstance.CURRENT_LOCATION); @@ -343,7 +343,6 @@ class Downloader implements Runnable, IDownloadUtil { Long r = Long.parseLong(record + ""); mConstance.CURRENT_LOCATION += r - startL; Log.d(TAG, "任务【" + mEntity.getFileName() + "】线程__" + i + "__恢复下载"); - mListener.onChildResume(r); startL = r; recordL[rl] = i; rl++; diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/IDownloadGroupListener.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/IDownloadGroupListener.java new file mode 100644 index 00000000..2b0f130f --- /dev/null +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/IDownloadGroupListener.java @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.arialyy.aria.core.download.downloader; + +import com.arialyy.aria.core.download.DownloadEntity; +import com.arialyy.aria.core.inf.IEventListener; + +/** + * Created by Aria.Lao on 2017/7/20. + * 下载任务组事件 + */ +public interface IDownloadGroupListener extends IEventListener { + + /** + * 子任务支持断点回调 + * + * @param support true,支持;false 不支持 + */ + void supportBreakpoint(boolean support, DownloadEntity subEntity); + + /** + * 子任务开始下载\恢复下载 + */ + void onSubStart(DownloadEntity subEntity); + + /** + * 子任务停止下载 + */ + void onSubStop(DownloadEntity subEntity); + + /** + * 子任务下载完成 + */ + void onSubComplete(DownloadEntity subEntity); + + /** + * 子任务下载失败 + */ + void onSubFail(DownloadEntity subEntity); + + /** + * 子任务取消下载 + */ + void onSubCancel(DownloadEntity subEntity); +} diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/IDownloadListener.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/IDownloadListener.java index aa6f3e2d..131c8779 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/IDownloadListener.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/IDownloadListener.java @@ -21,7 +21,7 @@ import com.arialyy.aria.core.inf.IEventListener; /** * 下载监听 */ -interface IDownloadListener extends IEventListener { +public interface IDownloadListener extends IEventListener { /** * 支持断点回调 @@ -29,14 +29,4 @@ interface IDownloadListener extends IEventListener { * @param support true,支持;false 不支持 */ void supportBreakpoint(boolean support); - - /** - * 单一线程的结束位置 - */ - void onChildComplete(long finishLocation); - - /** - * 子程恢复下载的位置 - */ - void onChildResume(long resumeLocation); } \ No newline at end of file diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/SingleThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/SingleThreadTask.java index 8efe4eb3..65c51cc4 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/SingleThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/SingleThreadTask.java @@ -134,7 +134,6 @@ final class SingleThreadTask implements Runnable { + mConfigEntity.THREAD_ID + "__下载完毕"); writeConfig(true, 1); - mListener.onChildComplete(mConfigEntity.END_LOCATION); CONSTANCE.COMPLETE_THREAD_NUM++; if (CONSTANCE.isComplete()) { File configFile = new File(mConfigFPath); diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java index ed651e99..84ec2588 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java +++ b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java @@ -84,4 +84,13 @@ public abstract class AbsTaskEntity extends DbEntity { public int code; public abstract ENTITY getEntity(); + + /** + * 获取任务下载状态 + * + * @return {@link IEntity} + */ + public int getState() { + return getEntity().getState(); + } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadGroupTaskQueue.java b/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadGroupTaskQueue.java index 1cbd63f1..781e2e1e 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadGroupTaskQueue.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadGroupTaskQueue.java @@ -25,7 +25,6 @@ import com.arialyy.aria.core.download.DownloadGroupTaskEntity; import com.arialyy.aria.core.queue.pool.BaseCachePool; import com.arialyy.aria.core.queue.pool.BaseExecutePool; import com.arialyy.aria.core.queue.pool.DownloadSharePool; -import com.arialyy.aria.core.scheduler.DQueueMapping; import com.arialyy.aria.core.scheduler.DownloadGroupSchedulers; /** @@ -65,8 +64,6 @@ public class DownloadGroupTaskQueue .createTask(targetName, entity, DownloadGroupSchedulers.getInstance()); entity.key = entity.getEntity().getGroupName(); mCachePool.putTask(task); - - DQueueMapping.getInstance().addType(task.getKey(), DQueueMapping.QUEUE_TYPE_DOWNLOAD_GROUP); } else { Log.e(TAG, "target name 为 null!!"); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java b/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java index 24d4344c..3eda8f38 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java @@ -25,7 +25,6 @@ import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.queue.pool.BaseCachePool; import com.arialyy.aria.core.queue.pool.BaseExecutePool; import com.arialyy.aria.core.queue.pool.DownloadSharePool; -import com.arialyy.aria.core.scheduler.DQueueMapping; import com.arialyy.aria.core.scheduler.DownloadSchedulers; import java.util.LinkedHashSet; import java.util.Map; @@ -130,8 +129,6 @@ public class DownloadTaskQueue .createTask(target, entity, DownloadSchedulers.getInstance()); entity.key = entity.getEntity().getDownloadPath(); mCachePool.putTask(task); - - DQueueMapping.getInstance().addType(task.getKey(), DQueueMapping.QUEUE_TYPE_DOWNLOAD); } else { Log.e(TAG, "target name 为 null!!"); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/pool/BaseExecutePool.java b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/BaseExecutePool.java index fda42905..ee9a10a0 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/pool/BaseExecutePool.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/BaseExecutePool.java @@ -21,7 +21,6 @@ import android.util.Log; import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.ITask; -import com.arialyy.aria.core.scheduler.DQueueMapping; import com.arialyy.aria.util.CommonUtil; import java.util.HashMap; import java.util.Map; @@ -186,8 +185,6 @@ public class BaseExecutePool implements IPool { String convertKey = CommonUtil.keyToHashKey(key); TASK task = mExecuteMap.get(convertKey); mExecuteMap.remove(convertKey); - - DQueueMapping.getInstance().removeType(key); return mExecuteQueue.remove(task); } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DownloadExecutePool.java b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DownloadExecutePool.java index 6123a62b..5c4d03e8 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DownloadExecutePool.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/DownloadExecutePool.java @@ -26,7 +26,7 @@ import java.util.concurrent.TimeUnit; * Created by AriaL on 2017/6/29. * 单个下载任务的执行池 */ -public class DownloadExecutePool extends BaseExecutePool { +class DownloadExecutePool extends BaseExecutePool { private final String TAG = "DownloadExecutePool"; @Override protected int getMaxSize() { @@ -41,6 +41,7 @@ public class DownloadExecutePool extends BaseExecutePool types = new LinkedHashMap<>(); - - private static volatile DQueueMapping instance = null; - - private DQueueMapping() { - - } - - public static DQueueMapping getInstance() { - if (instance == null) { - synchronized (AriaManager.LOCK) { - instance = new DQueueMapping(); - } - } - return instance; - } - - /** - * map中增加类型 - * - * @param key 任务的key - * @param type {@link #QUEUE_TYPE_DOWNLOAD}、{@link #QUEUE_TYPE_DOWNLOAD} - */ - public void addType(String key, int type) { - types.put(key, type); - } - - /** - * @param key 任务的key - */ - public void removeType(String key) { - types.remove(key); - } - - /** - * 获取下一个任务类型 - * - * @return {@link #QUEUE_TYPE_DOWNLOAD}、{@link #QUEUE_TYPE_DOWNLOAD} - */ - public int nextType() { - Iterator> iter = types.entrySet().iterator(); - if (iter.hasNext()) { - Map.Entry next = iter.next(); - int type = next.getValue(); - iter.remove(); - return type; - } - return QUEUE_NONE; - } - - public boolean canStart() { - return DownloadTaskQueue.getInstance().getCurrentExePoolNum() - + DownloadGroupTaskQueue.getInstance().getCurrentExePoolNum() >= AriaManager.getInstance( - AriaManager.APP).getDownloadConfig().getMaxTaskNum(); - } -} diff --git a/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadGroupSchedulers.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadGroupSchedulers.java index dd4dde4a..9d2a6d11 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadGroupSchedulers.java +++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadGroupSchedulers.java @@ -50,25 +50,4 @@ public class DownloadGroupSchedulers extends @Override String getProxySuffix() { return "$$DownloadGroupListenerProxy"; } - - @Override protected void startNextTask() { - if (getExeTaskNum() + DownloadSchedulers.getInstance().getExeTaskNum() - >= AriaManager.getInstance(AriaManager.APP).getDownloadConfig().getMaxTaskNum()) { - return; - } - if (!DownloadSchedulers.getInstance().hasNextTask()) { - nextSelf(); - } else { - Integer nextType = DQueueMapping.getInstance().nextType(); - if (nextType == DQueueMapping.QUEUE_TYPE_DOWNLOAD) { - DownloadSchedulers.getInstance().nextSelf(); - } else { - nextSelf(); - } - } - } - - void nextSelf() { - super.startNextTask(); - } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java index 5226c13b..3c492174 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java +++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java @@ -16,13 +16,11 @@ package com.arialyy.aria.core.scheduler; -import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.queue.DownloadTaskQueue; import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadTask; -import java.nio.MappedByteBuffer; /** * Created by lyy on 2016/8/16. @@ -54,25 +52,4 @@ public class DownloadSchedulers @Override String getProxySuffix() { return "$$DownloadListenerProxy"; } - - @Override protected void startNextTask() { - if (getExeTaskNum() + DownloadGroupSchedulers.getInstance().getExeTaskNum() - >= AriaManager.getInstance(AriaManager.APP).getDownloadConfig().getMaxTaskNum()) { - return; - } - if (!DownloadGroupSchedulers.getInstance().hasNextTask()) { - nextSelf(); - } else { - Integer nextType = DQueueMapping.getInstance().nextType(); - if (nextType == DQueueMapping.QUEUE_TYPE_DOWNLOAD_GROUP) { - DownloadGroupSchedulers.getInstance().nextSelf(); - } else { - nextSelf(); - } - } - } - - void nextSelf() { - super.startNextTask(); - } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadReceiver.java b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadReceiver.java index eab63b7c..9df0a8b9 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadReceiver.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadReceiver.java @@ -17,6 +17,7 @@ package com.arialyy.aria.core.upload; import android.support.annotation.NonNull; import com.arialyy.aria.core.AriaManager; +import com.arialyy.aria.core.ProxyHelper; import com.arialyy.aria.core.command.normal.NormalCmdFactory; import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.inf.AbsReceiver; diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTarget.java b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTarget.java index dd372289..690ebc4c 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTarget.java @@ -82,14 +82,6 @@ public class UploadTarget extends AbsNormalTarget keys = pro.keySet(); + Set newKeys = new LinkedHashSet<>(); + Set values = new LinkedHashSet<>(); + for (Object key : keys) { + String oldKey = String.valueOf(key); + if (oldKey.contains(oldName)) { + values.add(pro.getProperty(oldKey)); + newKeys.add(oldKey.replace(oldName, newName)); + } + } + + pro.clear(); + Iterator next = values.iterator(); + for (String key : newKeys) { + pro.setProperty(key, next.next()); + } + + CommonUtil.saveConfig(oldFile, pro); + } + + oldFile.renameTo(newFile); + } + } + /** * 读取下载配置文件 */ diff --git a/README.md b/README.md index db8e1574..df40b552 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,8 @@ Aria怎样使用? [![Download](https://api.bintray.com/packages/arialyy/maven/AriaApi/images/download.svg)](https://bintray.com/arialyy/maven/AriaApi/_latestVersion) [![Download](https://api.bintray.com/packages/arialyy/maven/AriaCompiler/images/download.svg)](https://bintray.com/arialyy/maven/AriaCompiler/_latestVersion) ```java -compile 'com.arialyy.aria:aria-core:3.2.6' -annotationProcessor 'com.arialyy.aria:aria-compiler:3.2.6' +compile 'com.arialyy.aria:aria-core:3.2.7' +annotationProcessor 'com.arialyy.aria:aria-compiler:3.2.7' ``` ## 示例 @@ -345,11 +345,13 @@ Aria.download(this).load(DOWNLOAD_URL).setExtendField(str) *** ## 后续版本开发规划 +* ~~ftp断点下载~~ * ~~http、scoket断点上传~~ * ~~实现上传队列调度功能~~ ## 开发日志 + + v_3.2.7 移除设置文件名的api接口,修复断开网络时出现的进度条错误的问题 + v_3.2.6 移除广播事件,增加任务组下载功能 + v_3.1.9 修复stopAll队列没有任务时崩溃的问题,增加针对单个任务监听的功能 + v_3.1.7 修复某些文件下载不了的bug,增加apt注解方法,事件获取更加简单了 diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml index 474752d0..43a593a2 100644 --- a/app/src/main/assets/aria_config.xml +++ b/app/src/main/assets/aria_config.xml @@ -8,7 +8,7 @@ - + @@ -17,10 +17,10 @@ - + - + diff --git a/app/src/main/java/com/arialyy/simple/download/SimpleNotification.java b/app/src/main/java/com/arialyy/simple/download/SimpleNotification.java index 39cc5d8e..15c0fa88 100644 --- a/app/src/main/java/com/arialyy/simple/download/SimpleNotification.java +++ b/app/src/main/java/com/arialyy/simple/download/SimpleNotification.java @@ -56,7 +56,6 @@ public class SimpleNotification { public void start() { Aria.download(mContext) .load(DOWNLOAD_URL) - .setDownloadName("notification_test.apk") .setDownloadPath( Environment.getExternalStorageDirectory() + "/Download/消灭星星.apk") .start(); diff --git a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index 5e4612fa..aaab2bb9 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -186,19 +186,25 @@ public class SingleTaskActivity extends BaseActivity { public void onClick(View view) { switch (view.getId()) { case R.id.start: - String text = ((TextView) view).getText().toString(); - if (text.equals("重新开始?") || text.equals("开始")) { - Aria.download(this) - .load(DOWNLOAD_URL) - .addHeader("groupName", "value") - .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") - .start(); - } else if (text.equals("恢复")) { - Aria.download(this).load(DOWNLOAD_URL).resume(); - } + //String text = ((TextView) view).getText().toString(); + //if (text.equals("重新开始?") || text.equals("开始")) { + // Aria.download(this) + // .load(DOWNLOAD_URL) + // .addHeader("groupName", "value") + // .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") + // .setFileName("hehe.apk") + // .start(); + //} else if (text.equals("恢复")) { + // Aria.download(this).load(DOWNLOAD_URL).resume(); + //} + Aria.download(this) + .load(DOWNLOAD_URL) + .addHeader("groupName", "value") + .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/gggg.apk") + .start(); break; case R.id.stop: - Aria.download(this).load(DOWNLOAD_URL).pause(); + Aria.download(this).load(DOWNLOAD_URL).stop(); break; case R.id.cancel: Aria.download(this).load(DOWNLOAD_URL).cancel(); diff --git a/app/src/main/java/com/arialyy/simple/download/group/GroupModule.java b/app/src/main/java/com/arialyy/simple/download/group/GroupModule.java index 221212e4..d9821643 100644 --- a/app/src/main/java/com/arialyy/simple/download/group/GroupModule.java +++ b/app/src/main/java/com/arialyy/simple/download/group/GroupModule.java @@ -43,12 +43,4 @@ public class GroupModule extends BaseModule { Collections.addAll(names, str); return names; } - - //NormalList convertPath(NormalList urls){ - // NormalList paths = new ArrayList<>(); - // - // for (String url : urls){ - // - // } - //} } diff --git a/app/src/main/java/com/arialyy/simple/download/multi_download/FileListAdapter.java b/app/src/main/java/com/arialyy/simple/download/multi_download/FileListAdapter.java index 750e2b2a..e423f79a 100644 --- a/app/src/main/java/com/arialyy/simple/download/multi_download/FileListAdapter.java +++ b/app/src/main/java/com/arialyy/simple/download/multi_download/FileListAdapter.java @@ -68,7 +68,6 @@ final class FileListAdapter extends AbsRVAdapter