From d2fba594dfea96b17ab01bb12afbc37ec10fe251 Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Mon, 23 Apr 2012 07:50:26 +0200 Subject: 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 --- main/src/cgeo/geocaching/cgeoapplication.java | 41 ++++++--------------------- 1 file changed, 9 insertions(+), 32 deletions(-) (limited to 'main/src/cgeo/geocaching/cgeoapplication.java') 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 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 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 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 list = new ArrayList(); - 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 list = new ArrayList(); - 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 caches, int listId) { + storage.moveToList(caches, listId); } /** {@link cgData#getCacheDescription(String)} */ -- cgit v1.1