From 99f875c4c3a0061f0be273afb04f1ddb43cd5a12 Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Mon, 2 Jul 2018 20:52:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=82=E6=AD=A5=E6=98=AFti?= =?UTF-8?q?mer=E4=B8=BAnull=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/arialyy/aria/core/AriaManager.java | 12 ---- .../aria/core/command/normal/StartCmd.java | 8 ++- .../arialyy/aria/core/common/AbsFileer.java | 57 +++++++++++++------ .../download/downloader/AbsGroupUtil.java | 12 ++-- app/src/main/AndroidManifest.xml | 6 +- app/src/main/assets/aria_config.xml | 2 +- .../simple/download/SingleTaskActivity.java | 8 +-- .../download/group/DownloadGroupActivity.java | 4 +- .../multi_download/MultiDownloadActivity.java | 2 +- .../multi_download/MultiTaskActivity.java | 6 ++ 10 files changed, 68 insertions(+), 49 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java index 940b05cf..ba810bb9 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java +++ b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java @@ -26,7 +26,6 @@ import android.os.Bundle; import android.support.v4.app.DialogFragment; import android.support.v4.app.Fragment; import android.widget.PopupWindow; -import android.widget.Toast; import com.arialyy.aria.core.command.ICmd; import com.arialyy.aria.core.common.QueueMod; import com.arialyy.aria.core.download.DownloadEntity; @@ -71,7 +70,6 @@ import org.xml.sax.SAXException; * activity 和其Dialog、Fragment的映射表 */ private Map> mSubClass = new ConcurrentHashMap<>(); - private List mActivityCount = new ArrayList<>(); public static Context APP; private List mCommands = new ArrayList<>(); private Configuration.DownloadConfig mDConfig; @@ -470,9 +468,6 @@ import org.xml.sax.SAXException; private class LifeCallback implements Application.ActivityLifecycleCallbacks { @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) { - mActivityCount.add( - String.format("%s_%s", activity.getClass().getName(), activity.hashCode())); - ALog.w(TAG, "size = " + mActivityCount.size()); } @Override public void onActivityStarted(Activity activity) { @@ -497,13 +492,6 @@ import org.xml.sax.SAXException; @Override public void onActivityDestroyed(Activity activity) { removeReceiver(activity); - mActivityCount.remove( - String.format("%s_%s", activity.getClass().getName(), activity.hashCode())); - ALog.w(TAG, "size = " + mActivityCount.size()); - if (mActivityCount.size() == 0) { - ALog.e(TAG, "gggg"); - //Toast.makeText(activity, "destroy", Toast.LENGTH_SHORT).show(); - } } } } 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 eaaf57d0..ece35307 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 @@ -17,6 +17,7 @@ package com.arialyy.aria.core.command.normal; import android.text.TextUtils; +import android.util.Log; import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.common.QueueMod; import com.arialyy.aria.core.download.DownloadGroupTaskEntity; @@ -82,14 +83,14 @@ class StartCmd extends AbsNormalCmd { || task.getState() == IEntity.STATE_COMPLETE) { resumeTask(); } else { - sendWaitState(); + sendWaitState(task); } } } else { //任务没执行并且执行队列中没有该任务,才认为任务没有运行中 if (!task.isRunning() && !mQueue.taskIsRunning(task.getKey())) { resumeTask(); - }else { + } else { ALog.w(TAG, String.format("任务【%s】已经在运行", task.getTaskName())); } } @@ -152,7 +153,8 @@ class StartCmd extends AbsNormalCmd { AbsTask task = getTask(te.getEntity()); if (task != null) continue; if (te instanceof DownloadTaskEntity) { - if (te.getRequestType() == AbsTaskEntity.D_FTP || te.getRequestType() == AbsTaskEntity.U_FTP) { + if (te.getRequestType() == AbsTaskEntity.D_FTP + || te.getRequestType() == AbsTaskEntity.U_FTP) { te.setUrlEntity(CommonUtil.getFtpUrlInfo(te.getEntity().getKey())); } mQueue = DownloadTaskQueue.getInstance(); diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java index 5680a83d..47ed0589 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java @@ -117,7 +117,7 @@ public abstract class AbsFileer - - + + diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml index 55c155be..b9aa70df 100644 --- a/app/src/main/assets/aria_config.xml +++ b/app/src/main/assets/aria_config.xml @@ -34,7 +34,7 @@ - + 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 8d5e1477..7093e227 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -46,13 +46,13 @@ public class SingleTaskActivity extends BaseActivity { private static final String DOWNLOAD_URL = //"http://kotlinlang.org/docs/kotlin-docs.pdf"; //"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://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载 //"https://static.donguo.me//video/ip/course/pfys_1.mp4"; //"https://www.baidu.com/link?url=_LFCuTPtnzFxVJByJ504QymRywIA1Z_T5xUxe9ZLuxcGM0C_RcdpWyB1eGjbJC-e5wv5wAKM4WmLMAS5KeF6EZJHB8Va3YqZUiaErqK_pxm&wd=&eqid=e8583fe70002d126000000065a99f864"; //"https://d.pcs.baidu.com/file/a02c89a2d479d4fd2756f3313d42491d?fid=4232431903-250528-1114369760340736&dstime=1525491372&rt=sh&sign=FDtAERVY-DCb740ccc5511e5e8fedcff06b081203-3C13vkOkuk4TqXvVYW05zj1K0ao%3D&expires=8h&chkv=1&chkbd=0&chkpc=et&dp-logid=8651730921842106225&dp-callid=0&r=165533013"; //"http://apk500.bce.baidu-mgame.com/game/67000/67734/20170622040827_oem_5502845.apk?r=1"; - "https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe"; + //"https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe"; @Bind(R.id.start) Button mStart; @Bind(R.id.stop) Button mStop; @Bind(R.id.cancel) Button mCancel; @@ -220,8 +220,8 @@ public class SingleTaskActivity extends BaseActivity { startD(); break; case R.id.stop: - //Aria.download(this).load(DOWNLOAD_URL).stop(); - startActivity(new Intent(this, SingleTaskActivity.class)); + Aria.download(this).load(DOWNLOAD_URL).stop(); + //startActivity(new Intent(this, SingleTaskActivity.class)); //Aria.download(this).load(DOWNLOAD_URL).removeRecord(); break; case R.id.cancel: diff --git a/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java b/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java index 16fc2b0f..1544e4a5 100644 --- a/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java @@ -92,8 +92,8 @@ public class DownloadGroupActivity extends BaseActivity { mAdapter.updateBtState(task.getKey(), false); } + @DownloadGroup.onWait void groupTaskWait(DownloadGroupTask task) { + ALog.d(TAG, String.format("group【%s】wait---", task.getTaskName())); + mAdapter.updateBtState(task.getKey(), true); + } + @DownloadGroup.onTaskStop void groupTaskStop(DownloadGroupTask task) { mAdapter.updateBtState(task.getKey(), true); Log.d(TAG, String.format("group【%s】stop", task.getTaskName()));