X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Ffunction%2FRearrangePhotosFunction.java;h=c55928021fcaaa08af3f84fa516bdf8f927f1469;hp=b8d9312de7dce3c1c349c466ec101b8fe72c3d56;hb=4d5796d02a15808311c09448d79e6e7d1de9d636;hpb=f1b92378a792131ac8fb33a869405851d5b2d1f7 diff --git a/tim/prune/function/RearrangePhotosFunction.java b/tim/prune/function/RearrangePhotosFunction.java index b8d9312..c559280 100644 --- a/tim/prune/function/RearrangePhotosFunction.java +++ b/tim/prune/function/RearrangePhotosFunction.java @@ -5,7 +5,6 @@ import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Arrays; -import java.util.Comparator; import javax.swing.BoxLayout; import javax.swing.ButtonGroup; @@ -193,32 +192,7 @@ public class RearrangePhotosFunction extends GenericFunction */ private static void sortPhotos(DataPoint[] inPhotos, boolean inSortByFile) { - Comparator comparator = null; - if (inSortByFile) - { - // sort by filename - comparator = new Comparator() { - public int compare(DataPoint inP1, DataPoint inP2) { - if (inP2 == null) return -1; // all nulls at end - if (inP1 == null) return 1; - if (inP1.getPhoto().getFile() == null || inP2.getPhoto().getFile() == null) - return inP1.getPhoto().getName().compareTo(inP2.getPhoto().getName()); - return inP1.getPhoto().getFile().compareTo(inP2.getPhoto().getFile()); - } - }; - } - else - { - // sort by photo timestamp - comparator = new Comparator() { - public int compare(DataPoint inP1, DataPoint inP2) { - if (inP2 == null) return -1; // all nulls at end - if (inP1 == null) return 1; - long secDiff = inP1.getPhoto().getTimestamp().getSecondsSince(inP2.getPhoto().getTimestamp()); - return (secDiff<0?-1:(secDiff==0?0:1)); - } - }; - } - Arrays.sort(inPhotos, comparator); + PhotoComparer comparer = new PhotoComparer(inSortByFile ? PhotoComparer.SortMode.SORTBY_NAME : PhotoComparer.SortMode.SORTBY_TIME); + Arrays.sort(inPhotos, comparer); } }