Clean code
This commit is contained in:
parent
5bbdb7b036
commit
debb562648
|
|
@ -288,7 +288,7 @@ public class API {
|
||||||
} else if (file.getCategory().equals("video") || file.getCategory().equals("audio")) {
|
} else if (file.getCategory().equals("video") || file.getCategory().equals("audio")) {
|
||||||
files.add(file.parent(parent.getName()));
|
files.add(file.parent(parent.getName()));
|
||||||
} else if (Utils.isSub(file.getExt())) {
|
} else if (Utils.isSub(file.getExt())) {
|
||||||
String key = file.removeExt();
|
String key = Utils.removeExt(file.getName());
|
||||||
if (!subMap.containsKey(key)) subMap.put(key, new ArrayList<>());
|
if (!subMap.containsKey(key)) subMap.put(key, new ArrayList<>());
|
||||||
subMap.get(key).add(key + "@@@" + file.getExt() + "@@@" + file.getFileId());
|
subMap.get(key).add(key + "@@@" + file.getExt() + "@@@" + file.getFileId());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,4 @@ public class Item {
|
||||||
public String getDisplayName() {
|
public String getDisplayName() {
|
||||||
return TextUtils.join(" ", Arrays.asList(getParent(), getName(), getSize())).trim();
|
return TextUtils.join(" ", Arrays.asList(getParent(), getName(), getSize())).trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String removeExt() {
|
|
||||||
return getName().indexOf(".") > 0 ? getName().substring(0, getName().lastIndexOf(".")) : getName();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package com.github.catvod.bean.ali;
|
package com.github.catvod.bean.ali;
|
||||||
|
|
||||||
|
import com.github.catvod.utils.Utils;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -13,7 +15,7 @@ public class Sorter implements Comparator<Item> {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Item o1, Item o2) {
|
public int compare(Item o1, Item o2) {
|
||||||
try {
|
try {
|
||||||
return Integer.valueOf(o1.getDisplayName()).compareTo(Integer.valueOf(o2.getDisplayName()));
|
return Integer.valueOf(Utils.removeExt(o1.getDisplayName())).compareTo(Integer.valueOf(Utils.removeExt(o2.getDisplayName())));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
return o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName());
|
return o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ public class WebDAV extends Spider {
|
||||||
}
|
}
|
||||||
|
|
||||||
private String removeExt(DavResource item) {
|
private String removeExt(DavResource item) {
|
||||||
return item.getName().indexOf(".") > 0 ? item.getName().substring(0, item.getName().lastIndexOf(".")) : item.getName();
|
return Utils.removeExt(item.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Drive getDrive(String name) {
|
private static Drive getDrive(String name) {
|
||||||
|
|
|
||||||
|
|
@ -70,6 +70,10 @@ public class Utils {
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String removeExt(String text) {
|
||||||
|
return text.contains(".") ? text.substring(0, text.lastIndexOf(".")) : text;
|
||||||
|
}
|
||||||
|
|
||||||
public static String substring(String text) {
|
public static String substring(String text) {
|
||||||
return substring(text, 1);
|
return substring(text, 1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
dc64f1fe003adcd9916ee38638684376
|
d255d424916b37d2329cbfd8dd8b2119
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue