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.java42
1 files changed, 36 insertions, 6 deletions
diff --git a/main/src/cgeo/geocaching/StoredList.java b/main/src/cgeo/geocaching/StoredList.java
index cdff1cb..d6f0993 100644
--- a/main/src/cgeo/geocaching/StoredList.java
+++ b/main/src/cgeo/geocaching/StoredList.java
@@ -34,6 +34,29 @@ public class StoredList {
return title + " [" + count + "]";
}
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + id;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!(obj instanceof StoredList)) {
+ return false;
+ }
+ StoredList other = (StoredList) obj;
+ if (id != other.id) {
+ return false;
+ }
+ return true;
+ }
+
public static class UserInterface {
private final IAbstractActivity activity;
private final cgeoapplication app;
@@ -46,16 +69,23 @@ public class StoredList {
}
public void promptForListSelection(final int titleId, final RunnableWithArgument<Integer> runAfterwards) {
- promptForListSelection(titleId, runAfterwards, false);
+ promptForListSelection(titleId, runAfterwards, false, -1);
}
- public void promptForListSelection(final int titleId, final RunnableWithArgument<Integer> runAfterwards, final boolean onlyMoveTargets) {
- final List<StoredList> lists = app.getLists();
+ public void promptForListSelection(final int titleId, final RunnableWithArgument<Integer> runAfterwards, final boolean onlyMoveTargets, final int exceptListId) {
+ final List<StoredList> lists = cgData.getLists();
if (lists == null) {
return;
}
+ if (exceptListId > StoredList.TEMPORARY_LIST_ID) {
+ StoredList exceptList = cgData.getList(exceptListId);
+ if (exceptList != null) {
+ lists.remove(exceptList);
+ }
+ }
+
final List<CharSequence> listsTitle = new ArrayList<CharSequence>();
for (StoredList list : lists) {
listsTitle.add(list.getTitleAndCount());
@@ -94,7 +124,7 @@ public class StoredList {
@Override
public void run(final String listName) {
- final int newId = app.createList(listName);
+ final int newId = cgData.createList(listName);
if (newId >= cgData.customListIdOffset) {
activity.showToast(res.getString(R.string.list_dialog_create_ok));
@@ -137,12 +167,12 @@ public class StoredList {
}
public void promptForListRename(final int listId, final Runnable runAfterRename) {
- final StoredList list = app.getList(listId);
+ final StoredList list = cgData.getList(listId);
handleListNameInput(list.title, R.string.list_dialog_rename_title, R.string.list_dialog_rename, new RunnableWithArgument<String>() {
@Override
public void run(final String listName) {
- app.renameList(listId, listName);
+ cgData.renameList(listId, listName);
if (runAfterRename != null) {
runAfterRename.run();
}