3.7.6
This commit is contained in:
@@ -170,9 +170,8 @@ public class CheckDGEntityUtil implements ICheckEntityUtil {
|
|||||||
if (!newName.equals(entity.getFileName())) {
|
if (!newName.equals(entity.getFileName())) {
|
||||||
String oldPath = mEntity.getDirPath() + "/" + entity.getFileName();
|
String oldPath = mEntity.getDirPath() + "/" + entity.getFileName();
|
||||||
String newPath = mEntity.getDirPath() + "/" + newName;
|
String newPath = mEntity.getDirPath() + "/" + newName;
|
||||||
if (DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=? or isComplete='true'",
|
if (DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=?", newPath)) {
|
||||||
newPath)) {
|
ALog.w(TAG, String.format("更新文件名失败,路径【%s】被其它任务占用", newPath));
|
||||||
ALog.w(TAG, String.format("更新文件名失败,路径【%s】已存在或文件已下载", newPath));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public class FtpBuilderTarget extends AbsBuilderTarget<FtpBuilderTarget> {
|
|||||||
mConfigHandler = new UNormalConfigHandler<>(this, -1);
|
mConfigHandler = new UNormalConfigHandler<>(this, -1);
|
||||||
mConfigHandler.setFilePath(filePath);
|
mConfigHandler.setFilePath(filePath);
|
||||||
getTaskWrapper().setRequestType(ITaskWrapper.U_FTP);
|
getTaskWrapper().setRequestType(ITaskWrapper.U_FTP);
|
||||||
|
getTaskWrapper().setNewTask(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
## 开发日志
|
## 开发日志
|
||||||
+ v_3.7.6
|
+ v_3.7.6 (2019/11/19)
|
||||||
|
- fix bug https://github.com/AriaLyy/Aria/issues/505
|
||||||
|
- fix bug https://github.com/AriaLyy/Aria/issues/516
|
||||||
|
- fix bug https://github.com/AriaLyy/Aria/issues/515
|
||||||
- 增加强制上传的api`forceUpload()`
|
- 增加强制上传的api`forceUpload()`
|
||||||
- 修复for循环上传文件出现的问题
|
- 修复for循环上传文件出现的问题
|
||||||
- 移除创建任务的500ms间隔限制
|
- 移除创建任务的500ms间隔限制
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class FtpUFileInfoThread extends AbsFtpInfoThread<UploadEntity, UTaskWrapper> {
|
|||||||
@Override protected boolean onInterceptor(FTPClient client, FTPFile[] ftpFiles) {
|
@Override protected boolean onInterceptor(FTPClient client, FTPFile[] ftpFiles) {
|
||||||
// 旧任务将不做处理,否则断点续传上传将失效
|
// 旧任务将不做处理,否则断点续传上传将失效
|
||||||
if (!mTaskWrapper.isNewTask()) {
|
if (!mTaskWrapper.isNewTask()) {
|
||||||
|
ALog.d(TAG, "任务是旧任务,忽略该拦截器");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
33
README.md
33
README.md
@@ -44,20 +44,20 @@ Aria有以下特点:
|
|||||||
|
|
||||||
## 引入库
|
## 引入库
|
||||||
[](https://github.com/AriaLyy/Aria/blob/master/LICENSE)
|
[](https://github.com/AriaLyy/Aria/blob/master/LICENSE)
|
||||||
[](https://github.com/AriaLyy/Aria)
|
[](https://github.com/AriaLyy/Aria)
|
||||||
[](https://github.com/AriaLyy/Aria)
|
[](https://github.com/AriaLyy/Aria)
|
||||||
[](https://github.com/AriaLyy/Aria)
|
[](https://github.com/AriaLyy/Aria)
|
||||||
[](https://github.com/AriaLyy/Aria)
|
[](https://github.com/AriaLyy/Aria)
|
||||||
|
|
||||||
```java
|
```java
|
||||||
implementation 'com.arialyy.aria:core:3.7.5'
|
implementation 'com.arialyy.aria:core:3.7.6'
|
||||||
annotationProcessor 'com.arialyy.aria:compiler:3.7.5'
|
annotationProcessor 'com.arialyy.aria:compiler:3.7.6'
|
||||||
implementation 'com.arialyy.aria:ftpComponent:3.7.5' # 如果需要使用ftp,请增加该组件
|
implementation 'com.arialyy.aria:ftpComponent:3.7.6' # 如果需要使用ftp,请增加该组件
|
||||||
implementation 'com.arialyy.aria:m3u8Component:3.7.5' # 如果需要使用m3u8下载功能,请增加该组件
|
implementation 'com.arialyy.aria:m3u8Component:3.7.6' # 如果需要使用m3u8下载功能,请增加该组件
|
||||||
```
|
```
|
||||||
如果出现android support依赖错误,请将 `compile 'com.arialyy.aria:core:<last-version>'`替换为
|
如果出现android support依赖错误,请将 `compile 'com.arialyy.aria:core:<last-version>'`替换为
|
||||||
```
|
```
|
||||||
api('com.arialyy.aria:aria-core:<last-version>'){
|
api('com.arialyy.aria:core:<last-version>'){
|
||||||
exclude group: 'androidx.appcompat.app'
|
exclude group: 'androidx.appcompat.app'
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -65,7 +65,7 @@ api('com.arialyy.aria:aria-core:<last-version>'){
|
|||||||
|
|
||||||
__⚠️注意:3.5.4以下版本升级时,需要更新[配置文件](https://aria.laoyuyu.me/aria_doc/start/config.html)!!__
|
__⚠️注意:3.5.4以下版本升级时,需要更新[配置文件](https://aria.laoyuyu.me/aria_doc/start/config.html)!!__
|
||||||
|
|
||||||
__⚠️注意:3.7 以上版本已经适配了AndroidX__
|
__⚠️注意:3.7 以上版本已经适配了AndroidX,如果是使用support库的,可使用[老版本](https://github.com/AriaLyy/Aria/tree/v3.6.6)__
|
||||||
|
|
||||||
***
|
***
|
||||||
## 使用
|
## 使用
|
||||||
@@ -137,11 +137,14 @@ protected void onCreate(Bundle savedInstanceState) {
|
|||||||
|
|
||||||
|
|
||||||
### 版本日志
|
### 版本日志
|
||||||
+ v_3.7.5 (2019/11/10)
|
+ v_3.7.6 (2019/11/19)
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/500
|
- fix bug https://github.com/AriaLyy/Aria/issues/505
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/508
|
- fix bug https://github.com/AriaLyy/Aria/issues/516
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/503
|
- fix bug https://github.com/AriaLyy/Aria/issues/515
|
||||||
- 修复m3u8创建索引不成功的问题
|
- 增加强制上传的api`forceUpload()`
|
||||||
|
- 修复for循环上传文件出现的问题
|
||||||
|
- 移除创建任务的500ms间隔限制
|
||||||
|
- 修复多线程读写时可能出现的`database is locked`的问题
|
||||||
|
|
||||||
[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)
|
[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)
|
||||||
|
|
||||||
|
|||||||
@@ -1,58 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package com.arialyy.aria.sftp;
|
|
||||||
|
|
||||||
import com.arialyy.aria.core.inf.OnFileInfoCallback;
|
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
|
||||||
import com.jcraft.jsch.ChannelSftp;
|
|
||||||
import com.jcraft.jsch.JSchException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取sftp文件信息
|
|
||||||
*
|
|
||||||
* @author lyy
|
|
||||||
*/
|
|
||||||
public class AbsSFtpFileInfoThread<WP extends AbsTaskWrapper> implements Runnable {
|
|
||||||
|
|
||||||
private WP mWrapper;
|
|
||||||
private SFtpUtil mUtil;
|
|
||||||
private OnFileInfoCallback mCallback;
|
|
||||||
|
|
||||||
public AbsSFtpFileInfoThread(SFtpUtil util, WP wrapper, OnFileInfoCallback callback) {
|
|
||||||
mWrapper = wrapper;
|
|
||||||
mUtil = util;
|
|
||||||
mCallback = callback;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void run() {
|
|
||||||
startFlow();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void startFlow() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private ChannelSftp createChannel() {
|
|
||||||
ChannelSftp sftp = null;
|
|
||||||
try {
|
|
||||||
sftp = (ChannelSftp) mUtil.getSession().openChannel(SFtpUtil.CMD_TYPE_SFTP);
|
|
||||||
sftp.connect();
|
|
||||||
} catch (JSchException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return sftp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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.sftp;
|
||||||
|
|
||||||
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sftp文件信息适配器
|
||||||
|
*/
|
||||||
|
public abstract class BaseInfoThreadAdapter<WRAPPER extends AbsTaskWrapper> {
|
||||||
|
|
||||||
|
private WRAPPER mWrapper;
|
||||||
|
|
||||||
|
public BaseInfoThreadAdapter(WRAPPER taskWrapper) {
|
||||||
|
mWrapper = taskWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WRAPPER getWrapper() {
|
||||||
|
return mWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理文件
|
||||||
|
*
|
||||||
|
* @return true 处理文件成功,false 处理文件失败,结束任务
|
||||||
|
*/
|
||||||
|
protected abstract boolean handlerFile(Vector vector);
|
||||||
|
}
|
||||||
@@ -16,19 +16,25 @@
|
|||||||
package com.arialyy.aria.sftp;
|
package com.arialyy.aria.sftp;
|
||||||
|
|
||||||
import com.arialyy.aria.core.AriaConfig;
|
import com.arialyy.aria.core.AriaConfig;
|
||||||
import com.arialyy.aria.core.common.AbsEntity;
|
import com.arialyy.aria.core.FtpUrlEntity;
|
||||||
|
import com.arialyy.aria.core.common.AbsNormalEntity;
|
||||||
import com.arialyy.aria.core.inf.OnFileInfoCallback;
|
import com.arialyy.aria.core.inf.OnFileInfoCallback;
|
||||||
import com.arialyy.aria.core.upload.UploadEntity;
|
import com.arialyy.aria.core.upload.UploadEntity;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.ftp.FtpTaskOption;
|
import com.arialyy.aria.ftp.FtpTaskOption;
|
||||||
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
|
import com.jcraft.jsch.ChannelSftp;
|
||||||
|
import com.jcraft.jsch.JSchException;
|
||||||
|
import com.jcraft.jsch.SftpException;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* https://cloud.tencent.com/developer/article/1354612
|
* https://cloud.tencent.com/developer/article/1354612
|
||||||
|
*
|
||||||
* @author lyy
|
* @author lyy
|
||||||
*/
|
*/
|
||||||
public class AbsSFtpInfoThread<ENTITY extends AbsEntity, TASK_WRAPPER extends AbsTaskWrapper<ENTITY>>
|
public class SFtpInfoThread<ENTITY extends AbsNormalEntity, TASK_WRAPPER extends AbsTaskWrapper<ENTITY>>
|
||||||
implements Runnable {
|
implements Runnable {
|
||||||
|
|
||||||
private final String TAG = CommonUtil.getClassName(getClass());
|
private final String TAG = CommonUtil.getClassName(getClass());
|
||||||
@@ -40,8 +46,12 @@ public class AbsSFtpInfoThread<ENTITY extends AbsEntity, TASK_WRAPPER extends Ab
|
|||||||
protected long mSize = 0;
|
protected long mSize = 0;
|
||||||
protected String charSet = "UTF-8";
|
protected String charSet = "UTF-8";
|
||||||
private boolean isUpload = false;
|
private boolean isUpload = false;
|
||||||
|
private SFtpUtil mSFtpUtil;
|
||||||
|
private BaseInfoThreadAdapter mAdapter;
|
||||||
|
|
||||||
public AbsSFtpInfoThread(TASK_WRAPPER taskWrapper, OnFileInfoCallback callback) {
|
public SFtpInfoThread(SFtpUtil ftpUtil, TASK_WRAPPER taskWrapper,
|
||||||
|
OnFileInfoCallback callback) {
|
||||||
|
mSFtpUtil = ftpUtil;
|
||||||
mTaskWrapper = taskWrapper;
|
mTaskWrapper = taskWrapper;
|
||||||
mEntity = taskWrapper.getEntity();
|
mEntity = taskWrapper.getEntity();
|
||||||
mTaskOption = (FtpTaskOption) taskWrapper.getTaskOption();
|
mTaskOption = (FtpTaskOption) taskWrapper.getTaskOption();
|
||||||
@@ -52,7 +62,39 @@ public class AbsSFtpInfoThread<ENTITY extends AbsEntity, TASK_WRAPPER extends Ab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void run() {
|
public void setAdapter(BaseInfoThreadAdapter adapter) {
|
||||||
|
mAdapter = adapter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void run() {
|
||||||
|
if (mAdapter == null) {
|
||||||
|
ALog.e(TAG, "adapter为空");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ChannelSftp channelSftp =
|
||||||
|
(ChannelSftp) mSFtpUtil.getSession().openChannel(SFtpUtil.CMD_TYPE_SFTP);
|
||||||
|
Vector files = channelSftp.ls(getUrlEntity().remotePath);
|
||||||
|
|
||||||
|
if (files.isEmpty()) {
|
||||||
|
ALog.e(TAG, String.format("路径【%s】没有文件", getUrlEntity().remotePath));
|
||||||
|
mCallback.onFail(mEntity, null, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mAdapter.handlerFile(files)) {
|
||||||
|
ALog.e(TAG, "文件处理失败");
|
||||||
|
mCallback.onFail(mEntity, null, false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (JSchException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
} catch (SftpException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private FtpUrlEntity getUrlEntity() {
|
||||||
|
return mTaskOption.getUrlEntity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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.sftp.download;
|
||||||
|
|
||||||
|
import com.arialyy.aria.core.download.DTaskWrapper;
|
||||||
|
import com.arialyy.aria.sftp.BaseInfoThreadAdapter;
|
||||||
|
import java.util.Vector;
|
||||||
|
|
||||||
|
final class DSFtpInfoThreadAdapter extends BaseInfoThreadAdapter<DTaskWrapper> {
|
||||||
|
|
||||||
|
DSFtpInfoThreadAdapter(DTaskWrapper taskWrapper) {
|
||||||
|
super(taskWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override protected boolean handlerFile(Vector vector) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ import com.arialyy.aria.core.loader.NormalLoader;
|
|||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.BaseException;
|
||||||
import com.arialyy.aria.ftp.FtpTaskOption;
|
import com.arialyy.aria.ftp.FtpTaskOption;
|
||||||
import com.arialyy.aria.sftp.AbsSFtpFileInfoThread;
|
import com.arialyy.aria.sftp.SFtpInfoThread;
|
||||||
import com.arialyy.aria.sftp.SFtpUtil;
|
import com.arialyy.aria.sftp.SFtpUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -57,15 +57,19 @@ public class SFtpDLoaderUtil extends AbsNormalLoaderUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override protected Runnable createInfoThread() {
|
@Override protected Runnable createInfoThread() {
|
||||||
return new AbsSFtpFileInfoThread<>(mSftpUtil, (DTaskWrapper) getTaskWrapper(), new OnFileInfoCallback() {
|
DSFtpInfoThreadAdapter adapter = new DSFtpInfoThreadAdapter((DTaskWrapper) getTaskWrapper());
|
||||||
@Override public void onComplete(String key, CompleteInfo info) {
|
SFtpInfoThread infoThread = new SFtpInfoThread<>(mSftpUtil, (DTaskWrapper) getTaskWrapper(),
|
||||||
|
new OnFileInfoCallback() {
|
||||||
|
@Override public void onComplete(String key, CompleteInfo info) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
||||||
|
|
||||||
mSftpUtil.logout();
|
}
|
||||||
}
|
});
|
||||||
});
|
infoThread.setAdapter(adapter);
|
||||||
|
|
||||||
|
return infoThread;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,13 +95,13 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
|||||||
mTaskId = Aria.download(this)
|
mTaskId = Aria.download(this)
|
||||||
.loadGroup(mUrls)
|
.loadGroup(mUrls)
|
||||||
.setDirPath(
|
.setDirPath(
|
||||||
Environment.getExternalStorageDirectory().getPath() + "/Download/group_test_2")
|
Environment.getExternalStorageDirectory().getPath() + "/Download/group_imgs")
|
||||||
.setGroupAlias("任务组测试")
|
.setGroupAlias("图片测试")
|
||||||
//.setSubFileName(getModule(GroupModule.class).getSubName2())
|
//.setSubFileName(getModule(GroupModule.class).getSubName2())
|
||||||
.setSubFileName(getModule(GroupModule.class).getSubName())
|
//.setSubFileName(getModule(GroupModule.class).getSubName())
|
||||||
.unknownSize()
|
.unknownSize()
|
||||||
.option(getHttpOption())
|
.option(getHttpOption())
|
||||||
.setFileSize(114981416)
|
//.setFileSize(114981416)
|
||||||
//.updateUrls(temp)
|
//.updateUrls(temp)
|
||||||
.create();
|
.create();
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
getBinding().setStateStr(getString(R.string.stop));
|
||||||
|
|||||||
@@ -32,8 +32,10 @@ public class GroupModule extends BaseModule {
|
|||||||
|
|
||||||
public List<String> getUrls() {
|
public List<String> getUrls() {
|
||||||
List<String> urls = new ArrayList<>();
|
List<String> urls = new ArrayList<>();
|
||||||
String[] str = getContext().getResources().getStringArray(R.array.group_urls_1);
|
urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924275&di=a7ea1497a4a2528a45ce7103bf61adf4&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fc2cec3fdfc03924590b2a9b58d94a4c27d1e2500.jpg");
|
||||||
Collections.addAll(urls, str);
|
urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924272&di=7861479e7cb3cea98d585eaf108f056f&imgtype=0&src=http%3A%2F%2Fd.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F562c11dfa9ec8a13c0741f5afd03918fa0ecc01a.jpg");
|
||||||
|
//String[] str = getContext().getResources().getStringArray(R.array.group_urls_1);
|
||||||
|
//Collections.addAll(urls, str);
|
||||||
return urls;
|
return urls;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ import com.arialyy.annotations.Upload;
|
|||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
import com.arialyy.aria.core.common.FtpOption;
|
import com.arialyy.aria.core.common.FtpOption;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
import com.arialyy.aria.core.inf.IEntity;
|
||||||
|
import com.arialyy.aria.core.processor.FtpInterceptHandler;
|
||||||
|
import com.arialyy.aria.core.processor.IFtpUploadInterceptor;
|
||||||
import com.arialyy.aria.core.task.UploadTask;
|
import com.arialyy.aria.core.task.UploadTask;
|
||||||
import com.arialyy.aria.core.upload.UploadEntity;
|
import com.arialyy.aria.core.upload.UploadEntity;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
@@ -114,26 +116,27 @@ public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
|
|||||||
public void onClick(View view) {
|
public void onClick(View view) {
|
||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.start:
|
case R.id.start:
|
||||||
//if (mTaskId == -1) {
|
if (mTaskId == -1) {
|
||||||
// mTaskId = Aria.upload(this)
|
mTaskId = Aria.upload(this)
|
||||||
// .loadFtp(mFilePath)
|
.loadFtp(mFilePath)
|
||||||
// .setUploadUrl(mUrl)
|
.setUploadUrl(mUrl)
|
||||||
// .option(getOption())
|
.option(getOption())
|
||||||
// .create();
|
.forceUpload()
|
||||||
// getBinding().setStateStr(getString(R.string.stop));
|
.create();
|
||||||
// break;
|
getBinding().setStateStr(getString(R.string.stop));
|
||||||
//}
|
break;
|
||||||
//if (Aria.upload(this).loadFtp(mTaskId).isRunning()) {
|
}
|
||||||
// Aria.upload(this).loadFtp(mTaskId).stop();
|
if (Aria.upload(this).loadFtp(mTaskId).isRunning()) {
|
||||||
// getBinding().setStateStr(getString(R.string.resume));
|
Aria.upload(this).loadFtp(mTaskId).stop();
|
||||||
//} else {
|
getBinding().setStateStr(getString(R.string.resume));
|
||||||
// Aria.upload(this)
|
} else {
|
||||||
// .loadFtp(mTaskId)
|
Aria.upload(this)
|
||||||
// .option(getOption())
|
.loadFtp(mTaskId)
|
||||||
// .resume();
|
.option(getOption())
|
||||||
// getBinding().setStateStr(getString(R.string.stop));
|
.resume();
|
||||||
//}
|
getBinding().setStateStr(getString(R.string.stop));
|
||||||
upload();
|
}
|
||||||
|
//upload();
|
||||||
break;
|
break;
|
||||||
case R.id.cancel:
|
case R.id.cancel:
|
||||||
Aria.upload(this).loadFtp(mTaskId).cancel();
|
Aria.upload(this).loadFtp(mTaskId).cancel();
|
||||||
@@ -168,6 +171,7 @@ public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
|
|||||||
private FtpOption getOption() {
|
private FtpOption getOption() {
|
||||||
FtpOption option = new FtpOption();
|
FtpOption option = new FtpOption();
|
||||||
option.login(user, pwd);
|
option.login(user, pwd);
|
||||||
|
option.setUploadInterceptor(new FtpUploadInterceptor());
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,4 +240,13 @@ public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class FtpUploadInterceptor implements IFtpUploadInterceptor {
|
||||||
|
@Override public FtpInterceptHandler onIntercept(UploadEntity entity, List<String> fileList) {
|
||||||
|
FtpInterceptHandler.Builder builder = new FtpInterceptHandler.Builder();
|
||||||
|
//builder.coverServerFile(); // 覆盖远端同名文件
|
||||||
|
builder.resetFileName("test.zip"); //修改上传到远端服务器的文件名
|
||||||
|
return builder.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class UploadModule extends BaseViewModule {
|
|||||||
LiveData<UploadEntity> getFtpInfo(Context context) {
|
LiveData<UploadEntity> getFtpInfo(Context context) {
|
||||||
String url = AppUtil.getConfigValue(context, FTP_URL_KEY, "ftp://9.9.9.50:2121/aa/你好");
|
String url = AppUtil.getConfigValue(context, FTP_URL_KEY, "ftp://9.9.9.50:2121/aa/你好");
|
||||||
String filePath = AppUtil.getConfigValue(context, FTP_PATH_KEY,
|
String filePath = AppUtil.getConfigValue(context, FTP_PATH_KEY,
|
||||||
Environment.getExternalStorageDirectory().getPath() + "/Download/PaNTFS15562.zip");
|
Environment.getExternalStorageDirectory().getPath() + "/Download/Folx P58.zip");
|
||||||
|
|
||||||
UploadEntity entity = Aria.upload(context).getFirstUploadEntity(filePath);
|
UploadEntity entity = Aria.upload(context).getFirstUploadEntity(filePath);
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ task clean(type: Delete) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
versionCode = 375
|
versionCode = 376
|
||||||
versionName = '3.7.5'
|
versionName = '3.7.6'
|
||||||
userOrg = 'arialyy'
|
userOrg = 'arialyy'
|
||||||
groupId = 'com.arialyy.aria'
|
groupId = 'com.arialyy.aria'
|
||||||
publishVersion = versionName
|
publishVersion = versionName
|
||||||
|
|||||||
Reference in New Issue
Block a user