diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/src/cgeo/geocaching/connector/ec/ECConnector.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/files/SimpleDirChooser.java | 25 |
2 files changed, 15 insertions, 14 deletions
diff --git a/main/src/cgeo/geocaching/connector/ec/ECConnector.java b/main/src/cgeo/geocaching/connector/ec/ECConnector.java index 2aff7e9..2535c61 100644 --- a/main/src/cgeo/geocaching/connector/ec/ECConnector.java +++ b/main/src/cgeo/geocaching/connector/ec/ECConnector.java @@ -79,7 +79,9 @@ public class ECConnector extends AbstractConnector implements ISearchByGeocode, @Override public SearchResult searchByGeocode(final @Nullable String geocode, final @Nullable String guid, final CancellableHandler handler) { - + if (geocode == null) { + return null; + } CancellableHandler.sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_loadpage); final Geocache cache = ECApi.searchByGeoCode(geocode); diff --git a/main/src/cgeo/geocaching/files/SimpleDirChooser.java b/main/src/cgeo/geocaching/files/SimpleDirChooser.java index 3f6182c..3e09cc4 100644 --- a/main/src/cgeo/geocaching/files/SimpleDirChooser.java +++ b/main/src/cgeo/geocaching/files/SimpleDirChooser.java @@ -29,6 +29,7 @@ import java.io.File; import java.io.FilenameFilter; import java.util.ArrayList; import java.util.Collections; +import java.util.Comparator; import java.util.List; /** @@ -141,7 +142,7 @@ public class SimpleDirChooser extends AbstractListActivity { } } catch (RuntimeException e) { } - Collections.sort(listDirs); + Collections.sort(listDirs, Option.NAME_COMPARATOR); if (dir.getParent() != null) { listDirs.add(0, new Option(PARENT_DIR, dir.getParent(), false)); } @@ -247,15 +248,21 @@ public class SimpleDirChooser extends AbstractListActivity { } } - /** - * Note: this class has a natural ordering that is inconsistent with equals. - */ - public static class Option implements Comparable<Option> { + public static class Option { private final String name; private final String path; private boolean checked = false; private boolean writeable = false; + private static Comparator<Option> NAME_COMPARATOR = new Comparator<SimpleDirChooser.Option>() { + + @Override + public int compare(Option lhs, Option rhs) { + return String.CASE_INSENSITIVE_ORDER.compare(lhs.name, rhs.name); + } + + }; + public Option(String name, String path, boolean writeable) { this.name = name; this.path = path; @@ -281,14 +288,6 @@ public class SimpleDirChooser extends AbstractListActivity { public boolean isWriteable() { return writeable; } - - @Override - public int compareTo(Option other) { - if (other != null && this.name != null) { - return String.CASE_INSENSITIVE_ORDER.compare(this.name, other.getName()); - } - throw new IllegalArgumentException(""); - } } public static class DirOnlyFilenameFilter implements FilenameFilter { |