修复ftp组件出现的问题

pull/617/head
laoyuyu 5 years ago
parent 9f673503c1
commit ce408c0d5c
  1. 2
      FtpComponent/src/main/java/com/arialyy/aria/ftp/BaseFtpThreadTaskAdapter.java
  2. 9
      FtpComponent/src/main/java/com/arialyy/aria/ftp/FtpDirInfoThread.java
  3. 7
      FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDLoaderUtil.java
  4. 22
      FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDirDLoaderUtil.java
  5. 8
      FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpSubDLoaderUtil.java
  6. 8
      FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpULoaderUtil.java
  7. 4
      HttpComponent/src/main/java/com/arialyy/aria/http/download/DGroupLoaderUtil.java
  8. 12
      HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpSubDLoaderUtil.java
  9. 6
      PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupUtil.java
  10. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/listener/BaseUListener.java
  11. 50
      PublicComponent/src/main/java/com/arialyy/aria/core/processor/ProxyHandler.java
  12. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/wrapper/AbsTaskWrapper.java
  13. 1
      app/build.gradle
  14. 9
      app/src/main/java/com/arialyy/simple/core/download/FtpDownloadActivity.java
  15. 4
      app/src/main/java/com/arialyy/simple/core/download/FtpDownloadModule.java
  16. 9
      app/src/main/java/com/arialyy/simple/core/download/group/FTPDirDownloadActivity.java
  17. 23
      app/src/main/java/com/arialyy/simple/core/upload/FtpUploadActivity.java
  18. 4
      app/src/main/java/com/arialyy/simple/core/upload/UploadModule.java

@ -43,7 +43,7 @@ public abstract class BaseFtpThreadTaskAdapter extends AbsThreadTaskAdapter {
protected BaseFtpThreadTaskAdapter(SubThreadConfig config) { protected BaseFtpThreadTaskAdapter(SubThreadConfig config) {
super(config); super(config);
mTaskOption = (FtpTaskOption) getTaskWrapper().getTaskOption();
} }
protected void closeClient(FTPClient client) { protected void closeClient(FTPClient client) {

@ -91,10 +91,17 @@ public class FtpDirInfoThread extends AbsFtpInfoThread<DownloadGroupEntity, DGTa
} }
private void cloneInfo(DTaskWrapper subWrapper, FtpUrlEntity urlEntity) { private void cloneInfo(DTaskWrapper subWrapper, FtpUrlEntity urlEntity) {
FtpTaskOption subOption = (FtpTaskOption) subWrapper.getTaskOption(); FtpTaskOption subOption = new FtpTaskOption();
subOption.setUrlEntity(urlEntity); subOption.setUrlEntity(urlEntity);
subOption.setCharSet(mTaskOption.getCharSet()); subOption.setCharSet(mTaskOption.getCharSet());
subOption.setProxy(mTaskOption.getProxy()); subOption.setProxy(mTaskOption.getProxy());
subOption.setClientConfig(mTaskOption.getClientConfig());
subOption.setNewFileName(mTaskOption.getNewFileName());
subOption.setProxy(mTaskOption.getProxy());
subOption.setUploadInterceptor(mTaskOption.getUploadInterceptor());
subWrapper.setTaskOption(subOption);
} }
@Override protected void failDownload(BaseException e, boolean needRetry) { @Override protected void failDownload(BaseException e, boolean needRetry) {

@ -19,10 +19,11 @@ import com.arialyy.aria.core.common.AbsEntity;
import com.arialyy.aria.core.common.CompleteInfo; import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.inf.OnFileInfoCallback; import com.arialyy.aria.core.inf.OnFileInfoCallback;
import com.arialyy.aria.core.listener.IDLoadListener; import com.arialyy.aria.core.listener.IEventListener;
import com.arialyy.aria.core.loader.AbsLoader; import com.arialyy.aria.core.loader.AbsLoader;
import com.arialyy.aria.core.loader.AbsNormalLoaderUtil; import com.arialyy.aria.core.loader.AbsNormalLoaderUtil;
import com.arialyy.aria.core.loader.NormalLoader; import com.arialyy.aria.core.loader.NormalLoader;
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;
@ -32,8 +33,8 @@ import com.arialyy.aria.ftp.FtpTaskOption;
*/ */
public class FtpDLoaderUtil extends AbsNormalLoaderUtil { public class FtpDLoaderUtil extends AbsNormalLoaderUtil {
public FtpDLoaderUtil(DTaskWrapper wrapper, IDLoadListener downloadListener) { public FtpDLoaderUtil(AbsTaskWrapper wrapper, IEventListener listener) {
super(wrapper, downloadListener); super(wrapper, listener);
wrapper.generateTaskOption(FtpTaskOption.class); wrapper.generateTaskOption(FtpTaskOption.class);
} }

@ -20,16 +20,16 @@ import android.text.TextUtils;
import com.arialyy.aria.core.FtpUrlEntity; import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.common.AbsEntity; import com.arialyy.aria.core.common.AbsEntity;
import com.arialyy.aria.core.common.CompleteInfo; import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.download.DGTaskWrapper;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.group.AbsGroupUtil;
import com.arialyy.aria.core.group.AbsSubDLoadUtil;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.inf.OnFileInfoCallback; import com.arialyy.aria.core.inf.OnFileInfoCallback;
import com.arialyy.aria.core.listener.IEventListener;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.exception.BaseException; import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.ftp.FtpDirInfoThread; import com.arialyy.aria.ftp.FtpDirInfoThread;
import com.arialyy.aria.ftp.FtpTaskOption; import com.arialyy.aria.ftp.FtpTaskOption;
import com.arialyy.aria.core.group.AbsGroupUtil;
import com.arialyy.aria.core.group.AbsSubDLoadUtil;
import com.arialyy.aria.core.listener.IDGroupListener;
import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
@ -41,14 +41,14 @@ public class FtpDirDLoaderUtil extends AbsGroupUtil {
private ReentrantLock LOCK = new ReentrantLock(); private ReentrantLock LOCK = new ReentrantLock();
private Condition condition = LOCK.newCondition(); private Condition condition = LOCK.newCondition();
public FtpDirDLoaderUtil(IDGroupListener listener, DGTaskWrapper wrapper) { public FtpDirDLoaderUtil(AbsTaskWrapper wrapper, IEventListener listener) {
super(listener, wrapper); super(wrapper, listener);
wrapper.generateTaskOption(FtpTaskOption.class); wrapper.generateTaskOption(FtpTaskOption.class);
} }
@Override @Override
protected AbsSubDLoadUtil createSubLoader(DTaskWrapper wrapper, boolean needGetFileInfo) { protected AbsSubDLoadUtil createSubLoader(DTaskWrapper wrapper, boolean needGetFileInfo) {
return new SubDLoaderUtil(getScheduler(), wrapper, needGetFileInfo); return new FtpSubDLoaderUtil(getScheduler(), wrapper, needGetFileInfo);
} }
@Override protected boolean onStart() { @Override protected boolean onStart() {
@ -109,9 +109,15 @@ public class FtpDirDLoaderUtil extends AbsGroupUtil {
String remotePath = uri.getPath(); String remotePath = uri.getPath();
urlEntity.remotePath = TextUtils.isEmpty(remotePath) ? "/" : remotePath; urlEntity.remotePath = TextUtils.isEmpty(remotePath) ? "/" : remotePath;
FtpTaskOption subOption = ((FtpTaskOption) subWrapper.getTaskOption()); FtpTaskOption subOption = new FtpTaskOption();
subOption.setUrlEntity(urlEntity); subOption.setUrlEntity(urlEntity);
subOption.setCharSet(option.getCharSet()); subOption.setCharSet(option.getCharSet());
subOption.setProxy(option.getProxy()); subOption.setProxy(option.getProxy());
subOption.setClientConfig(option.getClientConfig());
subOption.setNewFileName(option.getNewFileName());
subOption.setProxy(option.getProxy());
subOption.setUploadInterceptor(option.getUploadInterceptor());
subWrapper.setTaskOption(subOption);
} }
} }

@ -17,23 +17,21 @@ package com.arialyy.aria.ftp.download;
import android.os.Handler; import android.os.Handler;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.loader.NormalLoader;
import com.arialyy.aria.ftp.FtpTaskOption;
import com.arialyy.aria.core.group.AbsSubDLoadUtil; import com.arialyy.aria.core.group.AbsSubDLoadUtil;
import com.arialyy.aria.core.group.ChildDLoadListener; import com.arialyy.aria.core.group.ChildDLoadListener;
import com.arialyy.aria.core.loader.NormalLoader;
/** /**
* @Author lyy * @Author lyy
* @Date 2019-09-28 * @Date 2019-09-28
*/ */
class SubDLoaderUtil extends AbsSubDLoadUtil { class FtpSubDLoaderUtil extends AbsSubDLoadUtil {
/** /**
* @param schedulers 调度器 * @param schedulers 调度器
* @param needGetInfo {@code true} 需要获取文件信息{@code false} 不需要获取文件信息 * @param needGetInfo {@code true} 需要获取文件信息{@code false} 不需要获取文件信息
*/ */
SubDLoaderUtil(Handler schedulers, DTaskWrapper taskWrapper, boolean needGetInfo) { FtpSubDLoaderUtil(Handler schedulers, DTaskWrapper taskWrapper, boolean needGetInfo) {
super(schedulers, taskWrapper, needGetInfo); super(schedulers, taskWrapper, needGetInfo);
taskWrapper.generateTaskOption(FtpTaskOption.class);
} }
@Override protected NormalLoader createLoader(ChildDLoadListener listener, DTaskWrapper wrapper) { @Override protected NormalLoader createLoader(ChildDLoadListener listener, DTaskWrapper wrapper) {

@ -19,11 +19,13 @@ import com.arialyy.aria.core.common.AbsEntity;
import com.arialyy.aria.core.common.CompleteInfo; import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.inf.OnFileInfoCallback; import com.arialyy.aria.core.inf.OnFileInfoCallback;
import com.arialyy.aria.core.listener.IEventListener;
import com.arialyy.aria.core.listener.IUploadListener; import com.arialyy.aria.core.listener.IUploadListener;
import com.arialyy.aria.core.loader.AbsLoader; import com.arialyy.aria.core.loader.AbsLoader;
import com.arialyy.aria.core.loader.AbsNormalLoaderUtil; import com.arialyy.aria.core.loader.AbsNormalLoaderUtil;
import com.arialyy.aria.core.loader.NormalLoader; import com.arialyy.aria.core.loader.NormalLoader;
import com.arialyy.aria.core.upload.UTaskWrapper; import com.arialyy.aria.core.upload.UTaskWrapper;
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;
@ -33,15 +35,15 @@ import com.arialyy.aria.ftp.FtpTaskOption;
*/ */
public class FtpULoaderUtil extends AbsNormalLoaderUtil { public class FtpULoaderUtil extends AbsNormalLoaderUtil {
public FtpULoaderUtil(DTaskWrapper wrapper, IUploadListener uploadListener) { public FtpULoaderUtil(AbsTaskWrapper wrapper, IEventListener listener) {
super(wrapper, uploadListener); super(wrapper, listener);
wrapper.generateTaskOption(FtpTaskOption.class); wrapper.generateTaskOption(FtpTaskOption.class);
} }
@Override protected AbsLoader createLoader() { @Override protected AbsLoader createLoader() {
NormalLoader loader = new NormalLoader(getListener(), getTaskWrapper()); NormalLoader loader = new NormalLoader(getListener(), getTaskWrapper());
loader.setAdapter(new FtpULoaferAdapter(getTaskWrapper())); loader.setAdapter(new FtpULoaferAdapter(getTaskWrapper()));
return null; return loader;
} }
@Override protected Runnable createInfoThread() { @Override protected Runnable createInfoThread() {

@ -17,7 +17,6 @@ package com.arialyy.aria.http.download;
import com.arialyy.aria.core.common.AbsEntity; import com.arialyy.aria.core.common.AbsEntity;
import com.arialyy.aria.core.common.CompleteInfo; import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.download.DGTaskWrapper;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
@ -28,7 +27,6 @@ import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.BaseException; import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.core.group.AbsGroupUtil; import com.arialyy.aria.core.group.AbsGroupUtil;
import com.arialyy.aria.core.group.AbsSubDLoadUtil; import com.arialyy.aria.core.group.AbsSubDLoadUtil;
import com.arialyy.aria.core.listener.IDGroupListener;
import com.arialyy.aria.http.HttpFileInfoThread; import com.arialyy.aria.http.HttpFileInfoThread;
import com.arialyy.aria.http.HttpTaskOption; import com.arialyy.aria.http.HttpTaskOption;
import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.ALog;
@ -55,7 +53,7 @@ public class DGroupLoaderUtil extends AbsGroupUtil {
@Override @Override
protected AbsSubDLoadUtil createSubLoader(DTaskWrapper wrapper, boolean needGetFileInfo) { protected AbsSubDLoadUtil createSubLoader(DTaskWrapper wrapper, boolean needGetFileInfo) {
return new SubDLoaderUtil(getScheduler(), wrapper, needGetFileInfo); return new HttpSubDLoaderUtil(getScheduler(), wrapper, needGetFileInfo);
} }
@Override public void onPreCancel() { @Override public void onPreCancel() {

@ -19,27 +19,25 @@ import android.os.Handler;
import com.arialyy.aria.core.common.AbsEntity; import com.arialyy.aria.core.common.AbsEntity;
import com.arialyy.aria.core.common.CompleteInfo; import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.group.AbsSubDLoadUtil;
import com.arialyy.aria.core.group.ChildDLoadListener;
import com.arialyy.aria.core.inf.OnFileInfoCallback; import com.arialyy.aria.core.inf.OnFileInfoCallback;
import com.arialyy.aria.core.listener.ISchedulers; import com.arialyy.aria.core.listener.ISchedulers;
import com.arialyy.aria.core.loader.NormalLoader; import com.arialyy.aria.core.loader.NormalLoader;
import com.arialyy.aria.exception.BaseException; import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.core.group.AbsSubDLoadUtil;
import com.arialyy.aria.core.group.ChildDLoadListener;
import com.arialyy.aria.http.HttpFileInfoThread; import com.arialyy.aria.http.HttpFileInfoThread;
import com.arialyy.aria.http.HttpTaskOption;
/** /**
* @Author lyy * @Author lyy
* @Date 2019-09-28 * @Date 2019-09-28
*/ */
class SubDLoaderUtil extends AbsSubDLoadUtil { class HttpSubDLoaderUtil extends AbsSubDLoadUtil {
/** /**
* @param schedulers 调度器 * @param schedulers 调度器
* @param needGetInfo {@code true} 需要获取文件信息{@code false} 不需要获取文件信息 * @param needGetInfo {@code true} 需要获取文件信息{@code false} 不需要获取文件信息
*/ */
SubDLoaderUtil(Handler schedulers, DTaskWrapper taskWrapper, boolean needGetInfo) { HttpSubDLoaderUtil(Handler schedulers, DTaskWrapper taskWrapper, boolean needGetInfo) {
super(schedulers, taskWrapper, needGetInfo); super(schedulers, taskWrapper, needGetInfo);
taskWrapper.generateTaskOption(HttpTaskOption.class);
} }
@Override protected NormalLoader createLoader(ChildDLoadListener listener, DTaskWrapper wrapper) { @Override protected NormalLoader createLoader(ChildDLoadListener listener, DTaskWrapper wrapper) {
@ -58,7 +56,7 @@ class SubDLoaderUtil extends AbsSubDLoadUtil {
} }
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
getSchedulers().obtainMessage(ISchedulers.FAIL, SubDLoaderUtil.this).sendToTarget(); getSchedulers().obtainMessage(ISchedulers.FAIL, HttpSubDLoaderUtil.this).sendToTarget();
} }
})).start(); })).start();
} else { } else {

@ -55,9 +55,6 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
mListener = (IDGroupListener) listener; mListener = (IDGroupListener) listener;
mGTWrapper = (DGTaskWrapper) groupWrapper; mGTWrapper = (DGTaskWrapper) groupWrapper;
mUpdateInterval = Configuration.getInstance().downloadCfg.getUpdateInterval(); mUpdateInterval = Configuration.getInstance().downloadCfg.getUpdateInterval();
mState = new GroupRunState(groupWrapper.getKey(), mListener,
mGTWrapper.getSubTaskWrapper().size(), mSubQueue);
mScheduler = new Handler(Looper.getMainLooper(), SimpleSchedulers.newInstance(mState));
initState(); initState();
} }
@ -84,6 +81,8 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
* 初始化组合任务状态 * 初始化组合任务状态
*/ */
protected void initState() { protected void initState() {
mState = new GroupRunState(getWrapper().getKey(), mListener,
mGTWrapper.getSubTaskWrapper().size(), mSubQueue);
for (DTaskWrapper wrapper : mGTWrapper.getSubTaskWrapper()) { for (DTaskWrapper wrapper : mGTWrapper.getSubTaskWrapper()) {
if (wrapper.getEntity().getState() == IEntity.STATE_COMPLETE) { if (wrapper.getEntity().getState() == IEntity.STATE_COMPLETE) {
mState.updateCompleteNum(); mState.updateCompleteNum();
@ -94,6 +93,7 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
} }
} }
mState.updateProgress(mCurrentLocation); mState.updateProgress(mCurrentLocation);
mScheduler = new Handler(Looper.getMainLooper(), SimpleSchedulers.newInstance(mState));
} }
@Override public String getKey() { @Override public String getKey() {

@ -27,10 +27,10 @@ import com.arialyy.aria.util.RecordUtil;
/** /**
* 下载监听类 * 下载监听类
*/ */
class BaseUListener extends BaseListener<UploadEntity, UTaskWrapper, AbsTask<UTaskWrapper>> public class BaseUListener extends BaseListener<UploadEntity, UTaskWrapper, AbsTask<UTaskWrapper>>
implements IUploadListener { implements IUploadListener {
BaseUListener(AbsTask<UTaskWrapper> task, Handler outHandler) { public BaseUListener(AbsTask<UTaskWrapper> task, Handler outHandler) {
super(task, outHandler); super(task, outHandler);
} }

@ -0,0 +1,50 @@
/*
* 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.processor;
import com.arialyy.aria.core.inf.IEventHandler;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/**
* @Author lyy
* @Date 2019-10-7
* 处理器的动态代理
*/
public class ProxyHandler implements InvocationHandler {
private Object mTarget;
/**
* 绑定代理对象并返回代理类
*/
public Object bind(Class<? extends IEventHandler> clazz) {
//绑定该类实现的所有接口,取得代理类
try {
mTarget = clazz.newInstance();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InstantiationException e) {
e.printStackTrace();
}
return Proxy.newProxyInstance(clazz.getClassLoader(), clazz.getInterfaces(), this);
}
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
return method.invoke(mTarget, args);
}
}

@ -84,6 +84,10 @@ public abstract class AbsTaskWrapper<ENTITY extends AbsEntity>
*/ */
private TaskOptionParams optionParams = new TaskOptionParams(); private TaskOptionParams optionParams = new TaskOptionParams();
public void setTaskOption(ITaskOption option) {
this.taskOption = option;
}
public ITaskOption getTaskOption() { public ITaskOption getTaskOption() {
return taskOption; return taskOption;
} }

@ -74,6 +74,7 @@ dependencies {
implementation 'com.pddstudio:highlightjs-android:1.5.0' implementation 'com.pddstudio:highlightjs-android:1.5.0'
implementation 'org.greenrobot:eventbus:3.1.1' implementation 'org.greenrobot:eventbus:3.1.1'
implementation project(path: ':M3U8Component') implementation project(path: ':M3U8Component')
implementation project(path: ':FtpComponent')
} }
repositories { repositories {
mavenCentral() mavenCentral()

@ -48,7 +48,7 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
private String mUrl, mFilePath; private String mUrl, mFilePath;
private FtpDownloadModule mModule; private FtpDownloadModule mModule;
private long mTaskId; private long mTaskId;
private String user = "tester", passw = "password"; private String user = "lao", passw = "123456";
@Override protected void init(Bundle savedInstanceState) { @Override protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState); super.init(savedInstanceState);
@ -96,9 +96,8 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
mTaskId = Aria.download(this).loadFtp(mUrl) mTaskId = Aria.download(this).loadFtp(mUrl)
.setFilePath(mFilePath, true) .setFilePath(mFilePath, true)
.option() .option()
//.login("lao", "123456")
.login(user, passw) .login(user, passw)
.asFtps() //.asFtps()
.controller(ControllerType.CREATE_CONTROLLER) .controller(ControllerType.CREATE_CONTROLLER)
.create(); .create();
getBinding().setStateStr(getString(R.string.stop)); getBinding().setStateStr(getString(R.string.stop));
@ -112,8 +111,8 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
.loadFtp(mTaskId) .loadFtp(mTaskId)
.option() .option()
.login(user, passw) .login(user, passw)
.asFtps() //.asFtps()
.setProtocol(ProtocolType.SSL) //.setProtocol(ProtocolType.SSL)
.controller(ControllerType.TASK_CONTROLLER) .controller(ControllerType.TASK_CONTROLLER)
.resume(); .resume();
getBinding().setStateStr(getString(R.string.stop)); getBinding().setStateStr(getString(R.string.stop));

@ -33,7 +33,7 @@ public class FtpDownloadModule extends BaseViewModule {
private final String FTP_URL_KEY = "FTP_URL_KEY"; private final String FTP_URL_KEY = "FTP_URL_KEY";
private final String FTP_PATH_KEY = "FTP_PATH_KEY"; private final String FTP_PATH_KEY = "FTP_PATH_KEY";
private final String ftpDefUrl = "ftp://9.9.9.50:22/Cyberduck-6.9.4.30164.zip"; private final String ftpDefUrl = "ftp://9.9.9.50:2121/Cyberduck-6.9.4.30164.zip";
private final String ftpDefPath = private final String ftpDefPath =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath(); Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath();
@ -43,6 +43,8 @@ public class FtpDownloadModule extends BaseViewModule {
/** /**
* xx * xx
* 单任务下载的信息 * 单任务下载的信息
*
*
*/ */
LiveData<DownloadEntity> getFtpDownloadInfo(Context context) { LiveData<DownloadEntity> getFtpDownloadInfo(Context context) {
String url = AppUtil.getConfigValue(context, FTP_URL_KEY, ftpDefUrl); String url = AppUtil.getConfigValue(context, FTP_URL_KEY, ftpDefUrl);

@ -35,10 +35,11 @@ import com.arialyy.simple.widget.SubStateLinearLayout;
* Created by lyy on 2017/7/6. * Created by lyy on 2017/7/6.
*/ */
public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBinding> { public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBinding> {
private static final String dir = "ftp://9.9.9.205:2121/upload/测试"; private static final String dir = "ftp://9.9.9.50:2121/upload/测试";
private SubStateLinearLayout mChildList; private SubStateLinearLayout mChildList;
private long mTaskId = -1; private long mTaskId = -1;
private String user = "lao", pwd = "123456";
@Override protected void init(Bundle savedInstanceState) { @Override protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState); super.init(savedInstanceState);
@ -78,7 +79,7 @@ public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBi
Environment.getExternalStorageDirectory().getPath() + "/Download/ftp_dir") Environment.getExternalStorageDirectory().getPath() + "/Download/ftp_dir")
.setGroupAlias("ftp文件夹下载") .setGroupAlias("ftp文件夹下载")
.option() .option()
.login("8L8e", "8guD") .login(user, pwd)
.controller(ControllerType.CREATE_CONTROLLER) .controller(ControllerType.CREATE_CONTROLLER)
.create(); .create();
getBinding().setStateStr(getString(R.string.stop)); getBinding().setStateStr(getString(R.string.stop));
@ -91,7 +92,7 @@ public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBi
Aria.download(this) Aria.download(this)
.loadFtpDir(mTaskId) .loadFtpDir(mTaskId)
.option() .option()
.login("8L8e", "8guD") .login(user, pwd)
.controller(ControllerType.TASK_CONTROLLER) .controller(ControllerType.TASK_CONTROLLER)
.resume(); .resume();
getBinding().setStateStr(getString(R.string.stop)); getBinding().setStateStr(getString(R.string.stop));
@ -144,6 +145,8 @@ public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBi
@DownloadGroup.onTaskComplete() void taskComplete(DownloadGroupTask task) { @DownloadGroup.onTaskComplete() void taskComplete(DownloadGroupTask task) {
getBinding().setProgress(100); getBinding().setProgress(100);
mChildList.updateChildProgress(task.getEntity().getSubEntities()); mChildList.updateChildProgress(task.getEntity().getSubEntities());
getBinding().setStateStr(getString(R.string.re_start));
getBinding().setSpeed("");
T.showShort(this, "任务组下载完成"); T.showShort(this, "任务组下载完成");
L.d(TAG, "任务组下载完成"); L.d(TAG, "任务组下载完成");
} }

@ -25,12 +25,12 @@ import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders; import androidx.lifecycle.ViewModelProviders;
import com.arialyy.annotations.Upload; import com.arialyy.annotations.Upload;
import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.processor.FtpInterceptHandler;
import com.arialyy.aria.core.processor.IFtpUploadInterceptor;
import com.arialyy.aria.core.common.controller.ControllerType; import com.arialyy.aria.core.common.controller.ControllerType;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.upload.UploadEntity; 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.util.ALog; import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.util.FileUtil; import com.arialyy.frame.util.FileUtil;
@ -53,6 +53,7 @@ public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
private String mUrl; private String mUrl;
private UploadModule mModule; private UploadModule mModule;
private long mTaskId = -1; private long mTaskId = -1;
private String user = "lao", pwd = "123456";
@Override protected void init(Bundle savedInstanceState) { @Override protected void init(Bundle savedInstanceState) {
setTile("D_FTP 文件上传"); setTile("D_FTP 文件上传");
@ -117,20 +118,8 @@ public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
mTaskId = Aria.upload(this) mTaskId = Aria.upload(this)
.loadFtp(mFilePath) .loadFtp(mFilePath)
.setUploadUrl(mUrl) .setUploadUrl(mUrl)
.setUploadInterceptor(
new 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();
}
})
.option() .option()
.login("8L8e", "8guD") .login(user, pwd)
.controller(ControllerType.CREATE_CONTROLLER) .controller(ControllerType.CREATE_CONTROLLER)
.create(); .create();
getBinding().setStateStr(getString(R.string.stop)); getBinding().setStateStr(getString(R.string.stop));
@ -143,7 +132,7 @@ public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
Aria.upload(this) Aria.upload(this)
.loadFtp(mTaskId) .loadFtp(mTaskId)
.option() .option()
.login("8L8e", "8guD") .login(user, pwd)
.controller(ControllerType.TASK_CONTROLLER) .controller(ControllerType.TASK_CONTROLLER)
.resume(); .resume();
getBinding().setStateStr(getString(R.string.stop)); getBinding().setStateStr(getString(R.string.stop));

@ -35,9 +35,9 @@ public class UploadModule extends BaseViewModule {
* 获取Ftp上传信息 * 获取Ftp上传信息
*/ */
LiveData<UploadEntity> getFtpInfo(Context context) { LiveData<UploadEntity> getFtpInfo(Context context) {
String url = AppUtil.getConfigValue(context, FTP_URL_KEY, "ftp://9.9.9.205: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() + "/AriaPrj.rar"); Environment.getExternalStorageDirectory().getPath() + "/Download/PaNTFS15562.zip");
UploadEntity entity = Aria.upload(context).getFirstUploadEntity(filePath); UploadEntity entity = Aria.upload(context).getFirstUploadEntity(filePath);
if (entity != null) { if (entity != null) {

Loading…
Cancel
Save