diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2012-04-23 07:50:26 +0200 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2012-04-23 07:50:26 +0200 |
commit | d2fba594dfea96b17ab01bb12afbc37ec10fe251 (patch) | |
tree | 2e272eae1a0eeadc9213e8059f8f1d6dc381e048 /main/src/cgeo/geocaching/cgeoapplication.java | |
parent | 0d19a993a9d2e99bd4f0627d182870ee1606cb91 (diff) | |
download | cgeo-d2fba594dfea96b17ab01bb12afbc37ec10fe251.zip cgeo-d2fba594dfea96b17ab01bb12afbc37ec10fe251.tar.gz cgeo-d2fba594dfea96b17ab01bb12afbc37ec10fe251.tar.bz2 |
refactoring of database access
* use only one transaction when saving a cache
* rework some methods to always take a collection of objects instead of
calling the database multiple times
Diffstat (limited to 'main/src/cgeo/geocaching/cgeoapplication.java')
-rw-r--r-- | main/src/cgeo/geocaching/cgeoapplication.java | 41 |
1 files changed, 9 insertions, 32 deletions
diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java index 55fc84c..2b10c16 100644 --- a/main/src/cgeo/geocaching/cgeoapplication.java +++ b/main/src/cgeo/geocaching/cgeoapplication.java @@ -21,7 +21,6 @@ import android.os.Handler; import android.os.Message; import java.io.File; -import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.EnumSet; @@ -333,18 +332,13 @@ public class cgeoapplication extends Application { } /** {@link cgData#moveToList(String, int)} */ - public void markStored(String geocode, int listId) { - storage.moveToList(geocode, listId); + public void markStored(List<cgCache> caches, int listId) { + storage.moveToList(caches, listId); } /** {@link cgData#moveToList(String, int)} */ - public void markDropped(String geocode) { - storage.moveToList(geocode, StoredList.TEMPORARY_LIST_ID); - } - - /** {@link cgData#markFound(String)} */ - public boolean markFound(String geocode) { - return storage.markFound(geocode); + public void markDropped(List<cgCache> caches) { + storage.moveToList(caches, StoredList.TEMPORARY_LIST_ID); } /** {@link cgData#clearSearchedDestinations()} */ @@ -358,8 +352,8 @@ public class cgeoapplication extends Application { } /** {@link cgData#saveWaypoints(String, List, boolean)} */ - public boolean saveWaypoints(String geocode, List<cgWaypoint> waypoints, boolean drop) { - return storage.saveWaypoints(geocode, waypoints, drop); + public boolean saveWaypoints(final cgCache cache) { + return storage.saveWaypoints(cache); } public boolean saveOwnWaypoint(int id, String geocode, cgWaypoint waypoint) { @@ -376,10 +370,7 @@ public class cgeoapplication extends Application { } public boolean saveTrackable(cgTrackable trackable) { - final List<cgTrackable> list = new ArrayList<cgTrackable>(); - list.add(trackable); - - return storage.saveInventory("---", list); + return storage.saveTrackable(trackable); } /** {@link cgData#dropList(int)} **/ @@ -416,20 +407,6 @@ public class cgeoapplication extends Application { return StringUtils.defaultString(action); } - public boolean addLog(String geocode, LogEntry log) { - if (StringUtils.isBlank(geocode)) { - return false; - } - if (log == null) { - return false; - } - - List<LogEntry> list = new ArrayList<LogEntry>(); - list.add(log); - - return storage.saveLogs(geocode, list, false); - } - public void setLastCoords(final Geopoint coords) { lastCoords = coords; } @@ -494,8 +471,8 @@ public class cgeoapplication extends Application { } /** {@link cgData#moveToList(String, int)} */ - public void moveToList(String geocode, int listId) { - storage.moveToList(geocode, listId); + public void moveToList(List<cgCache> caches, int listId) { + storage.moveToList(caches, listId); } /** {@link cgData#getCacheDescription(String)} */ |