From d9ed7f87d2f2f1194e84ea29df5a35147a4af5de Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Sun, 8 Dec 2019 11:08:58 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4androidx=E3=80=81support?= =?UTF-8?q?=E4=BE=9D=E8=B5=96=EF=BC=8C=E7=8E=B0=E5=9C=A8=E5=93=AA=E4=B8=AA?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E7=9A=84appcompat=E5=BA=93=E9=83=BD=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E5=AF=BC=E5=85=A5Aria=20=E4=BF=AE=E5=A4=8D=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=9C=A8xml=E4=B8=AD=E4=BD=BF=E7=94=A8fragment?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aria/build.gradle | 2 +- .../com/arialyy/aria/core/AriaManager.java | 57 ++++++++----------- .../arialyy/aria/core/common/FtpOption.java | 2 +- .../arialyy/aria/core/common/HttpOption.java | 10 +--- .../aria/core/download/DownloadReceiver.java | 21 +++---- .../target/AbsGroupConfigHandler.java | 4 -- .../download/target/FtpBuilderTarget.java | 10 +--- .../download/target/FtpDirBuilderTarget.java | 6 -- .../download/target/FtpDirNormalTarget.java | 5 -- .../core/download/target/FtpNormalTarget.java | 8 +-- .../download/target/GroupBuilderTarget.java | 10 ---- .../download/target/GroupNormalTarget.java | 8 --- .../download/target/HttpBuilderTarget.java | 12 +--- .../target/HttpGroupConfigHandler.java | 3 - .../download/target/HttpNormalTarget.java | 8 --- .../download/target/TcpBuilderTarget.java | 8 +-- .../com/arialyy/aria/core/inf/AbsTarget.java | 5 +- .../com/arialyy/aria/core/inf/IReceiver.java | 2 +- .../arialyy/aria/core/inf/ReceiverType.java | 11 +--- .../aria/core/manager/TaskWrapperManager.java | 4 +- .../aria/core/upload/UploadReceiver.java | 14 ++--- .../core/upload/target/FtpBuilderTarget.java | 5 -- .../core/upload/target/FtpNormalTarget.java | 3 - .../core/upload/target/HttpBuilderTarget.java | 4 -- .../core/upload/target/HttpNormalTarget.java | 4 -- DEV_LOG.md | 3 + FtpComponent/build.gradle | 2 - .../aria/ftp/upload/FtpFISAdapter.java | 9 ++- HttpComponent/build.gradle | 4 -- M3U8Component/build.gradle | 1 - PublicComponent/build.gradle | 1 - .../com/arialyy/aria/core/FtpUrlEntity.java | 1 - .../com/arialyy/aria/core/ProtocolType.java | 15 +---- .../arialyy/aria/core/config/ConfigType.java | 12 +--- .../arialyy/aria/core/config/XMLReader.java | 2 +- .../aria/core/inf/TaskSchedulerType.java | 13 +---- .../aria/core/processor/ITsMergeHandler.java | 3 +- .../com/arialyy/aria/core/task/AbsTask.java | 7 +-- .../com/arialyy/aria/core/task/ITask.java | 6 +- .../aria/core/task/IThreadTaskObserver.java | 5 +- .../arialyy/aria/core/task/ThreadTask.java | 7 +-- .../com/arialyy/aria/util/SSLContextUtil.java | 12 ++-- .../com/arialyy/aria/util/WeakHandler.java | 35 ++++++------ SFtpComponent/build.gradle | 1 - .../simple/core/upload/UploadModule.java | 2 +- 45 files changed, 98 insertions(+), 269 deletions(-) diff --git a/Aria/build.gradle b/Aria/build.gradle index 14de1143..ea5fe579 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -23,7 +23,7 @@ android { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') testImplementation 'junit:junit:4.12' - implementation "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}" +// implementation "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}" api project(':AriaAnnotations') api project(path: ':PublicComponent') api project(path: ':HttpComponent') 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 b21910c6..a562e53b 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java +++ b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java @@ -290,19 +290,31 @@ import java.util.concurrent.ConcurrentHashMap; } } - private IReceiver putReceiver(@ReceiverType String type, Object obj) { + private IReceiver putReceiver(String type, Object obj) { final String key = getKey(type, obj); IReceiver receiver = mReceivers.get(key); boolean needRmReceiver = false; // 监控Dialog、fragment、popupWindow的生命周期 final WidgetLiftManager widgetLiftManager = new WidgetLiftManager(); + Context subParenActivity = null; + if (obj instanceof Dialog) { needRmReceiver = widgetLiftManager.handleDialogLift((Dialog) obj); + subParenActivity = ((Dialog) obj).getOwnerActivity(); } else if (obj instanceof PopupWindow) { needRmReceiver = widgetLiftManager.handlePopupWindowLift((PopupWindow) obj); + subParenActivity = ((PopupWindow) obj).getContentView().getContext(); } else if (isDialogFragment(obj.getClass())) { needRmReceiver = widgetLiftManager.handleDialogFragmentLift(getDialog(obj)); + subParenActivity = getFragmentActivity(obj); + } else if (isFragment(obj.getClass())) { + subParenActivity = getFragmentActivity(obj); + } + + if (subParenActivity instanceof Activity) { + relateSubClass(type, obj, (Activity) subParenActivity); } + if (receiver == null) { AbsReceiver absReceiver = type.equals(ReceiverType.DOWNLOAD) ? new DownloadReceiver() : new UploadReceiver(); @@ -315,30 +327,6 @@ import java.util.concurrent.ConcurrentHashMap; return receiver; } - /** - * 根据功能类型和控件类型获取对应的key - * - * @param type {@link ReceiverType} - * @param obj 观察者对象 - * @return {@link #createKey(String, Object)} - */ - private String getKey(@ReceiverType String type, Object obj) { - if (isFragment(obj.getClass())) { - relateSubClass(type, obj, getFragmentActivity(obj)); - } else if (obj instanceof Dialog) { - Activity activity = ((Dialog) obj).getOwnerActivity(); - if (activity != null) { - relateSubClass(type, obj, activity); - } - } else if (obj instanceof PopupWindow) { - Context context = ((PopupWindow) obj).getContentView().getContext(); - if (context instanceof Activity) { - relateSubClass(type, obj, (Activity) context); - } - } - return createKey(type, obj); - } - /** * 获取fragment的activity * @@ -421,14 +409,17 @@ import java.util.concurrent.ConcurrentHashMap; * @param sub Fragment或dialog类 * @param activity activity寄主类 */ - private void relateSubClass(@ReceiverType String type, Object sub, Activity activity) { - String key = createKey(type, activity); - List list = mSubClass.get(key); - if (list == null) { - list = new ArrayList<>(); - mSubClass.put(key, list); + private void relateSubClass(String type, Object sub, Activity activity) { + String key = getKey(type, activity); + List subClass = mSubClass.get(key); + if (subClass == null) { + subClass = new ArrayList<>(); + mSubClass.put(key, subClass); + } + subClass.add(getKey(type, sub)); + if (mReceivers.get(key) == null) { // 将activity填充进去 + mReceivers.put(key, new DownloadReceiver()); } - list.add(createKey(type, sub)); } /** @@ -439,7 +430,7 @@ import java.util.concurrent.ConcurrentHashMap; * @return key的格式为:{@code String.format("%s_%s_%s", obj.getClass().getName(), type, * obj.hashCode());} */ - private String createKey(@ReceiverType String type, Object obj) { + private String getKey(String type, Object obj) { return String.format("%s_%s_%s", obj.getClass().getName(), type, obj.hashCode()); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/FtpOption.java b/Aria/src/main/java/com/arialyy/aria/core/common/FtpOption.java index 6c737d39..168f195e 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/FtpOption.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/FtpOption.java @@ -70,7 +70,7 @@ public class FtpOption extends BaseOption { * * @param protocol {@link ProtocolType} */ - public FtpOption setProtocol(@ProtocolType String protocol) { + public FtpOption setProtocol(String protocol) { if (TextUtils.isEmpty(protocol)) { ALog.e(TAG, "设置协议失败,协议信息为空"); return this; diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/HttpOption.java b/Aria/src/main/java/com/arialyy/aria/core/common/HttpOption.java index e52c3866..16f7d4e2 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/HttpOption.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/HttpOption.java @@ -16,11 +16,6 @@ package com.arialyy.aria.core.common; import android.text.TextUtils; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; -import com.arialyy.aria.core.download.target.HttpBuilderTarget; -import com.arialyy.aria.core.inf.IOptionConstant; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.processor.IHttpFileLenAdapter; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CheckUtil; @@ -50,7 +45,6 @@ public class HttpOption extends BaseOption { * * @param requestEnum {@link RequestEnum} */ - @CheckResult(suggest = Suggest.TO_CONTROLLER) public HttpOption setRequestType(RequestEnum requestEnum) { this.requestEnum = requestEnum; return this; @@ -97,7 +91,7 @@ public class HttpOption extends BaseOption { * @param key header对应的key * @param value header对应的value */ - public HttpOption addHeader(@NonNull String key, @NonNull String value) { + public HttpOption addHeader(String key, String value) { if (TextUtils.isEmpty(key)) { ALog.w(TAG, "设置header失败,header对应的key不能为null"); return this; @@ -118,7 +112,7 @@ public class HttpOption extends BaseOption { * * @param headers 一组http header数据 */ - public HttpOption addHeaders(@NonNull Map headers) { + public HttpOption addHeaders(Map headers) { if (headers.size() == 0) { ALog.w(TAG, "设置header失败,map没有header数据"); return this; 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 446a92e3..09c58c08 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 @@ -15,8 +15,6 @@ */ package com.arialyy.aria.core.download; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; import com.arialyy.annotations.TaskEnum; import com.arialyy.aria.core.AriaConfig; import com.arialyy.aria.core.AriaManager; @@ -74,8 +72,7 @@ public class DownloadReceiver extends AbsReceiver { * * @param url 下载地址 */ - @CheckResult - public HttpBuilderTarget load(@NonNull String url) { + public HttpBuilderTarget load(String url) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_HTTP); return DTargetFactory.getInstance() .generateBuilderTarget(HttpBuilderTarget.class, url); @@ -87,7 +84,6 @@ public class DownloadReceiver extends AbsReceiver { * @param taskId 任务id,可从{@link AbsBuilderTarget#create()}、{@link AbsBuilderTarget#add()}、{@link * AbsEntity#getId()}读取任务id */ - @CheckResult public HttpNormalTarget load(long taskId) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_HTTP); return DTargetFactory.getInstance() @@ -99,7 +95,6 @@ public class DownloadReceiver extends AbsReceiver { * * @param urls 组合任务只任务列被,如果任务组的中的下载地址改变了,则任务从新的一个任务组 */ - @CheckResult public GroupBuilderTarget loadGroup(List urls) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_HTTP); return DTargetFactory.getInstance().generateGroupBuilderTarget(urls); @@ -111,7 +106,7 @@ public class DownloadReceiver extends AbsReceiver { * @param taskId 任务id,可从{@link AbsBuilderTarget#create()}、{@link AbsBuilderTarget#add()}、{@link * * AbsEntity#getId()}读取任务id */ - @CheckResult + public GroupNormalTarget loadGroup(long taskId) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_HTTP); return DTargetFactory.getInstance() @@ -121,8 +116,8 @@ public class DownloadReceiver extends AbsReceiver { /** * 加载ftp单任务下载地址,用于任务第一次下载,如果需要控制任务停止或删除等操作,请使用{@link #loadFtp(long)} */ - @CheckResult - public FtpBuilderTarget loadFtp(@NonNull String url) { + + public FtpBuilderTarget loadFtp(String url) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_FTP); return DTargetFactory.getInstance() .generateBuilderTarget(FtpBuilderTarget.class, url); @@ -134,7 +129,7 @@ public class DownloadReceiver extends AbsReceiver { * @param taskId 任务id,可从{@link AbsBuilderTarget#create()}、{@link AbsBuilderTarget#add()}、{@link * AbsEntity#getId()}读取任务id */ - @CheckResult + public FtpNormalTarget loadFtp(long taskId) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_FTP); return DTargetFactory.getInstance() @@ -144,8 +139,8 @@ public class DownloadReceiver extends AbsReceiver { /** * 加载ftp文件夹下载地址,用于任务第一次下载,如果需要控制任务停止或删除等操作,请使用{@link #loadFtpDir(long)} */ - @CheckResult - public FtpDirBuilderTarget loadFtpDir(@NonNull String dirUrl) { + + public FtpDirBuilderTarget loadFtpDir(String dirUrl) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_FTP); return DTargetFactory.getInstance().generateDirBuilderTarget(dirUrl); } @@ -156,7 +151,7 @@ public class DownloadReceiver extends AbsReceiver { * @param taskId 任务id,可从{@link AbsBuilderTarget#create()}、{@link AbsBuilderTarget#add()}、{@link * AbsEntity#getId()}读取任务id */ - @CheckResult + public FtpDirNormalTarget loadFtpDir(long taskId) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_FTP); return DTargetFactory.getInstance() diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/target/AbsGroupConfigHandler.java b/Aria/src/main/java/com/arialyy/aria/core/download/target/AbsGroupConfigHandler.java index 617848f6..3eec7170 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/target/AbsGroupConfigHandler.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/target/AbsGroupConfigHandler.java @@ -16,9 +16,7 @@ package com.arialyy.aria.core.download.target; import android.text.TextUtils; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.common.AbsNormalTarget; -import com.arialyy.aria.core.common.ErrorCode; import com.arialyy.aria.core.download.DGTaskWrapper; import com.arialyy.aria.core.download.DownloadGroupEntity; import com.arialyy.aria.core.event.ErrorEvent; @@ -66,7 +64,6 @@ abstract class AbsGroupConfigHandler implements IConfi * * @return 子任务管理器 */ - @CheckResult SubTaskManager getSubTaskManager() { if (mSubTaskManager == null) { mSubTaskManager = new SubTaskManager(getTaskWrapper()); @@ -89,7 +86,6 @@ abstract class AbsGroupConfigHandler implements IConfi return task != null && task.isRunning(); } - @CheckResult TARGET setDirPath(String dirPath) { mWrapper.setDirPathTemp(dirPath); return mTarget; diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpBuilderTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpBuilderTarget.java index 047df49b..a67a8bb7 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpBuilderTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpBuilderTarget.java @@ -15,12 +15,9 @@ */ package com.arialyy.aria.core.download.target; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; import com.arialyy.aria.core.common.AbsBuilderTarget; import com.arialyy.aria.core.common.FtpOption; import com.arialyy.aria.core.download.DownloadEntity; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.wrapper.ITaskWrapper; import com.arialyy.aria.util.CommonUtil; @@ -40,7 +37,6 @@ public class FtpBuilderTarget extends AbsBuilderTarget { /** * 设置登陆、字符串编码、ftps等参数 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public FtpBuilderTarget option(FtpOption option) { if (option == null) { throw new NullPointerException("ftp 任务配置为空"); @@ -56,8 +52,7 @@ public class FtpBuilderTarget extends AbsBuilderTarget { * 1、如果保存路径是该文件的保存路径,如:/mnt/sdcard/file.zip,则使用路径中的文件名file.zip * 2、如果保存路径是文件夹路径,如:/mnt/sdcard/,则使用FTP服务器该文件的文件名 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) - public FtpBuilderTarget setFilePath(@NonNull String filePath) { + public FtpBuilderTarget setFilePath(String filePath) { int lastIndex = mConfigHandler.getUrl().lastIndexOf("/"); getEntity().setFileName(mConfigHandler.getUrl().substring(lastIndex + 1)); mConfigHandler.setTempFilePath(filePath); @@ -74,8 +69,7 @@ public class FtpBuilderTarget extends AbsBuilderTarget { * @deprecated 使用 {@link #ignoreFilePathOccupy()} */ @Deprecated - @CheckResult(suggest = Suggest.TASK_CONTROLLER) - public FtpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) { + public FtpBuilderTarget setFilePath(String filePath, boolean forceDownload) { mConfigHandler.setTempFilePath(filePath); mConfigHandler.setForceDownload(forceDownload); return this; diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpDirBuilderTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpDirBuilderTarget.java index 488f81a1..efd29d3a 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpDirBuilderTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpDirBuilderTarget.java @@ -15,11 +15,9 @@ */ package com.arialyy.aria.core.download.target; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.common.AbsBuilderTarget; import com.arialyy.aria.core.common.FtpOption; import com.arialyy.aria.core.download.DownloadGroupEntity; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.manager.SubTaskManager; import com.arialyy.aria.util.CommonUtil; @@ -57,7 +55,6 @@ public class FtpDirBuilderTarget extends AbsBuilderTarget { * * @param dirPath 任务组保存文件夹路径 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public FtpDirBuilderTarget setDirPath(String dirPath) { return mConfigHandler.setDirPath(dirPath); } @@ -65,7 +62,6 @@ public class FtpDirBuilderTarget extends AbsBuilderTarget { /** * 设置任务组别名 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public FtpDirBuilderTarget setGroupAlias(String alias) { mConfigHandler.setGroupAlias(alias); return this; @@ -74,7 +70,6 @@ public class FtpDirBuilderTarget extends AbsBuilderTarget { /** * 设置登陆、字符串编码、ftps等参数 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public FtpDirBuilderTarget option(FtpOption option) { if (option == null) { throw new NullPointerException("ftp 任务配置为空"); @@ -93,7 +88,6 @@ public class FtpDirBuilderTarget extends AbsBuilderTarget { * * @return 子任务管理器 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public SubTaskManager getSubTaskManager() { return mConfigHandler.getSubTaskManager(); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpDirNormalTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpDirNormalTarget.java index 8ce740fe..f221a394 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpDirNormalTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpDirNormalTarget.java @@ -15,11 +15,9 @@ */ package com.arialyy.aria.core.download.target; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.common.AbsNormalTarget; import com.arialyy.aria.core.common.FtpOption; import com.arialyy.aria.core.download.DownloadGroupEntity; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.manager.SubTaskManager; import com.arialyy.aria.util.CommonUtil; @@ -62,7 +60,6 @@ public class FtpDirNormalTarget extends AbsNormalTarget { * * @param dirPath 任务组保存文件夹路径 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public FtpDirNormalTarget modifyDirPath(String dirPath) { return mConfigHandler.setDirPath(dirPath); } @@ -70,7 +67,6 @@ public class FtpDirNormalTarget extends AbsNormalTarget { /** * 设置登陆、字符串编码、ftps等参数 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public FtpDirNormalTarget option(FtpOption option) { if (option == null) { throw new NullPointerException("ftp 任务配置为空"); @@ -89,7 +85,6 @@ public class FtpDirNormalTarget extends AbsNormalTarget { * * @return 子任务管理器 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public SubTaskManager getSubTaskManager() { return mConfigHandler.getSubTaskManager(); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpNormalTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpNormalTarget.java index c10f646b..21b4f2e3 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpNormalTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/target/FtpNormalTarget.java @@ -15,12 +15,9 @@ */ package com.arialyy.aria.core.download.target; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; import com.arialyy.aria.core.common.AbsNormalTarget; import com.arialyy.aria.core.common.FtpOption; import com.arialyy.aria.core.download.DownloadEntity; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.wrapper.ITaskWrapper; import com.arialyy.aria.util.CommonUtil; @@ -40,7 +37,6 @@ public class FtpNormalTarget extends AbsNormalTarget { /** * 设置登陆、字符串编码、ftps等参数 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public FtpNormalTarget option(FtpOption option) { if (option == null) { throw new NullPointerException("ftp 任务配置为空"); @@ -56,8 +52,7 @@ public class FtpNormalTarget extends AbsNormalTarget { * 1、如果保存路径是该文件的保存路径,如:/mnt/sdcard/file.zip,则使用路径中的文件名file.zip * 2、如果保存路径是文件夹路径,如:/mnt/sdcard/,则使用FTP服务器该文件的文件名 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) - public FtpNormalTarget modifyFilePath(@NonNull String filePath) { + public FtpNormalTarget modifyFilePath(String filePath) { int lastIndex = mConfigHandler.getUrl().lastIndexOf("/"); getEntity().setFileName(mConfigHandler.getUrl().substring(lastIndex + 1)); mConfigHandler.setTempFilePath(filePath); @@ -67,7 +62,6 @@ public class FtpNormalTarget extends AbsNormalTarget { /** * 更新下载地址 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public FtpNormalTarget updateUrl(String newUrl) { return mConfigHandler.updateUrl(newUrl); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/target/GroupBuilderTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/target/GroupBuilderTarget.java index cbd7edae..61968de4 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/target/GroupBuilderTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/target/GroupBuilderTarget.java @@ -15,11 +15,9 @@ */ package com.arialyy.aria.core.download.target; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.common.AbsBuilderTarget; import com.arialyy.aria.core.common.HttpOption; import com.arialyy.aria.core.download.DGTaskWrapper; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.manager.SubTaskManager; import com.arialyy.aria.core.wrapper.ITaskWrapper; import com.arialyy.aria.util.ALog; @@ -42,7 +40,6 @@ public class GroupBuilderTarget extends AbsBuilderTarget { /** * 设置http请求参数,header等信息 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public GroupBuilderTarget option(HttpOption option) { if (option == null) { throw new NullPointerException("任务配置为空"); @@ -59,7 +56,6 @@ public class GroupBuilderTarget extends AbsBuilderTarget { * * @param fileSize 任务组总大小 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public GroupBuilderTarget setFileSize(long fileSize) { if (fileSize <= 0) { ALog.e(TAG, "文件大小不能小于 0"); @@ -78,7 +74,6 @@ public class GroupBuilderTarget extends AbsBuilderTarget { * 2、如果你的知道组合任务的总长度,请使用{@link #setFileSize(long)}设置组合任务的长度。 * 3、由于网络或其它原因的存在,这种方式获取的组合任务大小有可能是不准确的。 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public GroupBuilderTarget unknownSize() { ((DGTaskWrapper) getTaskWrapper()).setUnknownSize(true); return this; @@ -89,7 +84,6 @@ public class GroupBuilderTarget extends AbsBuilderTarget { * * @return 子任务管理器 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public SubTaskManager getSubTaskManager() { return mConfigHandler.getSubTaskManager(); } @@ -99,7 +93,6 @@ public class GroupBuilderTarget extends AbsBuilderTarget { * * @deprecated {@link #setSubFileName(List)} 请使用该api */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) @Deprecated public GroupBuilderTarget setSubTaskFileName(List subTaskFileName) { return setSubFileName(subTaskFileName); } @@ -107,7 +100,6 @@ public class GroupBuilderTarget extends AbsBuilderTarget { /** * 设置任务组别名 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public GroupBuilderTarget setGroupAlias(String alias) { mConfigHandler.setGroupAlias(alias); return this; @@ -132,7 +124,6 @@ public class GroupBuilderTarget extends AbsBuilderTarget { * * @param dirPath 任务组保存文件夹路径 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public GroupBuilderTarget setDirPath(String dirPath) { return mConfigHandler.setDirPath(dirPath); } @@ -140,7 +131,6 @@ public class GroupBuilderTarget extends AbsBuilderTarget { /** * 设置子任务文件名,该方法必须在{@link #setDirPath(String)}之后调用,否则不生效 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public GroupBuilderTarget setSubFileName(List subTaskFileName) { return mConfigHandler.setSubFileName(subTaskFileName); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/target/GroupNormalTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/target/GroupNormalTarget.java index 00b4d8f6..4d710cc6 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/target/GroupNormalTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/target/GroupNormalTarget.java @@ -15,10 +15,8 @@ */ package com.arialyy.aria.core.download.target; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.common.AbsNormalTarget; import com.arialyy.aria.core.common.HttpOption; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.manager.SubTaskManager; import com.arialyy.aria.core.wrapper.ITaskWrapper; import java.util.List; @@ -39,7 +37,6 @@ public class GroupNormalTarget extends AbsNormalTarget { /** * 设置http请求参数,header等信息 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public GroupNormalTarget option(HttpOption option) { if (option == null) { throw new NullPointerException("任务配置为空"); @@ -53,7 +50,6 @@ public class GroupNormalTarget extends AbsNormalTarget { * * @return 子任务管理器 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public SubTaskManager getSubTaskManager() { return mConfigHandler.getSubTaskManager(); } @@ -61,7 +57,6 @@ public class GroupNormalTarget extends AbsNormalTarget { /** * 设置任务组别名 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public GroupNormalTarget setGroupAlias(String alias) { mConfigHandler.setGroupAlias(alias); return this; @@ -72,7 +67,6 @@ public class GroupNormalTarget extends AbsNormalTarget { * * @param urls 新的组合任务下载地址列表 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public GroupNormalTarget updateUrls(List urls) { return mConfigHandler.updateUrls(urls); } @@ -96,7 +90,6 @@ public class GroupNormalTarget extends AbsNormalTarget { * * @param dirPath 任务组保存文件夹路径 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public GroupNormalTarget modifyDirPath(String dirPath) { return mConfigHandler.setDirPath(dirPath); } @@ -104,7 +97,6 @@ public class GroupNormalTarget extends AbsNormalTarget { /** * 更新子任务文件名,该方法必须在{@link #modifyDirPath(String)}之后调用,否则不生效 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public GroupNormalTarget modifySubFileName(List subTaskFileName) { return mConfigHandler.setSubFileName(subTaskFileName); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpBuilderTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpBuilderTarget.java index ae3fd203..534d98b0 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpBuilderTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpBuilderTarget.java @@ -15,14 +15,11 @@ */ package com.arialyy.aria.core.download.target; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; import com.arialyy.aria.core.common.AbsBuilderTarget; import com.arialyy.aria.core.common.HttpOption; import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.m3u8.M3U8LiveOption; import com.arialyy.aria.core.download.m3u8.M3U8VodOption; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.wrapper.ITaskWrapper; @@ -37,7 +34,6 @@ public class HttpBuilderTarget extends AbsBuilderTarget { getTaskWrapper().setNewTask(true); } - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public HttpBuilderTarget m3u8VodOption(M3U8VodOption m3U8VodOption) { if (m3U8VodOption == null) { throw new NullPointerException("m3u8任务设置为空"); @@ -48,7 +44,6 @@ public class HttpBuilderTarget extends AbsBuilderTarget { return this; } - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public HttpBuilderTarget m3u8LiveOption(M3U8LiveOption m3U8LiveOption) { if (m3U8LiveOption == null) { throw new NullPointerException("m3u8任务设置为空"); @@ -61,7 +56,6 @@ public class HttpBuilderTarget extends AbsBuilderTarget { /** * 设置http请求参数,header等信息 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public HttpBuilderTarget option(HttpOption option) { if (option == null) { throw new NullPointerException("任务配置为空"); @@ -77,8 +71,7 @@ public class HttpBuilderTarget extends AbsBuilderTarget { * * @param filePath 路径必须为文件路径,不能为文件夹路径 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) - public HttpBuilderTarget setFilePath(@NonNull String filePath) { + public HttpBuilderTarget setFilePath(String filePath) { mConfigHandler.setTempFilePath(filePath); return this; } @@ -93,8 +86,7 @@ public class HttpBuilderTarget extends AbsBuilderTarget { * @deprecated 使用 {@link #ignoreFilePathOccupy()} */ @Deprecated - @CheckResult(suggest = Suggest.TASK_CONTROLLER) - public HttpBuilderTarget setFilePath(@NonNull String filePath, boolean forceDownload) { + public HttpBuilderTarget setFilePath(String filePath, boolean forceDownload) { mConfigHandler.setTempFilePath(filePath); mConfigHandler.setForceDownload(forceDownload); return this; diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpGroupConfigHandler.java b/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpGroupConfigHandler.java index 8b8f1d3d..235ff97a 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpGroupConfigHandler.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpGroupConfigHandler.java @@ -15,7 +15,6 @@ */ package com.arialyy.aria.core.download.target; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.inf.AbsTarget; @@ -69,7 +68,6 @@ class HttpGroupConfigHandler extends AbsGroupConfigHan /** * 设置子任务文件名,该方法必须在{@link #setDirPath(String)}之后调用,否则不生效 */ - @CheckResult TARGET setSubFileName(List subTaskFileName) { if (subTaskFileName == null || subTaskFileName.isEmpty()) { ALog.w(TAG, "修改子任务的文件名失败:列表为null"); @@ -90,7 +88,6 @@ class HttpGroupConfigHandler extends AbsGroupConfigHan * * @param urls 新的组合任务下载地址列表 */ - @CheckResult TARGET updateUrls(List urls) { if (urls == null || urls.isEmpty()) { throw new NullPointerException("下载地址列表为空"); diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpNormalTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpNormalTarget.java index ea7800d0..53eb4b2c 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpNormalTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/target/HttpNormalTarget.java @@ -15,14 +15,12 @@ */ package com.arialyy.aria.core.download.target; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.common.AbsNormalTarget; import com.arialyy.aria.core.common.HttpOption; import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.m3u8.M3U8LiveOption; import com.arialyy.aria.core.download.m3u8.M3U8VodOption; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; /** @@ -38,7 +36,6 @@ public class HttpNormalTarget extends AbsNormalTarget { getTaskWrapper().setNewTask(false); } - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public M3U8NormalTarget m3u8VodOption(M3U8VodOption m3U8VodOption) { if (m3U8VodOption == null) { throw new NullPointerException("m3u8任务设置为空"); @@ -49,12 +46,10 @@ public class HttpNormalTarget extends AbsNormalTarget { return new M3U8NormalTarget((DTaskWrapper) getTaskWrapper()); } - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public M3U8NormalTarget m3u8VodOption() { return new M3U8NormalTarget((DTaskWrapper) getTaskWrapper()); } - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public HttpNormalTarget m3u8LiveOption(M3U8LiveOption m3U8LiveOption) { if (m3U8LiveOption == null) { throw new NullPointerException("m3u8任务设置为空"); @@ -67,7 +62,6 @@ public class HttpNormalTarget extends AbsNormalTarget { /** * 设置http请求参数,header等信息 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public HttpNormalTarget option(HttpOption option) { if (option == null) { throw new NullPointerException("任务配置为空"); @@ -81,7 +75,6 @@ public class HttpNormalTarget extends AbsNormalTarget { * 如:原文件路径 /mnt/sdcard/test.zip * 如果需要将test.zip改为game.zip,只需要重新设置文件路径为:/mnt/sdcard/game.zip */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public HttpNormalTarget modifyFilePath(String filePath) { mConfigHandler.setTempFilePath(filePath); return this; @@ -97,7 +90,6 @@ public class HttpNormalTarget extends AbsNormalTarget { /** * 更新下载地址 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public HttpNormalTarget updateUrl(String newUrl) { return mConfigHandler.updateUrl(newUrl); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/target/TcpBuilderTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/target/TcpBuilderTarget.java index 314294d4..77b0a8ea 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/target/TcpBuilderTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/target/TcpBuilderTarget.java @@ -15,11 +15,7 @@ */ package com.arialyy.aria.core.download.target; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; import com.arialyy.aria.core.common.AbsBuilderTarget; -import com.arialyy.aria.core.inf.Suggest; -import com.arialyy.aria.core.download.tcp.TcpDelegate; import com.arialyy.aria.core.wrapper.ITaskWrapper; /** @@ -51,10 +47,8 @@ public class TcpBuilderTarget extends AbsBuilderTarget { * * @param filePath 路径必须为文件路径,不能为文件夹路径 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) - public TcpBuilderTarget setFilePath(@NonNull String filePath) { + public TcpBuilderTarget setFilePath(String filePath) { mConfigHandler.setTempFilePath(filePath); return this; } - } diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java index 3fc67aa2..3c9281cb 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java @@ -16,11 +16,10 @@ package com.arialyy.aria.core.inf; import android.text.TextUtils; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.common.AbsEntity; -import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.common.controller.BuilderController; import com.arialyy.aria.core.common.controller.NormalController; +import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; @@ -61,7 +60,6 @@ public abstract class AbsTarget { * * @param str 扩展数据 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public TARGET setExtendField(String str) { if (TextUtils.isEmpty(str)) return (TARGET) this; if (TextUtils.isEmpty(mEntity.getStr()) || !mEntity.getStr().equals(str)) { @@ -80,7 +78,6 @@ public abstract class AbsTarget { * BuilderController#add()} * 等操作任务的方法,那么你需要调用{@link NormalController#save()}才能将修改保存到数据库 */ - @CheckResult(suggest = "after use #create()、#stop()、#cancel()、#resume()、#save()?") public TARGET resetState() { getTaskWrapper().getEntity().setState(IEntity.STATE_WAIT); getTaskWrapper().setRefreshInfo(true); diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/IReceiver.java b/Aria/src/main/java/com/arialyy/aria/core/inf/IReceiver.java index a4fb92b1..d2ca7f81 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/inf/IReceiver.java +++ b/Aria/src/main/java/com/arialyy/aria/core/inf/IReceiver.java @@ -49,5 +49,5 @@ public interface IReceiver { * * @return {@link ReceiverType} */ - @ReceiverType String getType(); + String getType(); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/ReceiverType.java b/Aria/src/main/java/com/arialyy/aria/core/inf/ReceiverType.java index cf4aa2be..7bc13733 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/inf/ReceiverType.java +++ b/Aria/src/main/java/com/arialyy/aria/core/inf/ReceiverType.java @@ -15,19 +15,10 @@ */ package com.arialyy.aria.core.inf; -import androidx.annotation.StringDef; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - /** * {@link AbsReceiver}类型 */ -@StringDef({ - ReceiverType.DOWNLOAD, - ReceiverType.UPLOAD, -}) -@Retention(RetentionPolicy.SOURCE) -public @interface ReceiverType { +public interface ReceiverType { String DOWNLOAD = "download"; String UPLOAD = "upload"; } \ No newline at end of file diff --git a/Aria/src/main/java/com/arialyy/aria/core/manager/TaskWrapperManager.java b/Aria/src/main/java/com/arialyy/aria/core/manager/TaskWrapperManager.java index 35bd1ec0..7dc92ff0 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/manager/TaskWrapperManager.java +++ b/Aria/src/main/java/com/arialyy/aria/core/manager/TaskWrapperManager.java @@ -15,11 +15,11 @@ */ package com.arialyy.aria.core.manager; -import androidx.collection.LruCache; +import android.util.LruCache; import com.arialyy.aria.core.download.DGTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper; -import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.core.upload.UTaskWrapper; +import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; import java.util.concurrent.locks.Lock; 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 e3f7467f..c8c8ec2e 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 @@ -16,8 +16,6 @@ package com.arialyy.aria.core.upload; import android.text.TextUtils; -import androidx.annotation.CheckResult; -import androidx.annotation.NonNull; import com.arialyy.annotations.TaskEnum; import com.arialyy.aria.core.AriaConfig; import com.arialyy.aria.core.AriaManager; @@ -68,8 +66,8 @@ public class UploadReceiver extends AbsReceiver { * * @param filePath 文件路径 */ - @CheckResult - public HttpBuilderTarget load(@NonNull String filePath) { + + public HttpBuilderTarget load(String filePath) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_HTTP); CheckUtil.checkUploadPathIsEmpty(filePath); return UTargetFactory.getInstance() @@ -82,7 +80,7 @@ public class UploadReceiver extends AbsReceiver { * @param taskId 任务id,可从{@link AbsBuilderTarget#create()}、{@link AbsBuilderTarget#add()}、{@link * AbsEntity#getId()}读取任务id */ - @CheckResult + public HttpNormalTarget load(long taskId) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_HTTP); return UTargetFactory.getInstance() @@ -94,8 +92,8 @@ public class UploadReceiver extends AbsReceiver { * * @param filePath 文件路径 */ - @CheckResult - public FtpBuilderTarget loadFtp(@NonNull String filePath) { + + public FtpBuilderTarget loadFtp(String filePath) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_FTP); CheckUtil.checkUploadPathIsEmpty(filePath); return UTargetFactory.getInstance() @@ -108,7 +106,7 @@ public class UploadReceiver extends AbsReceiver { * @param taskId 任务id,可从{@link AbsBuilderTarget#create()}、{@link AbsBuilderTarget#add()}、{@link * AbsEntity#getId()}读取任务id */ - @CheckResult + public FtpNormalTarget loadFtp(long taskId) { ComponentUtil.getInstance().checkComponentExist(ComponentUtil.COMPONENT_TYPE_FTP); return UTargetFactory.getInstance() diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/target/FtpBuilderTarget.java b/Aria/src/main/java/com/arialyy/aria/core/upload/target/FtpBuilderTarget.java index 12546fd3..e3b5f6a0 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/target/FtpBuilderTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/target/FtpBuilderTarget.java @@ -15,11 +15,8 @@ */ package com.arialyy.aria.core.upload.target; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.common.AbsBuilderTarget; import com.arialyy.aria.core.common.FtpOption; -import com.arialyy.aria.core.inf.Suggest; -import com.arialyy.aria.core.upload.UTaskWrapper; import com.arialyy.aria.core.wrapper.ITaskWrapper; import com.arialyy.aria.util.CommonUtil; @@ -43,7 +40,6 @@ public class FtpBuilderTarget extends AbsBuilderTarget { * * @param tempUrl 上传路径 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public FtpBuilderTarget setUploadUrl(String tempUrl) { url = tempUrl; mConfigHandler.setTempUrl(tempUrl); @@ -64,7 +60,6 @@ public class FtpBuilderTarget extends AbsBuilderTarget { /** * 设置登陆、字符串编码、ftps等参数 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public FtpBuilderTarget option(FtpOption option) { if (option == null) { throw new NullPointerException("ftp 任务配置为空"); diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/target/FtpNormalTarget.java b/Aria/src/main/java/com/arialyy/aria/core/upload/target/FtpNormalTarget.java index d093d8ad..78111086 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/target/FtpNormalTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/target/FtpNormalTarget.java @@ -15,10 +15,8 @@ */ package com.arialyy.aria.core.upload.target; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.common.AbsNormalTarget; import com.arialyy.aria.core.common.FtpOption; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.wrapper.ITaskWrapper; import com.arialyy.aria.util.CommonUtil; @@ -39,7 +37,6 @@ public class FtpNormalTarget extends AbsNormalTarget { /** * 设置登陆、字符串编码、ftps等参数 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public FtpNormalTarget option(FtpOption option) { if (option == null) { throw new NullPointerException("ftp 任务配置为空"); diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/target/HttpBuilderTarget.java b/Aria/src/main/java/com/arialyy/aria/core/upload/target/HttpBuilderTarget.java index 3e7e1fb5..68145b56 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/target/HttpBuilderTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/target/HttpBuilderTarget.java @@ -15,10 +15,8 @@ */ package com.arialyy.aria.core.upload.target; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.common.AbsBuilderTarget; import com.arialyy.aria.core.common.HttpOption; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; /** @@ -42,7 +40,6 @@ public class HttpBuilderTarget extends AbsBuilderTarget { * * @param tempUrl 上传路径 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public HttpBuilderTarget setUploadUrl(String tempUrl) { mConfigHandler.setTempUrl(tempUrl); return this; @@ -51,7 +48,6 @@ public class HttpBuilderTarget extends AbsBuilderTarget { /** * 设置http请求参数,header等信息 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public HttpBuilderTarget option(HttpOption option) { if (option == null) { diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/target/HttpNormalTarget.java b/Aria/src/main/java/com/arialyy/aria/core/upload/target/HttpNormalTarget.java index 66136b04..af61eb87 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/target/HttpNormalTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/target/HttpNormalTarget.java @@ -15,10 +15,8 @@ */ package com.arialyy.aria.core.upload.target; -import androidx.annotation.CheckResult; import com.arialyy.aria.core.common.AbsNormalTarget; import com.arialyy.aria.core.common.HttpOption; -import com.arialyy.aria.core.inf.Suggest; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; import com.arialyy.aria.util.ALog; @@ -41,7 +39,6 @@ public class HttpNormalTarget extends AbsNormalTarget { * * @param tempUrl 上传路径 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public HttpNormalTarget setUploadUrl(String tempUrl) { mConfigHandler.setTempUrl(tempUrl); return this; @@ -50,7 +47,6 @@ public class HttpNormalTarget extends AbsNormalTarget { /** * 设置http请求参数,header等信息 */ - @CheckResult(suggest = Suggest.TASK_CONTROLLER) public HttpNormalTarget option(HttpOption option) { if (option == null) { throw new NullPointerException("任务配置为空"); diff --git a/DEV_LOG.md b/DEV_LOG.md index e000b3e9..fb81df0b 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,4 +1,7 @@ ## 开发日志 + + v_3.8 + - 移除androidx和support的依赖,现在无论是哪个版本的appcompat包都可以使用本框架 + - 修复一个在xml中使用fragment导致的内存泄漏问题 + v_3.7.10 (2019/12/3) - fix bug https://github.com/AriaLyy/Aria/issues/543#issuecomment-559733124 - fix bug https://github.com/AriaLyy/Aria/issues/542 diff --git a/FtpComponent/build.gradle b/FtpComponent/build.gradle index 10b1fbb7..a480ed42 100644 --- a/FtpComponent/build.gradle +++ b/FtpComponent/build.gradle @@ -25,8 +25,6 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}" - implementation project(path: ':PublicComponent') } diff --git a/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpFISAdapter.java b/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpFISAdapter.java index ae78eeea..0bab6cf7 100644 --- a/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpFISAdapter.java +++ b/FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpFISAdapter.java @@ -15,7 +15,6 @@ */ package com.arialyy.aria.ftp.upload; -import androidx.annotation.NonNull; import com.arialyy.aria.util.BufferedRandomAccessFile; import java.io.IOException; import java.io.InputStream; @@ -34,12 +33,12 @@ final class FtpFISAdapter extends InputStream { void onProgressCallback(byte[] buffer, int byteOffset, int byteCount) throws IOException; } - FtpFISAdapter(@NonNull BufferedRandomAccessFile is, @NonNull ProgressCallback callback) { + FtpFISAdapter(BufferedRandomAccessFile is, ProgressCallback callback) { mIs = is; mCallback = callback; } - FtpFISAdapter(@NonNull BufferedRandomAccessFile is) { + FtpFISAdapter(BufferedRandomAccessFile is) { mIs = is; } @@ -51,7 +50,7 @@ final class FtpFISAdapter extends InputStream { return mIs.read(); } - @Override public int read(@NonNull byte[] buffer) throws IOException { + @Override public int read(byte[] buffer) throws IOException { count = mIs.read(buffer); if (mCallback != null) { mCallback.onProgressCallback(buffer, 0, count); @@ -59,7 +58,7 @@ final class FtpFISAdapter extends InputStream { return count; } - @Override public int read(@NonNull byte[] buffer, int byteOffset, int byteCount) + @Override public int read(byte[] buffer, int byteOffset, int byteCount) throws IOException { count = mIs.read(buffer, byteOffset, byteCount); if (mCallback != null) { diff --git a/HttpComponent/build.gradle b/HttpComponent/build.gradle index 287ed5e8..f16fd533 100644 --- a/HttpComponent/build.gradle +++ b/HttpComponent/build.gradle @@ -10,7 +10,6 @@ android { versionCode rootProject.ext.versionCode versionName rootProject.ext.versionName - testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" consumerProguardFiles 'consumer-rules.pro' } @@ -25,9 +24,6 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}" - - testImplementation 'junit:junit:4.12' implementation project(path: ':PublicComponent') } diff --git a/M3U8Component/build.gradle b/M3U8Component/build.gradle index d44a132e..6c08e9ef 100644 --- a/M3U8Component/build.gradle +++ b/M3U8Component/build.gradle @@ -25,7 +25,6 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}" implementation project(path: ':HttpComponent') implementation project(path: ':PublicComponent') } diff --git a/PublicComponent/build.gradle b/PublicComponent/build.gradle index 50ccd8df..8df6b54e 100644 --- a/PublicComponent/build.gradle +++ b/PublicComponent/build.gradle @@ -24,7 +24,6 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}" testImplementation 'junit:junit:4.12' } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/FtpUrlEntity.java b/PublicComponent/src/main/java/com/arialyy/aria/core/FtpUrlEntity.java index 24b8ede4..7a238f39 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/FtpUrlEntity.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/FtpUrlEntity.java @@ -92,7 +92,6 @@ public class FtpUrlEntity implements Cloneable { * 连接协议 * {@link ProtocolType} */ - @ProtocolType public String protocol = ProtocolType.Default; /** diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/ProtocolType.java b/PublicComponent/src/main/java/com/arialyy/aria/core/ProtocolType.java index d1602bd0..17ef1d7a 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/ProtocolType.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/ProtocolType.java @@ -15,20 +15,7 @@ */ package com.arialyy.aria.core; -import androidx.annotation.StringDef; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@StringDef({ - ProtocolType.Default, - ProtocolType.SSL, - ProtocolType.SSLv3, - ProtocolType.TLS, - ProtocolType.TLSv1, - ProtocolType.TLSv1_1, - ProtocolType.TLSv1_2 -}) -@Retention(RetentionPolicy.SOURCE) public @interface ProtocolType { +public interface ProtocolType { String Default = "TLS"; String SSL = "SSL"; String SSLv3 = "SSLv3"; diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/config/ConfigType.java b/PublicComponent/src/main/java/com/arialyy/aria/core/config/ConfigType.java index 357c485d..7a8d8113 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/config/ConfigType.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/config/ConfigType.java @@ -15,17 +15,7 @@ */ package com.arialyy.aria.core.config; -import androidx.annotation.IntDef; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@IntDef({ - ConfigType.DOWNLOAD, - ConfigType.UPLOAD, - ConfigType.APP, - ConfigType.D_GROUP -}) -@Retention(RetentionPolicy.SOURCE) @interface ConfigType { +public interface ConfigType { int DOWNLOAD = 1; int UPLOAD = 2; int APP = 3; diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/config/XMLReader.java b/PublicComponent/src/main/java/com/arialyy/aria/core/config/XMLReader.java index d3472130..4b17fea4 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/config/XMLReader.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/config/XMLReader.java @@ -33,7 +33,7 @@ public class XMLReader extends DefaultHandler { private UploadConfig mUploadConfig = Configuration.getInstance().uploadCfg; private AppConfig mAppConfig = Configuration.getInstance().appCfg; private DGroupConfig mDGroupConfig = Configuration.getInstance().dGroupCfg; - private @ConfigType int mType; + private int mType; @Override public void startDocument() throws SAXException { super.startDocument(); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/inf/TaskSchedulerType.java b/PublicComponent/src/main/java/com/arialyy/aria/core/inf/TaskSchedulerType.java index 77e1dfbf..a521cbc2 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/inf/TaskSchedulerType.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/inf/TaskSchedulerType.java @@ -1,17 +1,6 @@ package com.arialyy.aria.core.inf; -import androidx.annotation.IntDef; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -@IntDef({ - TaskSchedulerType.TYPE_DEFAULT, - TaskSchedulerType.TYPE_STOP_NOT_NEXT, - TaskSchedulerType.TYPE_STOP_AND_WAIT, - TaskSchedulerType.TYPE_CANCEL_AND_NOT_NOTIFY, - TaskSchedulerType.TYPE_START_AND_RESET_STATE -}) -@Retention(RetentionPolicy.SOURCE) public @interface TaskSchedulerType { +public interface TaskSchedulerType { int TYPE_DEFAULT = 1; /** * 停止当前任务并且不自动启动下一任务 diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/processor/ITsMergeHandler.java b/PublicComponent/src/main/java/com/arialyy/aria/core/processor/ITsMergeHandler.java index 5f093806..7810aa41 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/processor/ITsMergeHandler.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/processor/ITsMergeHandler.java @@ -15,7 +15,6 @@ */ package com.arialyy.aria.core.processor; -import androidx.annotation.Nullable; import com.arialyy.aria.core.download.M3U8Entity; import com.arialyy.aria.core.inf.IEventHandler; import java.util.List; @@ -33,5 +32,5 @@ public interface ITsMergeHandler extends IEventHandler { * @param tsPath ts文件列表 * @return {@code true} 合并成功 */ - boolean merge(@Nullable M3U8Entity m3U8Entity, List tsPath); + boolean merge(M3U8Entity m3U8Entity, List tsPath); } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/task/AbsTask.java b/PublicComponent/src/main/java/com/arialyy/aria/core/task/AbsTask.java index 514129a6..503c0869 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/task/AbsTask.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/task/AbsTask.java @@ -52,7 +52,6 @@ public abstract class AbsTask /** * 该任务的调度类型 */ - @TaskSchedulerType private int mSchedulerType = TaskSchedulerType.TYPE_DEFAULT; protected IEventListener mListener; @@ -193,7 +192,7 @@ public abstract class AbsTask start(TaskSchedulerType.TYPE_DEFAULT); } - @Override public void start(@TaskSchedulerType int type) { + @Override public void start(int type) { mSchedulerType = type; if (type == TaskSchedulerType.TYPE_START_AND_RESET_STATE) { if (getUtil().isRunning()) { @@ -216,7 +215,7 @@ public abstract class AbsTask stop(TaskSchedulerType.TYPE_DEFAULT); } - @Override public void stop(@TaskSchedulerType int type) { + @Override public void stop(int type) { isStop = true; mSchedulerType = type; getUtil().stop(); @@ -226,7 +225,7 @@ public abstract class AbsTask cancel(TaskSchedulerType.TYPE_DEFAULT); } - @Override public void cancel(@TaskSchedulerType int type) { + @Override public void cancel(int type) { isCancel = true; mSchedulerType = type; getUtil().cancel(); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/task/ITask.java b/PublicComponent/src/main/java/com/arialyy/aria/core/task/ITask.java index e9f1e5a4..bb92458a 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/task/ITask.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/task/ITask.java @@ -91,7 +91,7 @@ public interface ITask { * * @param type {@link TaskSchedulerType} */ - void start(@TaskSchedulerType int type); + void start(int type); /** * 停止任务 @@ -103,7 +103,7 @@ public interface ITask { * * @param type {@link TaskSchedulerType} */ - void stop(@TaskSchedulerType int type); + void stop(int type); /** * 删除任务 @@ -115,7 +115,7 @@ public interface ITask { * * @param type {@link TaskSchedulerType} */ - void cancel(@TaskSchedulerType int type); + void cancel(int type); /** * 读取扩展数据 diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/task/IThreadTaskObserver.java b/PublicComponent/src/main/java/com/arialyy/aria/core/task/IThreadTaskObserver.java index 1b9b6016..dd2b14a1 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/task/IThreadTaskObserver.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/task/IThreadTaskObserver.java @@ -16,7 +16,6 @@ package com.arialyy.aria.core.task; import android.os.Bundle; -import androidx.annotation.Nullable; import com.arialyy.aria.core.inf.IThreadState; import com.arialyy.aria.exception.BaseException; @@ -33,7 +32,7 @@ public interface IThreadTaskObserver { * * @param state state {@link IThreadState#STATE_STOP}.. */ - void updateState(int state, @Nullable Bundle bundle); + void updateState(int state, Bundle bundle); /** * 更新完成的状态 @@ -45,7 +44,7 @@ public interface IThreadTaskObserver { * * @param needRetry 是否需要重试,一般是网络错误才需要重试 */ - void updateFailState(@Nullable BaseException e, boolean needRetry); + void updateFailState(BaseException e, boolean needRetry); /** * 更新进度 diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java b/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java index 568e2b43..d4ea3464 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java @@ -20,7 +20,6 @@ import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.os.Process; -import androidx.annotation.Nullable; import com.arialyy.aria.core.AriaConfig; import com.arialyy.aria.core.ThreadRecord; import com.arialyy.aria.core.common.SubThreadConfig; @@ -259,7 +258,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver { * @param bundle 而外数据 */ @Override - public synchronized void updateState(int state, @Nullable Bundle bundle) { + public synchronized void updateState(int state, Bundle bundle) { Message msg = mStateHandler.obtainMessage(); msg.what = state; if (state != IThreadState.STATE_UPDATE_PROGRESS) { @@ -297,7 +296,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver { * * @param needRetry 是否需要重试,一般是网络错误才需要重试 */ - @Override public synchronized void updateFailState(@Nullable BaseException e, boolean needRetry) { + @Override public synchronized void updateFailState(BaseException e, boolean needRetry) { fail(mRangeProgress, e, needRetry); } @@ -448,7 +447,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver { /** * 发送失败信息 */ - private void sendFailMsg(@Nullable BaseException e,boolean needRetry) { + private void sendFailMsg(BaseException e, boolean needRetry) { Bundle b = new Bundle(); b.putBoolean(IThreadState.KEY_RETRY, needRetry); if (e != null) { diff --git a/PublicComponent/src/main/java/com/arialyy/aria/util/SSLContextUtil.java b/PublicComponent/src/main/java/com/arialyy/aria/util/SSLContextUtil.java index 78395132..0271104f 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/util/SSLContextUtil.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/util/SSLContextUtil.java @@ -56,8 +56,7 @@ public class SSLContextUtil { * @param caPath 保存在assets目录下的CA证书完整路径 * @param protocol 连接协议 */ - public static SSLContext getSSLContextFromAssets(String caAlias, String caPath, - @ProtocolType String protocol) { + public static SSLContext getSSLContextFromAssets(String caAlias, String caPath, String protocol) { if (TextUtils.isEmpty(caAlias) || TextUtils.isEmpty(caPath)) { return null; } @@ -83,8 +82,7 @@ public class SSLContextUtil { * @param caPath CA证书路径 * @param protocol 连接协议 */ - public static SSLContext getSSLContext(String caAlias, String caPath, - @ProtocolType String protocol) { + public static SSLContext getSSLContext(String caAlias, String caPath, String protocol) { if (TextUtils.isEmpty(caAlias) || TextUtils.isEmpty(caPath)) { return null; } @@ -105,8 +103,8 @@ public class SSLContextUtil { /** * @param cacheKey 别名 + 证书路径,然后取md5 */ - private static SSLContext createContext(String caAlias, Certificate ca, - @ProtocolType String protocol, String cacheKey) { + private static SSLContext createContext(String caAlias, Certificate ca, String protocol, + String cacheKey) { try { String keyStoreType = KeyStore.getDefaultType(); KeyStore keyStore = KeyStore.getInstance(keyStoreType); @@ -154,7 +152,7 @@ public class SSLContextUtil { /** * 服务器证书不是由 CA 签署的,而是自签署时,获取默认的SSL */ - public static SSLContext getDefaultSLLContext(@ProtocolType String protocol) { + public static SSLContext getDefaultSLLContext(String protocol) { SSLContext sslContext = null; try { sslContext = diff --git a/PublicComponent/src/main/java/com/arialyy/aria/util/WeakHandler.java b/PublicComponent/src/main/java/com/arialyy/aria/util/WeakHandler.java index 7f39f5d7..cc14d039 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/util/WeakHandler.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/util/WeakHandler.java @@ -27,9 +27,6 @@ package com.arialyy.aria.util; import android.os.Handler; import android.os.Looper; import android.os.Message; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.annotation.VisibleForTesting; import java.lang.ref.WeakReference; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -51,7 +48,7 @@ import java.util.concurrent.locks.ReentrantLock; // hard reference to Callback. We need to keep callback in memory private final ExecHandler mExec; private Lock mLock = new ReentrantLock(); - @SuppressWarnings("ConstantConditions") @VisibleForTesting final ChainedRef mRunnables = + @SuppressWarnings("ConstantConditions") final ChainedRef mRunnables = new ChainedRef(mLock, null); /** @@ -76,7 +73,7 @@ import java.util.concurrent.locks.ReentrantLock; * * @param callback The callback interface in which to handle messages, or null. */ - public WeakHandler(@Nullable Handler.Callback callback) { + public WeakHandler(Handler.Callback callback) { mCallback = callback; // Hard referencing body mExec = new ExecHandler(new WeakReference<>(callback)); // Weak referencing inside ExecHandler } @@ -86,7 +83,7 @@ import java.util.concurrent.locks.ReentrantLock; * * @param looper The looper, must not be null. */ - public WeakHandler(@NonNull Looper looper) { + public WeakHandler(Looper looper) { mCallback = null; mExec = new ExecHandler(looper); } @@ -98,7 +95,7 @@ import java.util.concurrent.locks.ReentrantLock; * @param looper The looper, must not be null. * @param callback The callback interface in which to handle messages, or null. */ - public WeakHandler(@NonNull Looper looper, @NonNull Handler.Callback callback) { + public WeakHandler(Looper looper, Handler.Callback callback) { mCallback = callback; mExec = new ExecHandler(looper, new WeakReference<>(callback)); } @@ -113,7 +110,7 @@ import java.util.concurrent.locks.ReentrantLock; * message queue. Returns false on failure, usually because the * looper processing the message queue is exiting. */ - public final boolean post(@NonNull Runnable r) { + public final boolean post(Runnable r) { return mExec.post(wrapRunnable(r)); } @@ -133,7 +130,7 @@ import java.util.concurrent.locks.ReentrantLock; * the looper is quit before the delivery time of the message * occurs then the message will be dropped. */ - public final boolean postAtTime(@NonNull Runnable r, long uptimeMillis) { + public final boolean postAtTime(Runnable r, long uptimeMillis) { return mExec.postAtTime(wrapRunnable(r), uptimeMillis); } @@ -367,7 +364,7 @@ import java.util.concurrent.locks.ReentrantLock; return mExec.getLooper(); } - private WeakRunnable wrapRunnable(@NonNull Runnable r) { + private WeakRunnable wrapRunnable(Runnable r) { //noinspection ConstantConditions if (r == null) { throw new NullPointerException("Runnable can't be null"); @@ -398,7 +395,7 @@ import java.util.concurrent.locks.ReentrantLock; mCallback = callback; } - @Override public void handleMessage(@NonNull Message msg) { + @Override public void handleMessage(Message msg) { if (mCallback == null) { return; } @@ -432,14 +429,14 @@ import java.util.concurrent.locks.ReentrantLock; } static class ChainedRef { - @Nullable ChainedRef next; - @Nullable ChainedRef prev; - @NonNull final Runnable runnable; - @NonNull final WeakRunnable wrapper; + ChainedRef next; + ChainedRef prev; + final Runnable runnable; + final WeakRunnable wrapper; - @NonNull Lock lock; + Lock lock; - public ChainedRef(@NonNull Lock lock, @NonNull Runnable r) { + public ChainedRef(Lock lock, Runnable r) { this.runnable = r; this.lock = lock; this.wrapper = new WeakRunnable(new WeakReference<>(r), new WeakReference<>(this)); @@ -462,7 +459,7 @@ import java.util.concurrent.locks.ReentrantLock; return wrapper; } - public void insertAfter(@NonNull ChainedRef candidate) { + public void insertAfter(ChainedRef candidate) { lock.lock(); try { if (this.next != null) { @@ -477,7 +474,7 @@ import java.util.concurrent.locks.ReentrantLock; } } - @Nullable public WeakRunnable remove(Runnable obj) { + public WeakRunnable remove(Runnable obj) { lock.lock(); try { ChainedRef curr = this.next; // Skipping head diff --git a/SFtpComponent/build.gradle b/SFtpComponent/build.gradle index 9aa5c8cd..3e7e3a3f 100644 --- a/SFtpComponent/build.gradle +++ b/SFtpComponent/build.gradle @@ -25,7 +25,6 @@ android { dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}" implementation "com.jcraft:jsch:0.1.55" implementation "com.jcraft:jzlib:1.1.3" implementation project(path: ':FtpComponent') diff --git a/app/src/main/java/com/arialyy/simple/core/upload/UploadModule.java b/app/src/main/java/com/arialyy/simple/core/upload/UploadModule.java index 5f5aa6b5..59365c1b 100644 --- a/app/src/main/java/com/arialyy/simple/core/upload/UploadModule.java +++ b/app/src/main/java/com/arialyy/simple/core/upload/UploadModule.java @@ -35,7 +35,7 @@ public class UploadModule extends BaseViewModule { * 获取Ftp上传信息 */ LiveData getFtpInfo(Context context) { - String url = AppUtil.getConfigValue(context, FTP_URL_KEY, "ftp://9.9.9.72:2121/aa/你好"); + String url = AppUtil.getConfigValue(context, FTP_URL_KEY, "ftp://9.9.9.72:2121/aab/你好"); String filePath = AppUtil.getConfigValue(context, FTP_PATH_KEY, Environment.getExternalStorageDirectory().getPath() + "/Download/AndroidAria.db");