aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/StoredList.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/StoredList.java')
-rw-r--r--main/src/cgeo/geocaching/StoredList.java37
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;
+ }
}