support get task name

This commit is contained in:
NikoXu 2025-02-12 09:56:47 +00:00
parent c7110a15ea
commit 6e32270dc6

View File

@ -1,6 +1,7 @@
package cn.montaro.aria2.bean;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
public class Task implements Serializable {
@ -17,6 +18,35 @@ public class Task implements Serializable {
private String status;
private String dir;
private List<TaskFile> files;
static class TaskFile {
String path;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
}
public String getName() {
if (Objects.isNull(dir) || this.files.isEmpty()) {
return "";
}
String name = files.get(0).path.replace(dir + "/", "");
String substring = name.substring(0, 23);
if (name.length() > 25) {
substring = substring + "...";
}
return substring;
}
public int getProgress() {
if (Objects.isNull(completedLength)
|| completedLength == 0