diff options
Diffstat (limited to 'main/src/cgeo/geocaching/Geocache.java')
| -rw-r--r-- | main/src/cgeo/geocaching/Geocache.java | 90 |
1 files changed, 45 insertions, 45 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index 96fbc06..8798539 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -1,8 +1,7 @@ package cgeo.geocaching; -import cgeo.geocaching.cgData.StorageLocation; +import cgeo.geocaching.DataStore.StorageLocation; import cgeo.geocaching.activity.ActivityMixin; -import cgeo.geocaching.activity.IAbstractActivity; import cgeo.geocaching.connector.ConnectorFactory; import cgeo.geocaching.connector.IConnector; import cgeo.geocaching.connector.ILoggingManager; @@ -33,6 +32,7 @@ import cgeo.geocaching.utils.MatcherWrapper; import cgeo.geocaching.utils.UncertainProperty; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.StringUtils; @@ -112,20 +112,20 @@ public class Geocache implements ICache, IWaypoint { private final List<String> attributes = new LazyInitializedList<String>() { @Override public List<String> call() { - return cgData.loadAttributes(geocode); + return DataStore.loadAttributes(geocode); } }; private final List<Waypoint> waypoints = new LazyInitializedList<Waypoint>() { @Override public List<Waypoint> call() { - return cgData.loadWaypoints(geocode); + return DataStore.loadWaypoints(geocode); } }; private List<Image> spoilers = null; private final List<LogEntry> logs = new LazyInitializedList<LogEntry>() { @Override public List<LogEntry> call() { - return cgData.loadLogs(geocode); + return DataStore.loadLogs(geocode); } }; private List<Trackable> inventory = null; @@ -447,16 +447,16 @@ public class Geocache implements ICache, IWaypoint { return cacheType.getValue().isEvent(); } - public void logVisit(final IAbstractActivity fromActivity) { + public void logVisit(final Activity fromActivity) { if (!getConnector().canLog(this)) { - fromActivity.showToast(((Activity) fromActivity).getResources().getString(R.string.err_cannot_log_visit)); + ActivityMixin.showToast(fromActivity, fromActivity.getResources().getString(R.string.err_cannot_log_visit)); return; } - final Intent logVisitIntent = new Intent((Activity) fromActivity, LogCacheActivity.class); + final Intent logVisitIntent = new Intent(fromActivity, LogCacheActivity.class); logVisitIntent.putExtra(LogCacheActivity.EXTRAS_ID, cacheId); logVisitIntent.putExtra(LogCacheActivity.EXTRAS_GEOCODE, geocode); - ((Activity) fromActivity).startActivity(logVisitIntent); + fromActivity.startActivity(logVisitIntent); } public void logOffline(final Activity fromActivity, final LogType logType) { @@ -469,12 +469,12 @@ public class Geocache implements ICache, IWaypoint { if (logType == LogType.UNKNOWN) { return; } - final boolean status = cgData.saveLogOffline(geocode, date.getTime(), logType, log); + final boolean status = DataStore.saveLogOffline(geocode, date.getTime(), logType, log); final Resources res = fromActivity.getResources(); if (status) { ActivityMixin.showToast(fromActivity, res.getString(R.string.info_log_saved)); - cgData.saveVisitDate(geocode); + DataStore.saveVisitDate(geocode); logOffline = Boolean.TRUE; notifyChange(); @@ -484,7 +484,7 @@ public class Geocache implements ICache, IWaypoint { } public void clearOfflineLog() { - cgData.clearLogOffline(geocode); + DataStore.clearLogOffline(geocode); notifyChange(); } @@ -568,7 +568,7 @@ public class Geocache implements ICache, IWaypoint { return getConnector().supportsOwnCoordinates(); } - public ILoggingManager getLoggingManager(Activity activity) { + public ILoggingManager getLoggingManager(final LogCacheActivity activity) { return getConnector().getLoggingManager(activity, this); } @@ -602,21 +602,21 @@ public class Geocache implements ICache, IWaypoint { @Override public boolean isArchived() { - return (archived != null && archived.booleanValue()); + return BooleanUtils.isTrue(archived); } @Override public boolean isDisabled() { - return (disabled != null && disabled.booleanValue()); + return BooleanUtils.isTrue(disabled); } @Override public boolean isPremiumMembersOnly() { - return (premiumMembersOnly != null && premiumMembersOnly.booleanValue()); + return BooleanUtils.isTrue(premiumMembersOnly); } public void setPremiumMembersOnly(boolean members) { - this.premiumMembersOnly = Boolean.valueOf(members); + this.premiumMembersOnly = members; } @Override @@ -664,7 +664,7 @@ public class Geocache implements ICache, IWaypoint { */ private void initializeCacheTexts() { if (description == null || shortdesc == null || hint == null || location == null) { - final Geocache partial = cgData.loadCacheTexts(this.getGeocode()); + final Geocache partial = DataStore.loadCacheTexts(this.getGeocode()); if (description == null) { setDescription(partial.getDescription()); } @@ -767,16 +767,16 @@ public class Geocache implements ICache, IWaypoint { @Override public boolean isFound() { - return (found != null && found.booleanValue()); + return BooleanUtils.isTrue(found); } @Override public boolean isFavorite() { - return (favorite != null && favorite.booleanValue()); + return BooleanUtils.isTrue(favorite); } public void setFavorite(boolean favorite) { - this.favorite = Boolean.valueOf(favorite); + this.favorite = favorite; } @Override @@ -990,11 +990,11 @@ public class Geocache implements ICache, IWaypoint { @Override public boolean isOnWatchlist() { - return (onWatchlist != null && onWatchlist.booleanValue()); + return BooleanUtils.isTrue(onWatchlist); } public void setOnWatchlist(boolean onWatchlist) { - this.onWatchlist = Boolean.valueOf(onWatchlist); + this.onWatchlist = onWatchlist; } /** @@ -1028,7 +1028,7 @@ public class Geocache implements ICache, IWaypoint { } } } - return saveToDatabase && cgData.saveWaypoints(this); + return saveToDatabase && DataStore.saveWaypoints(this); } /** @@ -1063,11 +1063,11 @@ public class Geocache implements ICache, IWaypoint { } public boolean isLogOffline() { - return (logOffline != null && logOffline.booleanValue()); + return BooleanUtils.isTrue(logOffline); } public void setLogOffline(boolean logOffline) { - this.logOffline = Boolean.valueOf(logOffline); + this.logOffline = logOffline; } public boolean isStatusChecked() { @@ -1140,15 +1140,15 @@ public class Geocache implements ICache, IWaypoint { } public void setDisabled(boolean disabled) { - this.disabled = Boolean.valueOf(disabled); + this.disabled = disabled; } public void setArchived(boolean archived) { - this.archived = Boolean.valueOf(archived); + this.archived = archived; } public void setFound(boolean found) { - this.found = Boolean.valueOf(found); + this.found = found; } public void setAttributes(List<String> attributes) { @@ -1244,7 +1244,7 @@ public class Geocache implements ICache, IWaypoint { // when waypoint was edited, finalDefined may have changed resetFinalDefined(); } - return saveToDatabase && cgData.saveWaypoint(waypoint.getId(), geocode, waypoint); + return saveToDatabase && DataStore.saveWaypoint(waypoint.getId(), geocode, waypoint); } public boolean hasWaypoints() { @@ -1295,9 +1295,9 @@ public class Geocache implements ICache, IWaypoint { final int index = getWaypointIndex(original); final Waypoint copy = new Waypoint(original); copy.setUserDefined(); - copy.setName(cgeoapplication.getInstance().getString(R.string.waypoint_copy_of) + " " + copy.getName()); + copy.setName(CgeoApplication.getInstance().getString(R.string.waypoint_copy_of) + " " + copy.getName()); waypoints.add(index + 1, copy); - return cgData.saveWaypoint(-1, geocode, copy); + return DataStore.saveWaypoint(-1, geocode, copy); } /** @@ -1317,8 +1317,8 @@ public class Geocache implements ICache, IWaypoint { if (waypoint.isUserDefined()) { final int index = getWaypointIndex(waypoint); waypoints.remove(index); - cgData.deleteWaypoint(waypoint.getId()); - cgData.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); + DataStore.deleteWaypoint(waypoint.getId()); + DataStore.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); // Check status if Final is defined if (waypoint.isFinalWithCoords()) { resetFinalDefined(); @@ -1337,8 +1337,8 @@ public class Geocache implements ICache, IWaypoint { public void deleteWaypointForce(Waypoint waypoint) { final int index = getWaypointIndex(waypoint); waypoints.remove(index); - cgData.deleteWaypoint(waypoint.getId()); - cgData.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); + DataStore.deleteWaypoint(waypoint.getId()); + DataStore.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); resetFinalDefined(); } @@ -1406,7 +1406,7 @@ public class Geocache implements ICache, IWaypoint { if (point.getLatitudeE6() != 0 && point.getLongitudeE6() != 0 && ((point.getLatitudeE6() % 1000) != 0 || (point.getLongitudeE6() % 1000) != 0) && !hasIdenticalWaypoint(point)) { - final String name = cgeoapplication.getInstance().getString(R.string.cache_personal_note) + " " + count; + final String name = CgeoApplication.getInstance().getString(R.string.cache_personal_note) + " " + count; final String potentialWaypointType = note.substring(Math.max(0, matcher.start() - 15)); final Waypoint waypoint = new Waypoint(name, parseWaypointType(potentialWaypointType), false); waypoint.setCoords(point); @@ -1511,8 +1511,8 @@ public class Geocache implements ICache, IWaypoint { public void drop(Handler handler) { try { - cgData.markDropped(Collections.singletonList(this)); - cgData.removeCache(getGeocode(), EnumSet.of(RemoveFlag.REMOVE_CACHE)); + DataStore.markDropped(Collections.singletonList(this)); + DataStore.removeCache(getGeocode(), EnumSet.of(RemoveFlag.REMOVE_CACHE)); handler.sendMessage(Message.obtain()); } catch (final Exception e) { @@ -1563,7 +1563,7 @@ public class Geocache implements ICache, IWaypoint { } public void refresh(int newListId, CancellableHandler handler) { - cgData.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); + DataStore.removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); storeCache(null, geocode, newListId, true, handler); } @@ -1639,7 +1639,7 @@ public class Geocache implements ICache, IWaypoint { } cache.setListId(listId); - cgData.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB)); + DataStore.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB)); if (CancellableHandler.isCancelled(handler)) { return; @@ -1661,9 +1661,9 @@ public class Geocache implements ICache, IWaypoint { return null; } - if (!forceReload && listId == StoredList.TEMPORARY_LIST_ID && (cgData.isOffline(geocode, guid) || cgData.isThere(geocode, guid, true, true))) { + if (!forceReload && listId == StoredList.TEMPORARY_LIST_ID && (DataStore.isOffline(geocode, guid) || DataStore.isThere(geocode, guid, true, true))) { final SearchResult search = new SearchResult(); - final String realGeocode = StringUtils.isNotBlank(geocode) ? geocode : cgData.getGeocodeForGuid(guid); + final String realGeocode = StringUtils.isNotBlank(geocode) ? geocode : DataStore.getGeocodeForGuid(guid); search.addGeocode(realGeocode); return search; } @@ -1708,7 +1708,7 @@ public class Geocache implements ICache, IWaypoint { } } // 12 o'clock - final String hourLocalized = cgeoapplication.getInstance().getString(R.string.cache_time_full_hours); + final String hourLocalized = CgeoApplication.getInstance().getString(R.string.cache_time_full_hours); if (StringUtils.isNotBlank(hourLocalized)) { final Pattern fullHours = Pattern.compile("\\b(\\d{1,2})\\s+" + Pattern.quote(hourLocalized), Pattern.CASE_INSENSITIVE); final MatcherWrapper matcherHours = new MatcherWrapper(fullHours, getDescription()); @@ -1735,7 +1735,7 @@ public class Geocache implements ICache, IWaypoint { * @return */ public boolean hasAttribute(CacheAttribute attribute, boolean yes) { - Geocache fullCache = cgData.loadCache(getGeocode(), EnumSet.of(LoadFlag.LOAD_ATTRIBUTES)); + Geocache fullCache = DataStore.loadCache(getGeocode(), EnumSet.of(LoadFlag.LOAD_ATTRIBUTES)); if (fullCache == null) { fullCache = this; } |
