Refactor ONE_MEGABYTE

This commit is contained in:
Reinhard Pointner 2016-08-10 03:05:51 +08:00
parent eceed1e979
commit feaa0802a8
4 changed files with 15 additions and 14 deletions

View File

@ -109,7 +109,7 @@ public class AutoDetection {
return true; return true;
} }
if (VIDEO_FILES.accept(f)) { if (VIDEO_FILES.accept(f) && f.length() > ONE_MEGABYTE) {
// check for Japanese audio or characteristic subtitles // check for Japanese audio or characteristic subtitles
try (MediaInfo mi = new MediaInfo().open(f)) { try (MediaInfo mi = new MediaInfo().open(f)) {
long minutes = Duration.ofMillis(Long.parseLong(mi.get(StreamKind.General, 0, "Duration"))).toMinutes(); long minutes = Duration.ofMillis(Long.parseLong(mi.get(StreamKind.General, 0, "Duration"))).toMinutes();

View File

@ -1097,7 +1097,7 @@ public class MediaDetection {
} }
filesByMediaFolder.stream().collect(groupingBy(f -> { 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)) { try (MediaInfo mi = new MediaInfo().open(f)) {
String v = mi.get(StreamKind.Video, 0, "Codec"); String v = mi.get(StreamKind.Video, 0, "Codec");
String a = mi.get(StreamKind.Audio, 0, "Codec"); String a = mi.get(StreamKind.Audio, 0, "Codec");

View File

@ -1,5 +1,7 @@
package net.filebot.ui.filter; package net.filebot.ui.filter;
import static net.filebot.util.FileUtilities.*;
import java.awt.Color; import java.awt.Color;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -17,7 +19,6 @@ import javax.swing.tree.TreeNode;
import net.filebot.ui.filter.FileTree.FolderNode; import net.filebot.ui.filter.FileTree.FolderNode;
import net.filebot.ui.transfer.DefaultTransferHandler; import net.filebot.ui.transfer.DefaultTransferHandler;
import net.filebot.util.FileUtilities;
import net.filebot.util.ui.GradientStyle; import net.filebot.util.ui.GradientStyle;
import net.filebot.util.ui.LoadingOverlayPane; import net.filebot.util.ui.LoadingOverlayPane;
import net.filebot.util.ui.notification.SeparatorBorder; import net.filebot.util.ui.notification.SeparatorBorder;
@ -62,7 +63,7 @@ class SplitTool extends Tool<TreeModel> {
} }
private long getSplitSize() { private long getSplitSize() {
return spinnerModel.getNumber().intValue() * FileUtilities.MEGA; return spinnerModel.getNumber().intValue() * ONE_MEGABYTE;
} }
@Override @Override
@ -70,7 +71,7 @@ class SplitTool extends Tool<TreeModel> {
int nextPart = 1; int nextPart = 1;
long splitSize = getSplitSize(); 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<TreeNode> rootGroup = new ArrayList<TreeNode>();
List<File> currentPart = new ArrayList<File>(); List<File> currentPart = new ArrayList<File>();

View File

@ -659,17 +659,17 @@ public final class FileUtilities {
public static final int BUFFER_SIZE = 64 * 1024; public static final int BUFFER_SIZE = 64 * 1024;
public static final long KILO = 1024; public static final long ONE_KILOBYTE = 1024;
public static final long MEGA = 1024 * KILO; public static final long ONE_MEGABYTE = 1024 * ONE_KILOBYTE;
public static final long GIGA = 1024 * MEGA; public static final long ONE_GIGABYTE = 1024 * ONE_MEGABYTE;
public static String formatSize(long size) { public static String formatSize(long size) {
if (size >= GIGA) if (size >= ONE_GIGABYTE)
return String.format("%,d GB", size / GIGA); return String.format("%,d GB", size / ONE_GIGABYTE);
else if (size >= MEGA) else if (size >= ONE_MEGABYTE)
return String.format("%,d MB", size / MEGA); return String.format("%,d MB", size / ONE_MEGABYTE);
else if (size >= KILO) else if (size >= ONE_KILOBYTE)
return String.format("%,d KB", size / KILO); return String.format("%,d KB", size / ONE_KILOBYTE);
else else
return String.format("%,d bytes", size); return String.format("%,d bytes", size);
} }