diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-04-20 10:35:24 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-04-20 10:35:24 +0200 |
| commit | b71d4bd03f8da774881d119c3ab55e16dc27f4d1 (patch) | |
| tree | 168d354301afe2637eff4f4e2f2308ba7ca9f003 | |
| parent | 0e20e9f3b936304f1200f3f0c4dbb3e8d6749def (diff) | |
| download | cgeo-b71d4bd03f8da774881d119c3ab55e16dc27f4d1.zip cgeo-b71d4bd03f8da774881d119c3ab55e16dc27f4d1.tar.gz cgeo-b71d4bd03f8da774881d119c3ab55e16dc27f4d1.tar.bz2 | |
fix #2664: List sorting does not respect locale
| -rw-r--r-- | main/src/cgeo/geocaching/StoredList.java | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/StoredList.java b/main/src/cgeo/geocaching/StoredList.java index 5a6f132..778c112 100644 --- a/main/src/cgeo/geocaching/StoredList.java +++ b/main/src/cgeo/geocaching/StoredList.java @@ -12,7 +12,10 @@ import android.content.res.Resources; import android.view.View; import android.widget.EditText; +import java.text.Collator; import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; import java.util.List; public class StoredList { @@ -69,7 +72,7 @@ public class StoredList { } public void promptForListSelection(final int titleId, final RunnableWithArgument<Integer> runAfterwards, final boolean onlyMoveTargets, final int exceptListId) { - final List<StoredList> lists = cgData.getLists(); + final List<StoredList> lists = getSortedLists(); if (lists == null) { return; @@ -115,6 +118,19 @@ public class StoredList { builder.create().show(); } + private static List<StoredList> getSortedLists() { + final Collator collator = Collator.getInstance(); + final List<StoredList> lists = cgData.getLists(); + Collections.sort(lists, new Comparator<StoredList>() { + + @Override + public int compare(StoredList lhs, StoredList rhs) { + return collator.compare(lhs.getTitle(), rhs.getTitle()); + } + }); + return lists; + } + public void promptForListCreation(final RunnableWithArgument<Integer> runAfterwards) { handleListNameInput("", R.string.list_dialog_create_title, R.string.list_dialog_create, new RunnableWithArgument<String>() { @@ -176,4 +192,13 @@ public class StoredList { }); } } + + /** + * Get the list title. This method is not public by intention to make clients use the {@link UserInterface} class. + * + * @return + */ + protected String getTitle() { + return title; + } } |
