diff options
| author | Portree-Kid <keith.paterson@gmx.de> | 2013-03-08 15:51:14 +0100 |
|---|---|---|
| committer | Portree-Kid <keith.paterson@gmx.de> | 2013-03-08 15:51:14 +0100 |
| commit | c80b90edad7c3721e349b4db3d6c5aa21a6c7a12 (patch) | |
| tree | 7af952f09a1e4d00c7f77cb1936a86bc81b6ef52 /main/src/cgeo/geocaching/Geocache.java | |
| parent | a0932683fdf840fd97464e93a4597fac5c93a731 (diff) | |
| parent | ea4e5bbbe197384fe276f85ae11856b0344af02c (diff) | |
| download | cgeo-c80b90edad7c3721e349b4db3d6c5aa21a6c7a12.zip cgeo-c80b90edad7c3721e349b4db3d6c5aa21a6c7a12.tar.gz cgeo-c80b90edad7c3721e349b4db3d6c5aa21a6c7a12.tar.bz2 | |
Merge remote-tracking branch 'upstream/master' into master-master
Conflicts:
main/src/cgeo/geocaching/cgeocaches.java
Diffstat (limited to 'main/src/cgeo/geocaching/Geocache.java')
| -rw-r--r-- | main/src/cgeo/geocaching/Geocache.java | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java index 18a315c..9a8325d 100644 --- a/main/src/cgeo/geocaching/Geocache.java +++ b/main/src/cgeo/geocaching/Geocache.java @@ -516,13 +516,17 @@ public class Geocache implements ICache, IWaypoint { } public void openInBrowser(Activity fromActivity) { - fromActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getCacheUrl()))); + fromActivity.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(getBrowserCacheUrl()))); } private String getCacheUrl() { return getConnector().getCacheUrl(this); } + private String getBrowserCacheUrl() { + return getConnector().getLongCacheUrl(this); + } + private IConnector getConnector() { return ConnectorFactory.getConnector(this); } @@ -618,15 +622,27 @@ public class Geocache implements ICache, IWaypoint { @Override public String getHint() { initializeCacheTexts(); + assertTextNotNull(hint, "Hint"); return hint; } /** + * After lazy loading the lazily loaded field must be non {@code null}. + * + */ + private static void assertTextNotNull(final String field, final String name) throws InternalError { + if (field == null) { + throw new InternalError(name + " field is not allowed to be null here"); + } + } + + /** * Attention, calling this method may trigger a database access for the cache! */ @Override public String getDescription() { initializeCacheTexts(); + assertTextNotNull(description, "Description"); return description; } @@ -635,7 +651,19 @@ public class Geocache implements ICache, IWaypoint { */ private void initializeCacheTexts() { if (description == null || shortdesc == null || hint == null || location == null) { - cgData.loadCacheTexts(this); + Geocache partial = cgData.loadCacheTexts(this.getGeocode()); + if (description == null) { + setDescription(partial.getDescription()); + } + if (shortdesc == null) { + setShortDescription(partial.getShortDescription()); + } + if (hint == null) { + setHint(partial.getHint()); + } + if (location == null) { + setLocation(partial.getLocation()); + } } } @@ -645,6 +673,7 @@ public class Geocache implements ICache, IWaypoint { @Override public String getShortDescription() { initializeCacheTexts(); + assertTextNotNull(shortdesc, "Short description"); return shortdesc; } @@ -673,6 +702,7 @@ public class Geocache implements ICache, IWaypoint { @Override public String getLocation() { initializeCacheTexts(); + assertTextNotNull(location, "Location"); return location; } |
