Improve calculation algorithm of memory usage / fix "used memory of Hillshade doesn't calculated"

This commit is contained in:
nazar-kutz 2021-02-02 10:13:01 +02:00
parent 8f302f8558
commit bba9ed1f26

View file

@ -99,16 +99,19 @@ public class RefreshUsedMemoryTask extends AsyncTask<MemoryItem, Void, Void> {
for (MemoryItem memoryItem : items) { for (MemoryItem memoryItem : items) {
DirectoryItem[] targetDirectories = memoryItem.getDirectories(); DirectoryItem[] targetDirectories = memoryItem.getDirectories();
if (targetDirectories != null) { if (targetDirectories != null) {
for (DirectoryItem targetDirectory : targetDirectories) { for (DirectoryItem dir : targetDirectories) {
String allowedDirPath = targetDirectory.getAbsolutePath(); String allowedDirPath = dir.getAbsolutePath();
if (objectEquals(directoryPath, allowedDirPath) boolean isPerfectlyMatch = objectEquals(directoryPath, allowedDirPath);
|| (directoryPath.startsWith(allowedDirPath))) { boolean isParentDirectory = !isPerfectlyMatch && (directoryPath.startsWith(allowedDirPath));
if (targetDirectory.shouldProcessInternalDirectories()) { boolean isMatchDirectory = isPerfectlyMatch || isParentDirectory;
calculateMultiTypes(directory, items); if (isPerfectlyMatch) {
return; calculateMultiTypes(directory, items);
} else if (!targetDirectory.shouldAddUnmatchedToOtherMemory()) { return;
return; } else if (isParentDirectory && dir.shouldProcessInternalDirectories()) {
} calculateMultiTypes(directory, items);
return;
} else if (isMatchDirectory && !dir.shouldAddUnmatchedToOtherMemory()) {
return;
} }
} }
} }
@ -122,7 +125,7 @@ public class RefreshUsedMemoryTask extends AsyncTask<MemoryItem, Void, Void> {
@NonNull MemoryItem... items) { @NonNull MemoryItem... items) {
for (MemoryItem item : items) { for (MemoryItem item : items) {
DirectoryItem[] targetDirectories = item.getDirectories(); DirectoryItem[] targetDirectories = item.getDirectories();
if (targetDirectories == null) continue; if (targetDirectories == null) return;
String rootDirPath = rootDir.getAbsolutePath(); String rootDirPath = rootDir.getAbsolutePath();
for (DirectoryItem targetDirectory : targetDirectories) { for (DirectoryItem targetDirectory : targetDirectories) {