aboutsummaryrefslogtreecommitdiffstats
path: root/main/src
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-05-01 15:06:46 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-05-01 15:15:53 +0200
commitc61f8b728e62e4e86e304956af7bc41b1839017f (patch)
treee5046ef0f9ba2eb433eeca0f3f093c3a94126afe /main/src
parent410304e78e04a6c3c4518ef0d330995efceb62bc (diff)
downloadcgeo-c61f8b728e62e4e86e304956af7bc41b1839017f.zip
cgeo-c61f8b728e62e4e86e304956af7bc41b1839017f.tar.gz
cgeo-c61f8b728e62e4e86e304956af7bc41b1839017f.tar.bz2
fix #1479: option to delete old caches
Diffstat (limited to 'main/src')
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java6
-rw-r--r--main/src/cgeo/geocaching/sorting/StorageTimeComparator.java23
2 files changed, 29 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index 5e16109..ec0e173 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -33,6 +33,7 @@ import cgeo.geocaching.sorting.PopularityComparator;
import cgeo.geocaching.sorting.RatingComparator;
import cgeo.geocaching.sorting.SizeComparator;
import cgeo.geocaching.sorting.StateComparator;
+import cgeo.geocaching.sorting.StorageTimeComparator;
import cgeo.geocaching.sorting.TerrainComparator;
import cgeo.geocaching.sorting.VisitComparator;
import cgeo.geocaching.sorting.VoteComparator;
@@ -117,6 +118,7 @@ public class cgeocaches extends AbstractListActivity implements IObserver<Object
private static final int MENU_NAVIGATION = 69;
private static final int MENU_STORE_CACHE = 73;
private static final int MENU_FILTER = 74;
+ private static final int MENU_SORT_STORAGE = 75;
private static final int MSG_DONE = -1;
private static final int MSG_RESTART_GEO_AND_DIR = -2;
@@ -712,6 +714,7 @@ public class cgeocaches extends AbstractListActivity implements IObserver<Object
comparators.put(res.getString(R.string.caches_sort_date), MENU_SORT_DATE);
comparators.put(res.getString(R.string.caches_sort_finds), MENU_SORT_FINDS);
comparators.put(res.getString(R.string.caches_sort_state), MENU_SORT_STATE);
+ comparators.put(res.getString(R.string.caches_sort_storage), MENU_SORT_STORAGE);
List<String> sortedLabels = new ArrayList<String>(comparators.keySet());
Collections.sort(sortedLabels);
@@ -918,6 +921,9 @@ public class cgeocaches extends AbstractListActivity implements IObserver<Object
case MENU_SORT_GEOCODE:
setComparator(item, new GeocodeComparator());
return false;
+ case MENU_SORT_STORAGE:
+ setComparator(item, new StorageTimeComparator());
+ return false;
case MENU_SWITCH_LIST:
selectList(null);
invalidateOptionsMenuCompatible();
diff --git a/main/src/cgeo/geocaching/sorting/StorageTimeComparator.java b/main/src/cgeo/geocaching/sorting/StorageTimeComparator.java
new file mode 100644
index 0000000..32bef32
--- /dev/null
+++ b/main/src/cgeo/geocaching/sorting/StorageTimeComparator.java
@@ -0,0 +1,23 @@
+package cgeo.geocaching.sorting;
+
+import cgeo.geocaching.cgCache;
+
+public class StorageTimeComparator extends AbstractCacheComparator {
+
+ @Override
+ protected boolean canCompare(cgCache cache1, cgCache cache2) {
+ return true;
+ }
+
+ @Override
+ protected int compareCaches(cgCache cache1, cgCache cache2) {
+ if (cache1.getUpdated() < cache2.getUpdated()) {
+ return -1;
+ }
+ if (cache1.getUpdated() > cache2.getUpdated()) {
+ return 1;
+ }
+ return 0;
+ }
+
+}