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/VisitCacheActivity.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/VisitCacheActivity.java')
-rw-r--r-- | main/src/cgeo/geocaching/VisitCacheActivity.java | 26 |
1 files changed, 6 insertions, 20 deletions
diff --git a/main/src/cgeo/geocaching/VisitCacheActivity.java b/main/src/cgeo/geocaching/VisitCacheActivity.java index 88908f1..342f19d 100644 --- a/main/src/cgeo/geocaching/VisitCacheActivity.java +++ b/main/src/cgeo/geocaching/VisitCacheActivity.java @@ -4,7 +4,6 @@ import cgeo.geocaching.activity.AbstractActivity; import cgeo.geocaching.connector.gc.GCParser; import cgeo.geocaching.connector.gc.Login; import cgeo.geocaching.enumerations.LoadFlags; -import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag; import cgeo.geocaching.enumerations.LoadFlags.SaveFlag; import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.enumerations.LogTypeTrackable; @@ -700,29 +699,16 @@ public class VisitCacheActivity extends AbstractActivity implements DateDialog.D log, trackables); if (status == StatusCode.NO_ERROR) { - final LogEntry logNow = new LogEntry(); - logNow.author = Settings.getUsername(); - logNow.date = date.getTimeInMillis(); - logNow.type = typeSelected; - logNow.log = log; - - if (cache != null) { - cache.prependLog(logNow); - } - app.addLog(geocode, logNow); + final LogEntry logNow = new LogEntry(date, typeSelected, log); + + cache.prependLog(logNow); + // app.saveLogs(cache); if (typeSelected == LogType.LOG_FOUND_IT) { - app.markFound(geocode); - if (cache != null) { - cache.setFound(true); - } + cache.setFound(true); } - if (cache != null) { - app.saveCache(cache, EnumSet.of(SaveFlag.SAVE_CACHE)); - } else { - app.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); - } + app.saveCache(cache, EnumSet.of(SaveFlag.SAVE_CACHE)); } if (status == StatusCode.NO_ERROR) { |