target 结构优化

v3.7
laoyuyu 5 years ago
parent 1e2f52daca
commit d129e0a802
  1. 1
      Aria/src/main/java/com/arialyy/aria/core/common/ftp/AbsFtpInfoThread.java
  2. 1
      Aria/src/main/java/com/arialyy/aria/core/common/ftp/AbsFtpThreadTask.java
  3. 1
      Aria/src/main/java/com/arialyy/aria/core/common/ftp/FTPSDelegate.java
  4. 1
      Aria/src/main/java/com/arialyy/aria/core/common/ftp/FtpDelegate.java
  5. 1
      Aria/src/main/java/com/arialyy/aria/core/common/ftp/FtpTaskConfig.java
  6. 2
      Aria/src/main/java/com/arialyy/aria/core/common/ftp/FtpUrlEntity.java
  7. 32
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java
  8. 5
      Aria/src/main/java/com/arialyy/aria/core/download/group/AbsGroupConfigHandler.java
  9. 3
      Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirBuilderTarget.java
  10. 3
      Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirConfigHandler.java
  11. 2
      Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirDownloadUtil.java
  12. 2
      Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirInfoThread.java
  13. 3
      Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirNormalTarget.java
  14. 3
      Aria/src/main/java/com/arialyy/aria/core/download/group/GroupBuilderTarget.java
  15. 2
      Aria/src/main/java/com/arialyy/aria/core/download/group/GroupNormalTarget.java
  16. 65
      Aria/src/main/java/com/arialyy/aria/core/download/group/GroupTargetFactory.java
  17. 4
      Aria/src/main/java/com/arialyy/aria/core/download/group/HttpGroupConfigHandler.java
  18. 6
      Aria/src/main/java/com/arialyy/aria/core/download/normal/DNormalConfigHandler.java
  19. 69
      Aria/src/main/java/com/arialyy/aria/core/download/normal/DNormalTargetFactory.java
  20. 3
      Aria/src/main/java/com/arialyy/aria/core/download/normal/FtpBuilderTarget.java
  21. 3
      Aria/src/main/java/com/arialyy/aria/core/download/normal/FtpNormalTarget.java
  22. 2
      Aria/src/main/java/com/arialyy/aria/core/download/normal/HttpBuilderTarget.java
  23. 3
      Aria/src/main/java/com/arialyy/aria/core/download/normal/HttpNormalTarget.java
  24. 17
      Aria/src/main/java/com/arialyy/aria/core/upload/UploadReceiver.java
  25. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/normal/FtpBuilderTarget.java
  26. 3
      Aria/src/main/java/com/arialyy/aria/core/upload/normal/FtpNormalTarget.java
  27. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/normal/HttpBuilderTarget.java
  28. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/normal/HttpNormalTarget.java
  29. 5
      Aria/src/main/java/com/arialyy/aria/core/upload/normal/UNormalConfigHandler.java
  30. 69
      Aria/src/main/java/com/arialyy/aria/core/upload/normal/UNormalTargetFactory.java
  31. 3
      Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java
  32. 2
      app/src/main/assets/help_code/KotlinHttpDownload.kt

@ -25,7 +25,6 @@ import aria.apache.commons.net.ftp.FTPFile;
import aria.apache.commons.net.ftp.FTPReply;
import aria.apache.commons.net.ftp.FTPSClient;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.common.OnFileInfoCallback;
import com.arialyy.aria.core.inf.AbsEntity;
import com.arialyy.aria.core.inf.AbsTaskWrapper;

@ -21,7 +21,6 @@ import aria.apache.commons.net.ftp.FTPClient;
import aria.apache.commons.net.ftp.FTPClientConfig;
import aria.apache.commons.net.ftp.FTPReply;
import aria.apache.commons.net.ftp.FTPSClient;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.common.AbsThreadTask;
import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.inf.AbsNormalEntity;

@ -17,7 +17,6 @@ package com.arialyy.aria.core.common.ftp;
import android.text.TextUtils;
import androidx.annotation.CheckResult;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.common.BaseDelegate;
import com.arialyy.aria.core.common.ProtocolType;
import com.arialyy.aria.core.common.Suggest;

@ -18,7 +18,6 @@ package com.arialyy.aria.core.common.ftp;
import android.text.TextUtils;
import androidx.annotation.CheckResult;
import aria.apache.commons.net.ftp.FTPClientConfig;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.common.BaseDelegate;
import com.arialyy.aria.core.common.Suggest;
import com.arialyy.aria.core.inf.AbsTarget;

@ -16,7 +16,6 @@
package com.arialyy.aria.core.common.ftp;
import aria.apache.commons.net.ftp.FTPClientConfig;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.inf.ITaskConfig;
import java.lang.ref.SoftReference;
import java.net.Proxy;

@ -15,7 +15,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core;
package com.arialyy.aria.core.common.ftp;
import com.arialyy.aria.core.common.ProtocolType;
import java.net.InetAddress;

@ -24,6 +24,16 @@ import com.arialyy.aria.core.command.CancelAllCmd;
import com.arialyy.aria.core.command.NormalCmdFactory;
import com.arialyy.aria.core.common.AbsBuilderTarget;
import com.arialyy.aria.core.common.ProxyHelper;
import com.arialyy.aria.core.download.group.FtpDirBuilderTarget;
import com.arialyy.aria.core.download.group.FtpDirNormalTarget;
import com.arialyy.aria.core.download.group.GroupBuilderTarget;
import com.arialyy.aria.core.download.group.GroupNormalTarget;
import com.arialyy.aria.core.download.group.GroupTargetFactory;
import com.arialyy.aria.core.download.normal.FtpBuilderTarget;
import com.arialyy.aria.core.download.normal.FtpNormalTarget;
import com.arialyy.aria.core.download.normal.HttpBuilderTarget;
import com.arialyy.aria.core.download.normal.HttpNormalTarget;
import com.arialyy.aria.core.download.normal.DNormalTargetFactory;
import com.arialyy.aria.core.event.EventMsgUtil;
import com.arialyy.aria.core.inf.AbsEntity;
import com.arialyy.aria.core.inf.AbsReceiver;
@ -66,7 +76,8 @@ public class DownloadReceiver extends AbsReceiver {
@CheckResult
public HttpBuilderTarget load(@NonNull String url) {
CheckUtil.checkUrlInvalidThrow(url);
return new HttpBuilderTarget(url, targetName);
return DNormalTargetFactory.getInstance()
.generateBuilderTarget(HttpBuilderTarget.class, url, targetName);
}
/**
@ -78,7 +89,8 @@ public class DownloadReceiver extends AbsReceiver {
@CheckResult
public HttpNormalTarget load(long taskId) {
CheckUtil.checkTaskId(taskId);
return new HttpNormalTarget(taskId, targetName);
return DNormalTargetFactory.getInstance()
.generateNormalTarget(HttpNormalTarget.class, taskId, targetName);
}
/**
@ -89,7 +101,7 @@ public class DownloadReceiver extends AbsReceiver {
@CheckResult
public GroupBuilderTarget loadGroup(List<String> urls) {
CheckUtil.checkDownloadUrls(urls);
return new GroupBuilderTarget(urls, targetName);
return GroupTargetFactory.getInstance().generateGroupBuilderTarget(urls, targetName);
}
/**
@ -101,7 +113,8 @@ public class DownloadReceiver extends AbsReceiver {
@CheckResult
public GroupNormalTarget loadGroup(long taskId) {
CheckUtil.checkTaskId(taskId);
return new GroupNormalTarget(taskId, targetName);
return GroupTargetFactory.getInstance()
.generateNormalTarget(GroupNormalTarget.class, taskId, targetName);
}
/**
@ -110,7 +123,8 @@ public class DownloadReceiver extends AbsReceiver {
@CheckResult
public FtpBuilderTarget loadFtp(@NonNull String url) {
CheckUtil.checkUrlInvalidThrow(url);
return new FtpBuilderTarget(url, targetName);
return DNormalTargetFactory.getInstance()
.generateBuilderTarget(FtpBuilderTarget.class, url, targetName);
}
/**
@ -122,7 +136,8 @@ public class DownloadReceiver extends AbsReceiver {
@CheckResult
public FtpNormalTarget loadFtp(long taskId) {
CheckUtil.checkTaskId(taskId);
return new FtpNormalTarget(taskId, targetName);
return DNormalTargetFactory.getInstance()
.generateNormalTarget(FtpNormalTarget.class, taskId, targetName);
}
/**
@ -131,7 +146,7 @@ public class DownloadReceiver extends AbsReceiver {
@CheckResult
public FtpDirBuilderTarget loadFtpDir(@NonNull String dirUrl) {
CheckUtil.checkUrlInvalidThrow(dirUrl);
return new FtpDirBuilderTarget(dirUrl, targetName);
return GroupTargetFactory.getInstance().generateDirBuilderTarget(dirUrl, targetName);
}
/**
@ -143,7 +158,8 @@ public class DownloadReceiver extends AbsReceiver {
@CheckResult
public FtpDirNormalTarget loadFtpDir(long taskId) {
CheckUtil.checkTaskId(taskId);
return new FtpDirNormalTarget(taskId, targetName);
return GroupTargetFactory.getInstance()
.generateNormalTarget(FtpDirNormalTarget.class, taskId, targetName);
}
/**

@ -13,10 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.group;
import androidx.annotation.CheckResult;
import android.text.TextUtils;
import com.arialyy.aria.core.download.DGTaskWrapper;
import com.arialyy.aria.core.download.DownloadGroupEntity;
import com.arialyy.aria.core.download.DownloadGroupTask;
import com.arialyy.aria.core.event.ErrorEvent;
import com.arialyy.aria.core.inf.AbsTarget;
import com.arialyy.aria.core.inf.IConfigHandler;

@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.group;
import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.AbsBuilderTarget;
import com.arialyy.aria.core.common.Suggest;
import com.arialyy.aria.core.common.ftp.FtpDelegate;
import com.arialyy.aria.core.download.DownloadGroupEntity;
import com.arialyy.aria.core.manager.SubTaskManager;
import com.arialyy.aria.util.CommonUtil;

@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.group;
import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.inf.AbsTarget;
import com.arialyy.aria.core.inf.AbsTaskWrapper;
import com.arialyy.aria.core.inf.ITaskWrapper;

@ -17,7 +17,7 @@ package com.arialyy.aria.core.download.group;
import android.net.Uri;
import android.text.TextUtils;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.common.ftp.FtpUrlEntity;
import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.common.OnFileInfoCallback;
import com.arialyy.aria.core.download.DGTaskWrapper;

@ -16,7 +16,7 @@
package com.arialyy.aria.core.download.group;
import aria.apache.commons.net.ftp.FTPFile;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.common.ftp.FtpUrlEntity;
import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.common.OnFileInfoCallback;
import com.arialyy.aria.core.common.ftp.AbsFtpInfoThread;

@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.group;
import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.AbsNormalTarget;
import com.arialyy.aria.core.common.Suggest;
import com.arialyy.aria.core.common.ftp.FtpDelegate;
import com.arialyy.aria.core.download.DownloadGroupEntity;
import com.arialyy.aria.core.manager.SubTaskManager;
import com.arialyy.aria.util.CommonUtil;

@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.group;
import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.AbsBuilderTarget;
import com.arialyy.aria.core.common.Suggest;
import com.arialyy.aria.core.common.http.HttpDelegate;
import com.arialyy.aria.core.download.DGTaskWrapper;
import com.arialyy.aria.core.inf.IHttpFileLenAdapter;
import com.arialyy.aria.core.inf.ITaskWrapper;
import com.arialyy.aria.core.manager.SubTaskManager;

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.group;
import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.AbsNormalTarget;

@ -0,0 +1,65 @@
/*
* 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.group;
import com.arialyy.aria.core.common.AbsNormalTarget;
import java.util.List;
/**
* @Author aria
* @Date 2019-09-05
*/
public class GroupTargetFactory {
public static volatile GroupTargetFactory INSTANCE;
private GroupTargetFactory() {
}
public static GroupTargetFactory getInstance() {
if (INSTANCE == null) {
synchronized (GroupTargetFactory.class) {
if (INSTANCE == null) {
INSTANCE = new GroupTargetFactory();
}
}
}
return INSTANCE;
}
public <T extends AbsNormalTarget> T generateNormalTarget(Class<T> clazz, long taskId,
String targetName) {
T target = null;
if (clazz == GroupNormalTarget.class) {
target = (T) new GroupNormalTarget(taskId, targetName);
} else if (clazz == FtpDirNormalTarget.class) {
target = (T) new FtpDirNormalTarget(taskId, targetName);
}
return target;
}
public FtpDirBuilderTarget generateDirBuilderTarget(String url, String targetName) {
return new FtpDirBuilderTarget(url, targetName);
}
public GroupBuilderTarget generateGroupBuilderTarget(List<String> urls, String targetName) {
return new GroupBuilderTarget(urls, targetName);
}
}

@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.group;
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;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;

@ -13,9 +13,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.normal;
import android.text.TextUtils;
import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.event.ErrorEvent;
import com.arialyy.aria.core.inf.AbsTarget;
import com.arialyy.aria.core.inf.IConfigHandler;
@ -57,7 +59,7 @@ class DNormalConfigHandler<TARGET extends AbsTarget> implements IConfigHandler {
}
}
TARGET updateUrl(String newUrl) {
public TARGET updateUrl(String newUrl) {
if (TextUtils.isEmpty(newUrl)) {
ALog.e(TAG, "url更新失败,newUrl为null");
return mTarget;

@ -0,0 +1,69 @@
/*
* 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.normal;
import com.arialyy.aria.core.common.AbsBuilderTarget;
import com.arialyy.aria.core.common.AbsNormalTarget;
/**
* @Author aria
* @Date 2019-09-05
*/
public class DNormalTargetFactory {
public static volatile DNormalTargetFactory INSTANCE;
private DNormalTargetFactory() {
}
public static DNormalTargetFactory getInstance() {
if (INSTANCE == null) {
synchronized (DNormalTargetFactory.class) {
if (INSTANCE == null) {
INSTANCE = new DNormalTargetFactory();
}
}
}
return INSTANCE;
}
public <T extends AbsNormalTarget> T generateNormalTarget(Class<T> clazz, long taskId,
String targetName) {
T target = null;
if (clazz == HttpNormalTarget.class) {
target = (T) new HttpNormalTarget(taskId, targetName);
} else if (clazz == FtpNormalTarget.class) {
target = (T) new FtpNormalTarget(taskId, targetName);
}
return target;
}
public <T extends AbsBuilderTarget> T generateBuilderTarget(Class<T> clazz, String url,
String targetName) {
T target = null;
if (clazz == HttpBuilderTarget.class) {
target = (T) new HttpBuilderTarget(url, targetName);
} else if (clazz == FtpBuilderTarget.class) {
target = (T) new FtpBuilderTarget(url, targetName);
}
return target;
}
}

@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.normal;
import androidx.annotation.CheckResult;
import androidx.annotation.NonNull;
import com.arialyy.aria.core.common.AbsBuilderTarget;
import com.arialyy.aria.core.common.Suggest;
import com.arialyy.aria.core.common.ftp.FtpDelegate;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.ITaskWrapper;
import com.arialyy.aria.util.CommonUtil;

@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.normal;
import androidx.annotation.CheckResult;
import androidx.annotation.NonNull;
import com.arialyy.aria.core.common.AbsNormalTarget;
import com.arialyy.aria.core.common.Suggest;
import com.arialyy.aria.core.common.ftp.FtpDelegate;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.ITaskWrapper;
import com.arialyy.aria.util.CommonUtil;

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.normal;
import androidx.annotation.CheckResult;
import androidx.annotation.NonNull;

@ -13,12 +13,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.download;
package com.arialyy.aria.core.download.normal;
import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.AbsNormalTarget;
import com.arialyy.aria.core.common.Suggest;
import com.arialyy.aria.core.common.http.HttpDelegate;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.m3u8.M3U8Delegate;
/**

@ -30,6 +30,11 @@ import com.arialyy.aria.core.inf.AbsReceiver;
import com.arialyy.aria.core.inf.ITask;
import com.arialyy.aria.core.inf.ReceiverType;
import com.arialyy.aria.core.scheduler.TaskSchedulers;
import com.arialyy.aria.core.upload.normal.FtpBuilderTarget;
import com.arialyy.aria.core.upload.normal.FtpNormalTarget;
import com.arialyy.aria.core.upload.normal.HttpBuilderTarget;
import com.arialyy.aria.core.upload.normal.HttpNormalTarget;
import com.arialyy.aria.core.upload.normal.UNormalTargetFactory;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil;
@ -64,7 +69,8 @@ public class UploadReceiver extends AbsReceiver {
@CheckResult
public HttpBuilderTarget load(@NonNull String filePath) {
CheckUtil.checkUploadPath(filePath);
return new HttpBuilderTarget(filePath, targetName);
return UNormalTargetFactory.getInstance()
.generateBuilderTarget(HttpBuilderTarget.class, filePath, targetName);
}
/**
@ -76,7 +82,8 @@ public class UploadReceiver extends AbsReceiver {
@CheckResult
public HttpNormalTarget load(long taskId) {
CheckUtil.checkTaskId(taskId);
return new HttpNormalTarget(taskId, targetName);
return UNormalTargetFactory.getInstance()
.generateNormalTarget(HttpNormalTarget.class, taskId, targetName);
}
/**
@ -87,7 +94,8 @@ public class UploadReceiver extends AbsReceiver {
@CheckResult
public FtpBuilderTarget loadFtp(@NonNull String filePath) {
CheckUtil.checkUploadPath(filePath);
return new FtpBuilderTarget(filePath, targetName);
return UNormalTargetFactory.getInstance()
.generateBuilderTarget(FtpBuilderTarget.class, filePath, targetName);
}
/**
@ -99,7 +107,8 @@ public class UploadReceiver extends AbsReceiver {
@CheckResult
public FtpNormalTarget loadFtp(long taskId) {
CheckUtil.checkTaskId(taskId);
return new FtpNormalTarget(taskId, targetName);
return UNormalTargetFactory.getInstance()
.generateNormalTarget(FtpNormalTarget.class, taskId, targetName);
}
/**

@ -13,7 +13,7 @@
* 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.upload.normal;
import androidx.annotation.CheckResult;
import androidx.annotation.NonNull;

@ -13,13 +13,14 @@
* 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.upload.normal;
import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.AbsNormalTarget;
import com.arialyy.aria.core.common.Suggest;
import com.arialyy.aria.core.common.ftp.FtpDelegate;
import com.arialyy.aria.core.inf.AbsTaskWrapper;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.util.CommonUtil;
/**

@ -13,7 +13,7 @@
* 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.upload.normal;
import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.AbsBuilderTarget;

@ -13,7 +13,7 @@
* 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.upload.normal;
import androidx.annotation.CheckResult;
import com.arialyy.aria.core.common.AbsNormalTarget;

@ -13,7 +13,7 @@
* 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.upload.normal;
import com.arialyy.aria.core.common.ftp.IFtpUploadInterceptor;
import com.arialyy.aria.core.event.ErrorEvent;
@ -22,6 +22,9 @@ import com.arialyy.aria.core.inf.AbsTarget;
import com.arialyy.aria.core.inf.IConfigHandler;
import com.arialyy.aria.core.manager.TaskWrapperManager;
import com.arialyy.aria.core.queue.UploadTaskQueue;
import com.arialyy.aria.core.upload.UTaskWrapper;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.upload.UploadTask;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.CommonUtil;
import java.io.File;

@ -0,0 +1,69 @@
/*
* 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.upload.normal;
import com.arialyy.aria.core.common.AbsBuilderTarget;
import com.arialyy.aria.core.common.AbsNormalTarget;
/**
* @Author aria
* @Date 2019-09-05
*/
public class UNormalTargetFactory {
public static volatile UNormalTargetFactory INSTANCE;
private UNormalTargetFactory() {
}
public static UNormalTargetFactory getInstance() {
if (INSTANCE == null) {
synchronized (UNormalTargetFactory.class) {
if (INSTANCE == null) {
INSTANCE = new UNormalTargetFactory();
}
}
}
return INSTANCE;
}
public <T extends AbsNormalTarget> T generateNormalTarget(Class<T> clazz, long taskId,
String targetName) {
T target = null;
if (clazz == HttpNormalTarget.class) {
target = (T) new HttpNormalTarget(taskId, targetName);
} else if (clazz == FtpNormalTarget.class) {
target = (T) new FtpNormalTarget(taskId, targetName);
}
return target;
}
public <T extends AbsBuilderTarget> T generateBuilderTarget(Class<T> clazz, String url,
String targetName) {
T target = null;
if (clazz == HttpBuilderTarget.class) {
target = (T) new HttpBuilderTarget(url, targetName);
} else if (clazz == FtpBuilderTarget.class) {
target = (T) new FtpBuilderTarget(url, targetName);
}
return target;
}
}

@ -21,11 +21,10 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Environment;
import android.os.StatFs;
import android.text.TextUtils;
import android.util.Base64;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.common.ftp.FtpUrlEntity;
import com.arialyy.aria.core.command.AbsGroupCmd;
import com.arialyy.aria.core.command.AbsNormalCmd;
import com.arialyy.aria.core.command.GroupCmdFactory;

@ -21,7 +21,7 @@ import android.widget.Button
import android.widget.Toast
import com.arialyy.annotations.Download
import com.arialyy.aria.core.Aria
import com.arialyy.aria.core.download.HttpNormalTarget
import com.arialyy.aria.core.download.normal.HttpNormalTarget
import com.arialyy.aria.core.download.DownloadTask
import com.arialyy.aria.core.inf.IEntity
import com.arialyy.simple.R

Loading…
Cancel
Save