* fix: Ignore invalid files Avoid NullPointerException when using "Open files" or drag-n-drop * refactor: Replace Stream API chain with loop IntelliJ * fix: Ignore invalid files Avoid NullPointerException when using "Add files" * fix: Fall back to complete path string Instead of empty project name * fix: Render tree Project tree (sidebar) didn’t load Toggling "View > Show flatten packages" threw a NPE here * fix code formatting --------- Co-authored-by: Skylot <skylot@gmail.com>
This commit is contained in:
@@ -10,6 +10,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.StringJoiner;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -113,11 +114,19 @@ public class JadxProject {
|
||||
} else {
|
||||
Collections.sort(files);
|
||||
data.setFiles(files);
|
||||
String joinedName = files.stream()
|
||||
.map(p -> p.getFileName().toString())
|
||||
.filter(file -> !file.endsWith(".jadx.kts"))
|
||||
.map(CommonFileUtils::removeFileExtension)
|
||||
.collect(Collectors.joining("_"));
|
||||
StringJoiner joiner = new StringJoiner("_");
|
||||
for (Path p : files) {
|
||||
Path fileNamePart = p.getFileName();
|
||||
if (fileNamePart == null) {
|
||||
joiner.add(p.toString());
|
||||
continue;
|
||||
}
|
||||
String fileName = fileNamePart.toString();
|
||||
if (!fileName.endsWith(".jadx.kts")) {
|
||||
joiner.add(CommonFileUtils.removeFileExtension(fileName));
|
||||
}
|
||||
}
|
||||
String joinedName = joiner.toString();
|
||||
name = StringUtils.abbreviate(joinedName, 100);
|
||||
}
|
||||
changed();
|
||||
|
||||
@@ -173,7 +173,11 @@ public class JRoot extends JNode {
|
||||
return "File not open";
|
||||
}
|
||||
if (count == 1) {
|
||||
return paths.get(0).getFileName().toString();
|
||||
Path fileNamePath = paths.get(0).getFileName();
|
||||
if (fileNamePath != null) {
|
||||
return fileNamePath.toString();
|
||||
}
|
||||
return paths.get(0).toString();
|
||||
}
|
||||
return count + " files";
|
||||
}
|
||||
|
||||
@@ -460,6 +460,9 @@ public class MainWindow extends JFrame {
|
||||
}
|
||||
|
||||
private boolean openSingleFile(Path singleFile, Runnable onFinish) {
|
||||
if (singleFile.getFileName() == null) {
|
||||
return false;
|
||||
}
|
||||
String fileExtension = CommonFileUtils.getFileExtension(singleFile.getFileName().toString());
|
||||
if (fileExtension != null && fileExtension.equalsIgnoreCase(JadxProject.PROJECT_EXTENSION)) {
|
||||
openProject(singleFile, onFinish);
|
||||
|
||||
Reference in New Issue
Block a user