aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-07-19 23:19:20 +0200
committerBananeweizen <bananeweizen@gmx.de>2013-07-19 23:19:20 +0200
commit00165dafe3e709eac2775a311b47c354ad5aae7c (patch)
tree885210f7245c03923ab380cb2e33774a54624bb9
parentf7e98eb38e2f65e779fa674d8ece946e8b4c47be (diff)
downloadcgeo-00165dafe3e709eac2775a311b47c354ad5aae7c.zip
cgeo-00165dafe3e709eac2775a311b47c354ad5aae7c.tar.gz
cgeo-00165dafe3e709eac2775a311b47c354ad5aae7c.tar.bz2
refactoring: simplify control flow
* don't use boolean markers to trace the exception control flow
-rw-r--r--main/src/cgeo/geocaching/cgData.java30
1 files changed, 12 insertions, 18 deletions
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java
index ead698d..87710fb 100644
--- a/main/src/cgeo/geocaching/cgData.java
+++ b/main/src/cgeo/geocaching/cgData.java
@@ -1102,7 +1102,6 @@ public class cgData {
//try to update record else insert fresh..
database.beginTransaction();
- boolean result = false;
try {
saveAttributesWithoutTransaction(cache);
saveOriginalWaypointsWithoutTransaction(cache);
@@ -1118,14 +1117,14 @@ public class cgData {
database.insert(dbTableCaches, null, values);
}
database.setTransactionSuccessful();
- result = true;
+ return true;
} catch (Exception e) {
Log.e("SaveCache", e);
} finally {
database.endTransaction();
}
- return result;
+ return false;
}
private static void saveAttributesWithoutTransaction(final Geocache cache) {
@@ -1172,17 +1171,16 @@ public class cgData {
init();
database.beginTransaction();
- boolean result = false;
try {
saveOriginalWaypointsWithoutTransaction(cache);
database.setTransactionSuccessful();
- result = true;
+ return true;
} catch (Exception e) {
Log.e("saveWaypoints", e);
} finally {
database.endTransaction();
}
- return result;
+ return false;
}
private static void saveOriginalWaypointsWithoutTransaction(final Geocache cache) {
@@ -1376,7 +1374,7 @@ public class cgData {
}
}
- public static boolean saveTrackable(final Trackable trackable) {
+ public static void saveTrackable(final Trackable trackable) {
init();
database.beginTransaction();
@@ -1386,8 +1384,6 @@ public class cgData {
} finally {
database.endTransaction();
}
-
- return true;
}
private static void saveInventoryWithoutTransaction(final String geocode, final List<Trackable> trackables) {
@@ -1842,18 +1838,17 @@ public class cgData {
init();
database.beginTransaction();
- boolean success = true;
try {
database.delete(dbTableSearchDestionationHistory, null, null);
database.setTransactionSuccessful();
+ return true;
} catch (Exception e) {
- success = false;
Log.e("Unable to clear searched destinations", e);
} finally {
database.endTransaction();
}
- return success;
+ return false;
}
public static List<LogEntry> loadLogs(String geocode) {
@@ -2693,18 +2688,17 @@ public class cgData {
init();
database.beginTransaction();
- boolean result = false;
try {
database.delete(dbTableSearchDestionationHistory, "_id = " + destination.getId(), null);
database.setTransactionSuccessful();
- result = true;
+ return true;
} catch (Exception e) {
Log.e("Unable to remove searched destination", e);
} finally {
database.endTransaction();
}
- return result;
+ return false;
}
/**
@@ -3007,14 +3001,14 @@ public class cgData {
if (connector.canHandle(geocode)) {
Geocache geocache = cacheCache.getCacheFromCache(geocode);
if (geocache.getZoomLevel() <= maxZoom) {
- boolean bFound = false;
+ boolean found = false;
for (Tile tile : tiles) {
if (tile.containsPoint(geocache)) {
- bFound = true;
+ found = true;
break;
}
}
- if (bFound) {
+ if (found) {
missingFromSearch.add(geocode);
}
}