diff options
| author | bananeweizen <bananeweizen@gmx.de> | 2011-08-21 14:38:24 +0200 |
|---|---|---|
| committer | bananeweizen <bananeweizen@gmx.de> | 2011-08-21 14:38:24 +0200 |
| commit | 877fb48415b44bf84542303d8c1cd2dd96bb02a5 (patch) | |
| tree | 69fce7b8ec50547227db569c91530d29cf94d2e9 /src | |
| parent | 2a6c5e7e4e7a5d521f5b2099ac2adf46caaa30cb (diff) | |
| parent | c6517f17006066361acfc6fb2b9473bf8a5de798 (diff) | |
| download | cgeo-877fb48415b44bf84542303d8c1cd2dd96bb02a5.zip cgeo-877fb48415b44bf84542303d8c1cd2dd96bb02a5.tar.gz cgeo-877fb48415b44bf84542303d8c1cd2dd96bb02a5.tar.bz2 | |
move file parsers into their own package, merge previous changes of
MichielK
Diffstat (limited to 'src')
15 files changed, 170 insertions, 172 deletions
diff --git a/src/cgeo/geocaching/cgBase.java b/src/cgeo/geocaching/cgBase.java index aeb253d..90f69f1 100644 --- a/src/cgeo/geocaching/cgBase.java +++ b/src/cgeo/geocaching/cgBase.java @@ -65,6 +65,7 @@ import android.text.style.StrikethroughSpan; import android.util.Log; import android.widget.EditText; import cgeo.geocaching.activity.ActivityMixin; +import cgeo.geocaching.files.LocParser; public class cgBase { @@ -92,7 +93,7 @@ public class cgBase { private final static Pattern patternDesc = Pattern.compile("<span id=\"ctl00_ContentBody_LongDescription\"[^>]*>" + "(.*)</span>[^<]*</div>[^<]*<p>[^<]*</p>[^<]*<p>[^<]*<strong>\\W*Additional Hints</strong>", Pattern.CASE_INSENSITIVE); private final static Pattern patternCountLogs = Pattern.compile("<span id=\"ctl00_ContentBody_lblFindCounts\"><p>(.*)<\\/p><\\/span>", Pattern.CASE_INSENSITIVE); private final static Pattern patternCountLog = Pattern.compile(" src=\"\\/images\\/icons\\/([^\\.]*).gif\" alt=\"[^\"]*\" title=\"[^\"]*\" />([0-9]*)[^0-9]+", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); - private final static Pattern patternLogs = Pattern.compile("<table class=\"LogsTable\">(.*?)</table>\\s*<p", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); + //private final static Pattern patternLogs = Pattern.compile("<table class=\"LogsTable\">(.*?)</table>\\s*<p", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); private final static Pattern patternLog = Pattern.compile("<tr><td class.+?<a href=\"/profile/\\?guid=.+?>(.+?)</a>.+?logOwnerStats.+?guid.+?>(\\d+)</a>.+?LogType.+?<img.+?/images/icons/([^\\.]+)\\..+?title=\"(.+?)\".+?LogDate.+?>(.+?)<.+?LogText.+?>(.*?)</p>(.*?)</div></div></div></td></tr>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE); private final static Pattern patternLogImgs = Pattern.compile("href=\"(http://img.geocaching.com/cache/log/.+?)\".+?<span>([^<]*)", Pattern.CASE_INSENSITIVE); private final static Pattern patternAttributes = Pattern.compile("<h3 class=\"WidgetHeader\">[^<]*<img[^>]+>\\W*Attributes[^<]*</h3>[^<]*<div class=\"WidgetBody\">(([^<]*<img src=\"[^\"]+\" alt=\"[^\"]+\"[^>]*>)+)[^<]*<p", Pattern.CASE_INSENSITIVE); @@ -115,13 +116,15 @@ public class cgBase { public static HashMap<Integer, String> logTypesTrackable = new HashMap<Integer, String>(); public static HashMap<Integer, String> logTypesTrackableAction = new HashMap<Integer, String>(); public static HashMap<Integer, String> errorRetrieve = new HashMap<Integer, String>(); - public static SimpleDateFormat dateInBackslash = new SimpleDateFormat("MM/dd/yyyy"); - public static SimpleDateFormat dateInDash = new SimpleDateFormat("yyyy-MM-dd"); - public static SimpleDateFormat dateEvIn = new SimpleDateFormat("dd MMMMM yyyy", Locale.ENGLISH); // 28 March 2009 - public static SimpleDateFormat dateTbIn1 = new SimpleDateFormat("EEEEE, dd MMMMM yyyy", Locale.ENGLISH); // Saturday, 28 March 2009 - public static SimpleDateFormat dateTbIn2 = new SimpleDateFormat("EEEEE, MMMMM dd, yyyy", Locale.ENGLISH); // Saturday, March 28, 2009 - public static SimpleDateFormat dateSqlIn = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 2010-07-25 14:44:01 - public static SimpleDateFormat dateGPXIn = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); // 2010-04-20T07:00:00Z + public final static SimpleDateFormat dateInBackslash = new SimpleDateFormat("MM/dd/yyyy"); + public final static SimpleDateFormat dateInDash = new SimpleDateFormat("yyyy-MM-dd"); + public final static SimpleDateFormat dateEvIn = new SimpleDateFormat("dd MMMMM yyyy", Locale.ENGLISH); // 28 March 2009 + public final static SimpleDateFormat dateTbIn1 = new SimpleDateFormat("EEEEE, dd MMMMM yyyy", Locale.ENGLISH); // Saturday, 28 March 2009 + public final static SimpleDateFormat dateTbIn2 = new SimpleDateFormat("EEEEE, MMMMM dd, yyyy", Locale.ENGLISH); // Saturday, March 28, 2009 + public final static SimpleDateFormat dateSqlIn = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 2010-07-25 14:44:01 + public final static SimpleDateFormat dateGPXIn = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"); // 2010-04-20T07:00:00Z + public final static SimpleDateFormat dateLogs1 = new SimpleDateFormat("MMMMM dd, yyyy", Locale.ENGLISH); // March 28, 2009 + public final static SimpleDateFormat dateLogs2 = new SimpleDateFormat("MMMMM dd", Locale.ENGLISH); // March 28 private Resources res = null; private HashMap<String, String> cookies = new HashMap<String, String>(); private static final String passMatch = "[/\\?&]*[Pp]ass(word)?=[^&^#^$]+"; @@ -867,7 +870,7 @@ public class cgBase { while (matcherTotalCnt.find()) { if (matcherTotalCnt.groupCount() > 0) { if (matcherTotalCnt.group(1) != null) { - caches.totalCnt = new Integer(matcherTotalCnt.group(1)); + caches.totalCnt = Integer.valueOf(matcherTotalCnt.group(1)); } } } @@ -1590,7 +1593,7 @@ public class cgBase { 2- Finds-count 3- Log type image name (e.g. "icon_smile") 4- Type string (e.g. "Found it") - 5- Date string (e.g. "about 4 days ago") + 5- Date string (e.g. "March 28, 2009") 6- Log text 7- The rest (e.g. log-images, maybe faster) */ @@ -1608,6 +1611,28 @@ public class cgBase { { logDone.type = logTypes.get("icon_note"); } + + try + { + logDone.date = dateLogs1.parse(matcherLog.group(5)).getTime(); // long format + } + catch (ParseException e) + { + try + { + // short format, with current year + final Date date = dateLogs2.parse(matcherLog.group(5)); + final Calendar cal = Calendar.getInstance(); + final int year = cal.get(Calendar.YEAR); + cal.setTime(date); + cal.set(Calendar.YEAR, year); + logDone.date = cal.getTimeInMillis(); + } + catch (ParseException ee) + { + Log.w(cgSettings.tag, "Failed to parse logs date: " + ee.toString()); + } + } logDone.author = Html.fromHtml(matcherLog.group(1)).toString(); @@ -2457,12 +2482,12 @@ public class cgBase { continue; } if (trackableMatcher.group(3) != null) { - trackable.ctl = new Integer(trackableMatcher.group(3)); + trackable.ctl = Integer.valueOf(trackableMatcher.group(3)); } else { continue; } if (trackableMatcher.group(5) != null) { - trackable.id = new Integer(trackableMatcher.group(5)); + trackable.id = Integer.valueOf(trackableMatcher.group(5)); } else { continue; } @@ -4165,63 +4190,7 @@ public class cgBase { scheme = "https://"; } - // prepare cookies - String cookiesDone = null; - if (cookies == null || cookies.isEmpty()) { - if (cookies == null) { - cookies = new HashMap<String, String>(); - } - - final Map<String, ?> prefsAll = prefs.getAll(); - final Set<? extends Map.Entry<String, ?>> entrySet = prefsAll.entrySet(); - - for(Map.Entry<String, ?> entry : entrySet){ - String key = entry.getKey(); - if (key.matches("cookie_.+")) { - final String cookieKey = key.substring(7); - final String cookieValue = (String) entry.getValue(); - - cookies.put(cookieKey, cookieValue); - } - } - } - - if (cookies != null) { - final Set<Map.Entry<String, String>> entrySet = cookies.entrySet(); - final ArrayList<String> cookiesEncoded = new ArrayList<String>(); - - for(Map.Entry<String, String> entry : entrySet){ - cookiesEncoded.add(entry.getKey() + "=" + entry.getValue()); - } - - if (cookiesEncoded.size() > 0) { - cookiesDone = implode("; ", cookiesEncoded.toArray()); - } - } - - if (cookiesDone == null) { - Map<String, ?> prefsValues = prefs.getAll(); - - if (prefsValues != null && prefsValues.size() > 0 && prefsValues.keySet().size() > 0) { - final Set<? extends Map.Entry<String, ?>> entrySet = prefsValues.entrySet(); - final ArrayList<String> cookiesEncoded = new ArrayList<String>(); - - for(Map.Entry<String, ?> entry : entrySet){ - String key = entry.getKey(); - if (key.length() > 7 && key.substring(0, 7).equals("cookie_")) { - cookiesEncoded.add(key + "=" + entry.getValue()); - } - } - - if (cookiesEncoded.size() > 0) { - cookiesDone = implode("; ", cookiesEncoded.toArray()); - } - } - } - - if (cookiesDone == null) { - cookiesDone = ""; - } + String cookiesDone = getCookiesAsString(); URLConnection uc = null; HttpURLConnection connection = null; @@ -4323,16 +4292,7 @@ public class cgBase { } prefsEditor.commit(); - final String encoding = connection.getContentEncoding(); - InputStream ins; - - if (encoding != null && encoding.equalsIgnoreCase("gzip")) { - ins = new GZIPInputStream(connection.getInputStream()); - } else if (encoding != null && encoding.equalsIgnoreCase("deflate")) { - ins = new InflaterInputStream(connection.getInputStream(), new Inflater(true)); - } else { - ins = connection.getInputStream(); - } + InputStream ins = getInputstreamFromConnection(connection); final InputStreamReader inr = new InputStreamReader(ins); final BufferedReader br = new BufferedReader(inr, 16 * 1024); @@ -4401,32 +4361,7 @@ public class cgBase { return response; } - private static void replaceWhitespace(final StringBuffer buffer) { - final int length = buffer.length(); - final char[] chars = new char[length]; - buffer.getChars(0, length, chars, 0); - int resultSize = 0; - boolean lastWasWhitespace = false; - for (int i = 0; i < length; i++) { - char c = chars[i]; - if (c == ' ' || c == '\n' || c == '\r' || c == '\t') { - if (!lastWasWhitespace) { - chars[resultSize++] =' '; - } - lastWasWhitespace = true; - } else { - chars[resultSize++] = c; - lastWasWhitespace = false; - } - } - buffer.setLength(0); - buffer.append(chars); - } - - public String requestJSONgc(String host, String path, String params) { - int httpCode = -1; - String httpLocation = null; - + private String getCookiesAsString() { // prepare cookies String cookiesDone = null; if (cookies == null || cookies.isEmpty()) { @@ -4484,6 +4419,35 @@ public class cgBase { if (cookiesDone == null) { cookiesDone = ""; } + return cookiesDone; + } + + private static void replaceWhitespace(final StringBuffer buffer) { + final int length = buffer.length(); + final char[] chars = new char[length]; + buffer.getChars(0, length, chars, 0); + int resultSize = 0; + boolean lastWasWhitespace = false; + for (char c : chars) { + if (c == ' ' || c == '\n' || c == '\r' || c == '\t') { + if (!lastWasWhitespace) { + chars[resultSize++] =' '; + } + lastWasWhitespace = true; + } else { + chars[resultSize++] = c; + lastWasWhitespace = false; + } + } + buffer.setLength(0); + buffer.append(chars); + } + + public String requestJSONgc(String host, String path, String params) { + int httpCode = -1; + String httpLocation = null; + + String cookiesDone = getCookiesAsString(); URLConnection uc = null; HttpURLConnection connection = null; @@ -4555,16 +4519,7 @@ public class cgBase { } prefsEditor.commit(); - final String encoding = connection.getContentEncoding(); - InputStream ins; - - if (encoding != null && encoding.equalsIgnoreCase("gzip")) { - ins = new GZIPInputStream(connection.getInputStream()); - } else if (encoding != null && encoding.equalsIgnoreCase("deflate")) { - ins = new InflaterInputStream(connection.getInputStream(), new Inflater(true)); - } else { - ins = connection.getInputStream(); - } + InputStream ins = getInputstreamFromConnection(connection); final InputStreamReader inr = new InputStreamReader(ins); final BufferedReader br = new BufferedReader(inr); @@ -4611,6 +4566,20 @@ public class cgBase { } } + private static InputStream getInputstreamFromConnection(HttpURLConnection connection) throws IOException { + final String encoding = connection.getContentEncoding(); + InputStream ins; + + if (encoding != null && encoding.equalsIgnoreCase("gzip")) { + ins = new GZIPInputStream(connection.getInputStream()); + } else if (encoding != null && encoding.equalsIgnoreCase("deflate")) { + ins = new InflaterInputStream(connection.getInputStream(), new Inflater(true)); + } else { + ins = connection.getInputStream(); + } + return ins; + } + public static String requestJSON(String host, String path, String params) { return requestJSON("http://", host, path, "GET", params); } @@ -4690,16 +4659,7 @@ public class cgBase { } - final String encoding = connection.getContentEncoding(); - InputStream ins; - - if (encoding != null && encoding.equalsIgnoreCase("gzip")) { - ins = new GZIPInputStream(connection.getInputStream()); - } else if (encoding != null && encoding.equalsIgnoreCase("deflate")) { - ins = new InflaterInputStream(connection.getInputStream(), new Inflater(true)); - } else { - ins = connection.getInputStream(); - } + InputStream ins = getInputstreamFromConnection(connection); final InputStreamReader inr = new InputStreamReader(ins); final BufferedReader br = new BufferedReader(inr, 1024); @@ -4825,11 +4785,11 @@ public class cgBase { if (path.exists()) { File[] files = path.listFiles(); - for (int i = 0; i < files.length; i++) { - if (files[i].isDirectory()) { - deleteDirectory(files[i]); + for (File file : files) { + if (file.isDirectory()) { + deleteDirectory(file); } else { - files[i].delete(); + file.delete(); } } } diff --git a/src/cgeo/geocaching/cgData.java b/src/cgeo/geocaching/cgData.java index deb8ea1..27cedea 100644 --- a/src/cgeo/geocaching/cgData.java +++ b/src/cgeo/geocaching/cgData.java @@ -2804,14 +2804,15 @@ public class cgData { if (size > 0) { Log.d(cgSettings.tag, "Database clean: removing " + size + " geocaches"); - databaseRW.execSQL("delete from " + dbTableCaches + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableAttributes + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableSpoilers + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableLogs + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableLogCount + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableLogsOffline + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableWaypoints + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ") and type <> \"own\""); - databaseRW.execSQL("delete from " + dbTableTrackables + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); + String geocodeList = cgBase.implode(", ", geocodes.toArray()); + databaseRW.execSQL("delete from " + dbTableCaches + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableAttributes + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableSpoilers + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableLogs + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableLogCount + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableLogsOffline + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableWaypoints + " where geocode in (" + geocodeList + ") and type <> \"own\""); + databaseRW.execSQL("delete from " + dbTableTrackables + " where geocode in (" + geocodeList + ")"); geocodes.clear(); } @@ -2861,14 +2862,15 @@ public class cgData { } if (geocodes.size() > 0) { - databaseRW.execSQL("delete from " + dbTableCaches + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableAttributes + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableSpoilers + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableLogs + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableLogCount + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableLogsOffline + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); - databaseRW.execSQL("delete from " + dbTableWaypoints + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ") and type <> \"own\""); - databaseRW.execSQL("delete from " + dbTableTrackables + " where geocode in (" + cgBase.implode(", ", geocodes.toArray()) + ")"); + String geocodeList = cgBase.implode(", ", geocodes.toArray()); + databaseRW.execSQL("delete from " + dbTableCaches + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableAttributes + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableSpoilers + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableLogs + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableLogCount + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableLogsOffline + " where geocode in (" + geocodeList + ")"); + databaseRW.execSQL("delete from " + dbTableWaypoints + " where geocode in (" + geocodeList + ") and type <> \"own\""); + databaseRW.execSQL("delete from " + dbTableTrackables + " where geocode in (" + geocodeList + ")"); geocodes.clear(); } diff --git a/src/cgeo/geocaching/cgOAuth.java b/src/cgeo/geocaching/cgOAuth.java index 48592eb..46e9c7d 100644 --- a/src/cgeo/geocaching/cgOAuth.java +++ b/src/cgeo/geocaching/cgOAuth.java @@ -27,15 +27,15 @@ public class cgOAuth { params.put("oauth_timestamp", Long.toString(currentTime)); params.put("oauth_token", token); params.put("oauth_version", "1.0"); - - Object[] keys = params.keySet().toArray(); + + String[] keys = new String[params.keySet().size()]; + params.keySet().toArray(keys); Arrays.sort(keys); ArrayList<String> paramsEncoded = new ArrayList<String>(); - for (int i = 0; i < keys.length; i++) { - String value = params.get(keys[i].toString()); - - paramsEncoded.add(keys[i] + "=" + cgBase.urlencode_rfc3986(value)); + for (String key : keys) { + String value = params.get(key); + paramsEncoded.add(key + "=" + cgBase.urlencode_rfc3986(value)); } String keysPacked; diff --git a/src/cgeo/geocaching/cgSelectMapfile.java b/src/cgeo/geocaching/cgSelectMapfile.java index d119f26..e9bed60 100644 --- a/src/cgeo/geocaching/cgSelectMapfile.java +++ b/src/cgeo/geocaching/cgSelectMapfile.java @@ -3,6 +3,8 @@ package cgeo.geocaching; import java.io.File; import java.util.ArrayList; +import cgeo.geocaching.files.FileList; + import android.content.Intent; import android.os.Bundle; import android.os.Environment; diff --git a/src/cgeo/geocaching/cgSettings.java b/src/cgeo/geocaching/cgSettings.java index 87eacdd..8e6686e 100644 --- a/src/cgeo/geocaching/cgSettings.java +++ b/src/cgeo/geocaching/cgSettings.java @@ -429,11 +429,9 @@ public class cgSettings { if (prefsValues != null && prefsValues.size() > 0) { Log.i(cgSettings.tag, "Removing cookies"); - Object[] keys = prefsValues.keySet().toArray(); - - for (int i = 0; i < keys.length; i++) { - if (keys[i].toString().length() > 7 && keys[i].toString().substring(0, 7).equals("cookie_")) { - edit.remove(keys[i].toString()); + for (String key : prefsValues.keySet()) { + if (key.length() > 7 && key.substring(0, 7).equals("cookie_")) { + edit.remove(key); } } } diff --git a/src/cgeo/geocaching/cgeodetail.java b/src/cgeo/geocaching/cgeodetail.java index ff6d702..6df21b1 100644 --- a/src/cgeo/geocaching/cgeodetail.java +++ b/src/cgeo/geocaching/cgeodetail.java @@ -595,9 +595,17 @@ public class cgeodetail extends AbstractActivity { gcIcons.put("mystery", R.drawable.type_mystery); } - geocode = geocode.toUpperCase(); + if (null == geocode && cache.geocode.length() > 0) + { + geocode = cache.geocode; + } + + if (null == guid && cache.guid.length() > 0) + { + guid = cache.guid; + } - setTitle(geocode); + setTitle(cache.geocode.toUpperCase()); inflater = getLayoutInflater(); @@ -807,9 +815,7 @@ public class cgeodetail extends AbstractActivity { final TextView attribView = (TextView) findViewById(R.id.attributes); StringBuilder buffer = new StringBuilder(); - String attribute; - for (int i = 0; i < cache.attributes.size(); i++) { - attribute = cache.attributes.get(i); + for (String attribute : cache.attributes) { // dynamically search for a translation of the attribute int id = res.getIdentifier("attribute_" + attribute, "string", base.context.getPackageName()); diff --git a/src/cgeo/geocaching/cgeogpxes.java b/src/cgeo/geocaching/cgeogpxes.java index 380f0f7..64d5bf8 100644 --- a/src/cgeo/geocaching/cgeogpxes.java +++ b/src/cgeo/geocaching/cgeogpxes.java @@ -3,6 +3,10 @@ package cgeo.geocaching; import java.io.File; import java.util.ArrayList; +import cgeo.geocaching.files.FileList; +import cgeo.geocaching.files.GPXParser; +import cgeo.geocaching.files.LocParser; + import android.app.ProgressDialog; import android.os.Bundle; import android.os.Environment; diff --git a/src/cgeo/geocaching/cgeovisit.java b/src/cgeo/geocaching/cgeovisit.java index 767363d..c26dba4 100644 --- a/src/cgeo/geocaching/cgeovisit.java +++ b/src/cgeo/geocaching/cgeovisit.java @@ -774,7 +774,7 @@ public class cgeovisit extends cgLogForm { logNow.type = typeSelected; logNow.log = log; - if (cache != null) { + if (cache != null && null != cache.logs) { cache.logs.add(0, logNow); } app.addLog(geocode, logNow); @@ -817,4 +817,4 @@ public class cgeovisit extends cgLogForm { return 1000; } -}
\ No newline at end of file +} diff --git a/src/cgeo/geocaching/compatibility/Compatibility.java b/src/cgeo/geocaching/compatibility/Compatibility.java index 7d83fb6..18ee8a8 100644 --- a/src/cgeo/geocaching/compatibility/Compatibility.java +++ b/src/cgeo/geocaching/compatibility/Compatibility.java @@ -15,7 +15,7 @@ public final class Compatibility { private static AndroidLevel8 getLevel8() { if (!initialized) { try { - final int sdk = new Integer(Build.VERSION.SDK).intValue(); + final int sdk = Integer.valueOf(Build.VERSION.SDK).intValue(); if (sdk >= 8) { level8 = new AndroidLevel8(); } @@ -52,7 +52,7 @@ public final class Compatibility { } public static Uri getCalendarProviderURI() { - final int sdk = new Integer(Build.VERSION.SDK).intValue(); + final int sdk = Integer.valueOf(Build.VERSION.SDK).intValue(); if (sdk >= 8) { return Uri.parse("content://com.android.calendar/calendars"); } else { @@ -61,7 +61,7 @@ public final class Compatibility { } public static Uri getCalenderEventsProviderURI() { - final int sdk = new Integer(Build.VERSION.SDK).intValue(); + final int sdk = Integer.valueOf(Build.VERSION.SDK).intValue(); if (sdk >= 8) { return Uri.parse("content://com.android.calendar/events"); } else { diff --git a/src/cgeo/geocaching/FileList.java b/src/cgeo/geocaching/files/FileList.java index 545ad52..67e89a0 100644 --- a/src/cgeo/geocaching/FileList.java +++ b/src/cgeo/geocaching/files/FileList.java @@ -1,4 +1,4 @@ -package cgeo.geocaching; +package cgeo.geocaching.files; import java.io.File; import java.util.ArrayList; @@ -11,6 +11,8 @@ import android.os.Handler; import android.os.Message; import android.util.Log; import android.widget.ArrayAdapter; +import cgeo.geocaching.R; +import cgeo.geocaching.cgSettings; import cgeo.geocaching.activity.AbstractListActivity; public abstract class FileList<T extends ArrayAdapter<File>> extends AbstractListActivity { diff --git a/src/cgeo/geocaching/FileParser.java b/src/cgeo/geocaching/files/FileParser.java index d67c888..4e6cdf7 100644 --- a/src/cgeo/geocaching/FileParser.java +++ b/src/cgeo/geocaching/files/FileParser.java @@ -1,4 +1,4 @@ -package cgeo.geocaching;
+package cgeo.geocaching.files;
import java.io.BufferedReader;
import java.io.File;
@@ -7,6 +7,10 @@ import java.io.FileReader; import java.io.IOException;
import java.util.Date;
+import cgeo.geocaching.cgBase;
+import cgeo.geocaching.cgCache;
+import cgeo.geocaching.cgSearch;
+
import android.os.Handler;
import android.os.Message;
diff --git a/src/cgeo/geocaching/GPX10Parser.java b/src/cgeo/geocaching/files/GPX10Parser.java index a1bcef4..7bb3cb5 100644 --- a/src/cgeo/geocaching/GPX10Parser.java +++ b/src/cgeo/geocaching/files/GPX10Parser.java @@ -1,5 +1,7 @@ -package cgeo.geocaching;
+package cgeo.geocaching.files;
+import cgeo.geocaching.cgSearch;
+import cgeo.geocaching.cgeoapplication;
import android.sax.Element;
public final class GPX10Parser extends GPXParser {
diff --git a/src/cgeo/geocaching/GPX11Parser.java b/src/cgeo/geocaching/files/GPX11Parser.java index 0f946b3..d890e6d 100644 --- a/src/cgeo/geocaching/GPX11Parser.java +++ b/src/cgeo/geocaching/files/GPX11Parser.java @@ -1,5 +1,7 @@ -package cgeo.geocaching;
+package cgeo.geocaching.files;
+import cgeo.geocaching.cgSearch;
+import cgeo.geocaching.cgeoapplication;
import android.sax.Element;
public final class GPX11Parser extends GPXParser {
diff --git a/src/cgeo/geocaching/GPXParser.java b/src/cgeo/geocaching/files/GPXParser.java index 000c745..80764a7 100644 --- a/src/cgeo/geocaching/GPXParser.java +++ b/src/cgeo/geocaching/files/GPXParser.java @@ -1,4 +1,4 @@ -package cgeo.geocaching; +package cgeo.geocaching.files; import java.io.File; import java.io.FileInputStream; @@ -11,6 +11,14 @@ import java.util.regex.Pattern; import org.xml.sax.Attributes; import org.xml.sax.SAXException; +import cgeo.geocaching.cgBase; +import cgeo.geocaching.cgCache; +import cgeo.geocaching.cgLog; +import cgeo.geocaching.cgSearch; +import cgeo.geocaching.cgSettings; +import cgeo.geocaching.cgTrackable; +import cgeo.geocaching.cgeoapplication; + import android.os.Handler; import android.sax.Element; import android.sax.EndElementListener; diff --git a/src/cgeo/geocaching/LocParser.java b/src/cgeo/geocaching/files/LocParser.java index 21e9e02..e05b5f6 100644 --- a/src/cgeo/geocaching/LocParser.java +++ b/src/cgeo/geocaching/files/LocParser.java @@ -1,4 +1,4 @@ -package cgeo.geocaching;
+package cgeo.geocaching.files;
import java.io.File;
import java.util.HashMap;
@@ -6,6 +6,14 @@ import java.util.Map.Entry; import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import cgeo.geocaching.cgBase;
+import cgeo.geocaching.cgCache;
+import cgeo.geocaching.cgCacheWrap;
+import cgeo.geocaching.cgCoord;
+import cgeo.geocaching.cgSearch;
+import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.cgeoapplication;
+
import android.os.Handler;
import android.util.Log;
|
