Refactor ONE_MEGABYTE
This commit is contained in:
parent
eceed1e979
commit
feaa0802a8
|
@ -109,7 +109,7 @@ public class AutoDetection {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (VIDEO_FILES.accept(f)) {
|
||||
if (VIDEO_FILES.accept(f) && f.length() > ONE_MEGABYTE) {
|
||||
// check for Japanese audio or characteristic subtitles
|
||||
try (MediaInfo mi = new MediaInfo().open(f)) {
|
||||
long minutes = Duration.ofMillis(Long.parseLong(mi.get(StreamKind.General, 0, "Duration"))).toMinutes();
|
||||
|
|
|
@ -1097,7 +1097,7 @@ public class MediaDetection {
|
|||
}
|
||||
|
||||
filesByMediaFolder.stream().collect(groupingBy(f -> {
|
||||
if (VIDEO_FILES.accept(f) && f.length() > 0) {
|
||||
if (VIDEO_FILES.accept(f) && f.length() > ONE_MEGABYTE) {
|
||||
try (MediaInfo mi = new MediaInfo().open(f)) {
|
||||
String v = mi.get(StreamKind.Video, 0, "Codec");
|
||||
String a = mi.get(StreamKind.Audio, 0, "Codec");
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package net.filebot.ui.filter;
|
||||
|
||||
import static net.filebot.util.FileUtilities.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -17,7 +19,6 @@ import javax.swing.tree.TreeNode;
|
|||
|
||||
import net.filebot.ui.filter.FileTree.FolderNode;
|
||||
import net.filebot.ui.transfer.DefaultTransferHandler;
|
||||
import net.filebot.util.FileUtilities;
|
||||
import net.filebot.util.ui.GradientStyle;
|
||||
import net.filebot.util.ui.LoadingOverlayPane;
|
||||
import net.filebot.util.ui.notification.SeparatorBorder;
|
||||
|
@ -62,7 +63,7 @@ class SplitTool extends Tool<TreeModel> {
|
|||
}
|
||||
|
||||
private long getSplitSize() {
|
||||
return spinnerModel.getNumber().intValue() * FileUtilities.MEGA;
|
||||
return spinnerModel.getNumber().intValue() * ONE_MEGABYTE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,7 +71,7 @@ class SplitTool extends Tool<TreeModel> {
|
|||
int nextPart = 1;
|
||||
long splitSize = getSplitSize();
|
||||
|
||||
List<File> files = (root != null) ? FileUtilities.listFiles(root) : new ArrayList<File>();
|
||||
List<File> files = (root != null) ? listFiles(root) : new ArrayList<File>();
|
||||
|
||||
List<TreeNode> rootGroup = new ArrayList<TreeNode>();
|
||||
List<File> currentPart = new ArrayList<File>();
|
||||
|
|
|
@ -659,17 +659,17 @@ public final class FileUtilities {
|
|||
|
||||
public static final int BUFFER_SIZE = 64 * 1024;
|
||||
|
||||
public static final long KILO = 1024;
|
||||
public static final long MEGA = 1024 * KILO;
|
||||
public static final long GIGA = 1024 * MEGA;
|
||||
public static final long ONE_KILOBYTE = 1024;
|
||||
public static final long ONE_MEGABYTE = 1024 * ONE_KILOBYTE;
|
||||
public static final long ONE_GIGABYTE = 1024 * ONE_MEGABYTE;
|
||||
|
||||
public static String formatSize(long size) {
|
||||
if (size >= GIGA)
|
||||
return String.format("%,d GB", size / GIGA);
|
||||
else if (size >= MEGA)
|
||||
return String.format("%,d MB", size / MEGA);
|
||||
else if (size >= KILO)
|
||||
return String.format("%,d KB", size / KILO);
|
||||
if (size >= ONE_GIGABYTE)
|
||||
return String.format("%,d GB", size / ONE_GIGABYTE);
|
||||
else if (size >= ONE_MEGABYTE)
|
||||
return String.format("%,d MB", size / ONE_MEGABYTE);
|
||||
else if (size >= ONE_KILOBYTE)
|
||||
return String.format("%,d KB", size / ONE_KILOBYTE);
|
||||
else
|
||||
return String.format("%,d bytes", size);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue