diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2011-10-14 13:57:25 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2011-10-14 13:58:20 +0200 |
| commit | cae896bbdda1628b438d5477677e08d2e8dcfed2 (patch) | |
| tree | 32ed7f1f6bccf125d9235809d0c155cc03b9a80b | |
| parent | 3688fed754ac08d016628ad01b777a5fc920f8a6 (diff) | |
| download | cgeo-cae896bbdda1628b438d5477677e08d2e8dcfed2.zip cgeo-cae896bbdda1628b438d5477677e08d2e8dcfed2.tar.gz cgeo-cae896bbdda1628b438d5477677e08d2e8dcfed2.tar.bz2 | |
Make parseTrackable static to ease testing and add documentation
| -rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index fa984df..d30b652 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -1728,7 +1728,16 @@ public class cgBase { return null; } - public cgTrackable parseTrackable(String page) { + /** + * Parse a trackable HTML description into a cgTrackable object + * + * @param page + * the HTML page to parse, already processed through {@link BaseUtils#replaceWhitespace} + * @param app + * if not null, the application to use to save the trackable + * @return the parsed trackable, or null if none could be parsed + */ + public static cgTrackable parseTrackable(final String page, final cgeoapplication app) { if (StringUtils.isBlank(page)) { Log.e(Settings.tag, "cgeoBase.parseTrackable: No page given"); return null; @@ -1966,7 +1975,9 @@ public class cgBase { Log.w(Settings.tag, "cgeoBase.parseCache: Failed to parse cache logs"); } - app.saveTrackable(trackable); + if (app != null) { + app.saveTrackable(trackable); + } return trackable; } @@ -2506,7 +2517,7 @@ public class cgBase { return trackable; } - trackable = parseTrackable(page); + trackable = parseTrackable(page, app); if (trackable == null) { Log.e(Settings.tag, "cgeoBase.searchTrackable: No trackable parsed"); return trackable; |
