diff options
| -rw-r--r-- | main/src/cgeo/geocaching/StoredList.java | 34 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeocaches.java | 4 | ||||
| -rw-r--r-- | tests/src/cgeo/geocaching/StoredListTest.java | 18 |
3 files changed, 52 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/StoredList.java b/main/src/cgeo/geocaching/StoredList.java index bb00506..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) { + 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()); diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java index aa4c89e..628c012 100644 --- a/main/src/cgeo/geocaching/cgeocaches.java +++ b/main/src/cgeo/geocaching/cgeocaches.java @@ -985,7 +985,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity refreshCurrentList(); } - }, true); + }, true, listId); } @Override @@ -1045,7 +1045,7 @@ public class cgeocaches extends AbstractListActivity implements FilteredActivity adapter.setSelectMode(false); refreshCurrentList(); } - }, true); + }, true, listId); break; case MENU_STORE_CACHE: //FIXME: this must use the same handler like in the CacheDetailActivity. Will be done by moving the handler into the store method. diff --git a/tests/src/cgeo/geocaching/StoredListTest.java b/tests/src/cgeo/geocaching/StoredListTest.java new file mode 100644 index 0000000..6d8fd64 --- /dev/null +++ b/tests/src/cgeo/geocaching/StoredListTest.java @@ -0,0 +1,18 @@ +package cgeo.geocaching; + +import junit.framework.TestCase; + +public class StoredListTest extends TestCase { + + public static void testStandardListExists() { + StoredList list = cgData.getList(StoredList.STANDARD_LIST_ID); + assertNotNull(list); + } + + public static void testEquals() { + StoredList list1 = cgData.getList(StoredList.STANDARD_LIST_ID); + StoredList list2 = cgData.getList(StoredList.STANDARD_LIST_ID); + assertEquals(list1, list2); + } + +} |
