修复重构loader后ftp模块的bug

This commit is contained in:
laoyuyu
2020-01-04 20:06:25 +08:00
parent c39bfbdd88
commit e14928e260
28 changed files with 141 additions and 85 deletions

View File

@@ -55,7 +55,7 @@ public class DbTestActivity extends BaseActivity<ActivityDbTestBinding> {
DownloadEntity entity = new DownloadEntity();
entity.setUrl(url);
entity.setFileName("ssssssssssssssssss");
entity.setDownloadPath(key);
entity.setFilePath(key);
DTaskWrapper dte = new DTaskWrapper(entity);

View File

@@ -129,7 +129,7 @@ public class DownloadModule extends BaseModule {
DownloadEntity entity = new DownloadEntity();
entity.setFileName(name);
entity.setUrl(downloadUrl);
entity.setDownloadPath(path);
entity.setFilePath(path);
return entity;
}
}

View File

@@ -28,6 +28,7 @@ import com.arialyy.aria.core.common.FtpOption;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.util.show.L;
import com.arialyy.frame.util.show.T;
@@ -48,7 +49,7 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
private String mUrl, mFilePath;
private FtpDownloadModule mModule;
private long mTaskId;
private String user = "boamax\\update", passw = "2020&suzhou";
private String user = "lao", passw = "123456";
@Override protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState);
@@ -124,7 +125,7 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
private FtpOption getFtpOption() {
FtpOption option = new FtpOption();
option.login(user, passw);
option.setServerIdentifier(FtpOption.FTPServerIdentifier.SYST_NT);
//option.setServerIdentifier(FtpOption.FTPServerIdentifier.SYST_NT);
//option.setConnectionMode(FtpConnectionMode.DATA_CONNECTION_MODE_ACTIVITY);
return option;
}
@@ -145,7 +146,7 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
}
@Download.onTaskPre() protected void onTaskPre(DownloadTask task) {
L.d(TAG, "ftp task pre");
L.d(TAG, "ftp task pre, fileSize = " + task.getConvertFileSize());
getBinding().setFileSize(task.getConvertFileSize());
}
@@ -154,6 +155,7 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
}
@Download.onTaskRunning() protected void running(DownloadTask task) {
ALog.d(TAG, "running, p = " + task.getPercent() + ", speed = " + task.getConvertSpeed());
getBinding().setProgress(task.getPercent());
getBinding().setSpeed(task.getConvertSpeed());
}
@@ -165,6 +167,7 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
@Download.onTaskStop() void taskStop(DownloadTask task) {
L.d(TAG, "ftp task stop");
getBinding().setSpeed("");
getBinding().setStateStr(getString(R.string.resume));
}
@Download.onTaskCancel() void taskCancel(DownloadTask task) {
@@ -174,12 +177,14 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
@Download.onTaskFail() void taskFail(DownloadTask task) {
L.d(TAG, "ftp task fail");
getBinding().setSpeed("");
getBinding().setStateStr(getString(R.string.resume));
}
@Download.onTaskComplete() void taskComplete(DownloadTask task) {
getBinding().setSpeed("");
getBinding().setProgress(100);
getBinding().setStateStr(getString(R.string.re_start));
Log.d(TAG, "md5 ==> " + CommonUtil.getFileMD5(new File(task.getFilePath())));
T.showShort(this, "文件:" + task.getEntity().getFileName() + ",下载完成");
}

View File

@@ -48,9 +48,8 @@ public class FtpDownloadModule extends BaseViewModule {
*/
LiveData<DownloadEntity> getFtpDownloadInfo(Context context) {
//String url = AppUtil.getConfigValue(context, FTP_URL_KEY, ftpDefUrl);
//String url = "ftp://9.9.9.72:2121/Cyberduck-6.9.4.30164.zip";
String url = "ftp://58.210.178.52:21/battery1.0.0.apk";
String filePath = AppUtil.getConfigValue(context, FTP_PATH_KEY, ftpDefPath);
//String filePath = AppUtil.getConfigValue(context, FTP_PATH_KEY, ftpDefPath);
String url = "ftp://9.9.9.72:2121/Cyberduck-6.9.4.30164.zip";
singDownloadInfo = Aria.download(context).getFirstDownloadEntity(url);
if (singDownloadInfo == null) {
@@ -58,7 +57,7 @@ public class FtpDownloadModule extends BaseViewModule {
singDownloadInfo.setUrl(url);
String name = getFileName(ftpDefUrl);
singDownloadInfo.setFileName(name);
singDownloadInfo.setFilePath(filePath + name);
singDownloadInfo.setFilePath(ftpDefPath + name);
} else {
AppUtil.setConfigValue(context, FTP_PATH_KEY, singDownloadInfo.getFilePath());
AppUtil.setConfigValue(context, FTP_URL_KEY, singDownloadInfo.getUrl());

View File

@@ -55,7 +55,7 @@ public class M3U8LiveModule extends BaseViewModule {
singDownloadInfo.setFilePath(filePath);
singDownloadInfo.setFileName(temp.getName());
} else {
AppUtil.setConfigValue(context, M3U8_LIVE_PATH_KEY, singDownloadInfo.getDownloadPath());
AppUtil.setConfigValue(context, M3U8_LIVE_PATH_KEY, singDownloadInfo.getFilePath());
AppUtil.setConfigValue(context, M3U8_LIVE_URL_KEY, singDownloadInfo.getUrl());
}
liveData.postValue(singDownloadInfo);

View File

@@ -76,7 +76,7 @@ public class AnyRunnModule {
}
@Download.onTaskComplete void taskComplete(DownloadTask task) {
L.d(TAG, "path ==> " + task.getDownloadEntity().getDownloadPath());
L.d(TAG, "path ==> " + task.getDownloadEntity().getFilePath());
L.d(TAG, "md5Code ==> " + CommonUtil.getFileMD5(new File(task.getFilePath())));
}

View File

@@ -74,7 +74,7 @@ public class SubStateLinearLayout extends LinearLayout implements View.OnClickLi
int i = 1;
for (DownloadEntity entity : datas) {
TextView view = createView(i - 1, entity);
mPosition.put(entity.getDownloadPath(), i);
mPosition.put(entity.getFilePath(), i);
addView(view, i);
i++;
}