[ali] add folder

This commit is contained in:
FongMi 2023-01-04 21:43:19 +08:00
parent 59f1030ed9
commit 12e3abd4ea
4 changed files with 17 additions and 9 deletions

View File

@ -6,6 +6,7 @@ import com.github.catvod.utils.Misc;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName; import com.google.gson.annotations.SerializedName;
import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -29,6 +30,8 @@ public class Item {
private String category; private String category;
@SerializedName("size") @SerializedName("size")
private double size; private double size;
@SerializedName("parent")
private String parent;
public static Item objectFrom(String str) { public static Item objectFrom(String str) {
return new Gson().fromJson(str, Item.class); return new Gson().fromJson(str, Item.class);
@ -50,10 +53,6 @@ public class Item {
return TextUtils.isEmpty(fileId) ? "" : fileId; return TextUtils.isEmpty(fileId) ? "" : fileId;
} }
public String getShareId() {
return TextUtils.isEmpty(shareId) ? "" : shareId;
}
public String getName() { public String getName() {
return TextUtils.isEmpty(name) ? "" : name; return TextUtils.isEmpty(name) ? "" : name;
} }
@ -70,12 +69,21 @@ public class Item {
return TextUtils.isEmpty(category) ? "" : category; return TextUtils.isEmpty(category) ? "" : category;
} }
public double getSize() { public String getSize() {
return size; return size == 0 ? "" : "[" + Misc.getSize(size) + "]";
}
public String getParent() {
return TextUtils.isEmpty(parent) ? "" : "[" + parent + "]";
}
public Item parent(String parent) {
this.parent = parent;
return this;
} }
public String getDisplayName() { public String getDisplayName() {
return getSize() == 0 ? getName() : "[" + Misc.getSize(getSize()) + "] " + getName(); return TextUtils.join(" ", Arrays.asList(getParent(), getName(), getSize())).trim();
} }
public String removeExt() { public String removeExt() {

View File

@ -155,7 +155,7 @@ public class Ali {
if (file.getType().equals("folder")) { if (file.getType().equals("folder")) {
folders.add(file); folders.add(file);
} else if (file.getCategory().equals("video") || file.getCategory().equals("audio")) { } else if (file.getCategory().equals("video") || file.getCategory().equals("audio")) {
files.add(file); files.add(file.parent(parent.getName()));
} else if (Misc.isSub(file.getExt())) { } else if (Misc.isSub(file.getExt())) {
String key = file.removeExt(); String key = file.removeExt();
if (!subMap.containsKey(key)) subMap.put(key, new ArrayList<>()); if (!subMap.containsKey(key)) subMap.put(key, new ArrayList<>());

Binary file not shown.

View File

@ -1 +1 @@
b6cec380ddab899d275cf2fec2ed676a b8cedd4dd751ac60b6fe87509d7b442c