diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2013-05-10 09:10:44 +0200 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2013-05-10 09:11:28 +0200 |
| commit | d6e525eeba8fbd066138a9d6b98bb5683c18f449 (patch) | |
| tree | 071eeb0ebd1d59f462d944555ad29d99c30a1423 /main/src/cgeo/geocaching/StoredList.java | |
| parent | 7aad1b422c9a06bf82283c5069be74b5fafea351 (diff) | |
| parent | ab6f4537d74b228ca2620abba571f5ae8bb71706 (diff) | |
| download | cgeo-d6e525eeba8fbd066138a9d6b98bb5683c18f449.zip cgeo-d6e525eeba8fbd066138a9d6b98bb5683c18f449.tar.gz cgeo-d6e525eeba8fbd066138a9d6b98bb5683c18f449.tar.bz2 | |
Merge remote-tracking branch 'origin/release'
Diffstat (limited to 'main/src/cgeo/geocaching/StoredList.java')
| -rw-r--r-- | main/src/cgeo/geocaching/StoredList.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/StoredList.java b/main/src/cgeo/geocaching/StoredList.java index 5a6f132..c505e3c 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,23 @@ 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; + } + + /** + * Return the given list, if it is a concrete list. Return the default list otherwise. + */ + public static int getConcreteList(int listId) { + if (listId == ALL_LIST_ID || listId == TEMPORARY_LIST_ID) { + return STANDARD_LIST_ID; + } + return listId; + } } |
