修复ftp组件出现的问题

This commit is contained in:
laoyuyu
2019-10-14 20:00:06 +08:00
parent 9f673503c1
commit ce408c0d5c
18 changed files with 122 additions and 64 deletions

View File

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

View File

@@ -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 {
BaseUListener(AbsTask<UTaskWrapper> task, Handler outHandler) {
public BaseUListener(AbsTask<UTaskWrapper> task, Handler outHandler) {
super(task, outHandler);
}

View File

@@ -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);
}
}

View File

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