diff options
| -rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 6 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/activity/AbstractListActivity.java | 5 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgCache.java | 9 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgCacheListAdapter.java | 1 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgCacheView.java | 5 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 85 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgList.java | 1 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgTrackable.java | 7 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeoapplication.java | 1 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeocoords.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/files/GPXImporter.java | 3 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/files/LocalStorage.java | 10 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/go4cache/Go4CacheUser.java | 2 |
13 files changed, 73 insertions, 64 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index eefe69a..6fd6452 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -1966,13 +1966,15 @@ public class CacheDetailActivity extends AbstractActivity { protected Void doInBackground(Void... params) { // log count if (cache != null && cache.getLogCounts() != null) { - final StringBuilder text = new StringBuilder(); + final StringBuilder text = new StringBuilder(200); text.append(res.getString(R.string.cache_log_types)); text.append(": "); // sort the log counts by type id ascending. that way the FOUND, DNF log types are the first and most visible ones List<Entry<Integer, Integer>> sortedLogCounts = new ArrayList<Entry<Integer, Integer>>(); - sortedLogCounts.addAll(cache.getLogCounts().entrySet()); + for (Entry<Integer, Integer> entry : cache.getLogCounts().entrySet()) { + sortedLogCounts.add(entry); // don't add these entries using addAll(), the iterator in the EntrySet can go wrong (see Findbugs) + } Collections.sort(sortedLogCounts, new Comparator<Entry<Integer, Integer>>() { @Override diff --git a/main/src/cgeo/geocaching/activity/AbstractListActivity.java b/main/src/cgeo/geocaching/activity/AbstractListActivity.java index a1c7596..10e73a5 100644 --- a/main/src/cgeo/geocaching/activity/AbstractListActivity.java +++ b/main/src/cgeo/geocaching/activity/AbstractListActivity.java @@ -1,13 +1,10 @@ package cgeo.geocaching.activity; -import cgeo.geocaching.Settings; import cgeo.geocaching.cgBase; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgeoapplication; import android.app.ListActivity; -import android.content.Context; -import android.content.SharedPreferences; import android.content.res.Resources; import android.graphics.drawable.Drawable; import android.os.Bundle; @@ -21,7 +18,6 @@ public abstract class AbstractListActivity extends ListActivity implements protected cgeoapplication app = null; protected Resources res = null; - protected SharedPreferences prefs = null; protected AbstractListActivity() { this(null); @@ -70,7 +66,6 @@ public abstract class AbstractListActivity extends ListActivity implements // init res = this.getResources(); app = (cgeoapplication) this.getApplication(); - prefs = getSharedPreferences(Settings.preferences, Context.MODE_PRIVATE); cgBase.initialize(app); } diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index b1d064a..6977099 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -645,8 +645,13 @@ public class cgCache implements ICache { this.nameSp = nameSp; } - public void setHidden(Date hidden) { - this.hidden = hidden; + public void setHidden(final Date hidden) { + if (hidden == null) { + this.hidden = null; + } + else { + this.hidden = new Date(hidden.getTime()); // avoid storing the external reference in this object + } } public Float getDirection() { diff --git a/main/src/cgeo/geocaching/cgCacheListAdapter.java b/main/src/cgeo/geocaching/cgCacheListAdapter.java index 4b8c573..7f67bc6 100644 --- a/main/src/cgeo/geocaching/cgCacheListAdapter.java +++ b/main/src/cgeo/geocaching/cgCacheListAdapter.java @@ -343,7 +343,6 @@ public class cgCacheListAdapter extends ArrayAdapter<cgCache> { holder.oneInfo = (RelativeLayout) v.findViewById(R.id.one_info); holder.oneCheckbox = (RelativeLayout) v.findViewById(R.id.one_checkbox); holder.logStatusMark = (ImageView) v.findViewById(R.id.log_status_mark); - holder.oneCache = (RelativeLayout) v.findViewById(R.id.one_cache); holder.text = (TextView) v.findViewById(R.id.text); holder.directionLayout = (RelativeLayout) v.findViewById(R.id.direction_layout); holder.distance = (cgDistanceView) v.findViewById(R.id.distance); diff --git a/main/src/cgeo/geocaching/cgCacheView.java b/main/src/cgeo/geocaching/cgCacheView.java index 6b3b433..39f5a45 100644 --- a/main/src/cgeo/geocaching/cgCacheView.java +++ b/main/src/cgeo/geocaching/cgCacheView.java @@ -7,7 +7,6 @@ import android.widget.TextView; public class cgCacheView { // layouts & views - public RelativeLayout oneCache; public RelativeLayout oneInfo; public RelativeLayout oneCheckbox; public CheckBox checkbox; @@ -21,8 +20,4 @@ public class cgCacheView { public cgCompassMini direction; public RelativeLayout dirImgLayout; public ImageView dirImg; - - // status - public float startX = -1; - public float prevX = -1; } diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index 715ebed..c70e8c4 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -1671,8 +1671,8 @@ public class cgData { values.clear(); values.put("geocode", geocode); values.put("updated", timeStamp); - values.put("type", pair.getKey().intValue()); - values.put("count", pair.getValue().intValue()); + values.put("type", pair.getKey()); + values.put("count", pair.getValue()); databaseRW.insert(dbTableLogCount, null, values); } @@ -2015,44 +2015,45 @@ public class cgData { cgCache cache = new cgCache(); if (cacheColumnIndex == null) { - cacheColumnIndex = new int[37]; - cacheColumnIndex[0] = cursor.getColumnIndex("updated"); - cacheColumnIndex[1] = cursor.getColumnIndex("reason"); - cacheColumnIndex[2] = cursor.getColumnIndex("detailed"); - cacheColumnIndex[3] = cursor.getColumnIndex("detailedupdate"); - cacheColumnIndex[4] = cursor.getColumnIndex("visiteddate"); - cacheColumnIndex[5] = cursor.getColumnIndex("geocode"); - cacheColumnIndex[6] = cursor.getColumnIndex("cacheid"); - cacheColumnIndex[7] = cursor.getColumnIndex("guid"); - cacheColumnIndex[8] = cursor.getColumnIndex("type"); - cacheColumnIndex[9] = cursor.getColumnIndex("name"); - cacheColumnIndex[10] = cursor.getColumnIndex("own"); - cacheColumnIndex[11] = cursor.getColumnIndex("owner"); - cacheColumnIndex[12] = cursor.getColumnIndex("owner_real"); - cacheColumnIndex[13] = cursor.getColumnIndex("hidden"); - cacheColumnIndex[14] = cursor.getColumnIndex("hint"); - cacheColumnIndex[15] = cursor.getColumnIndex("size"); - cacheColumnIndex[16] = cursor.getColumnIndex("difficulty"); - cacheColumnIndex[17] = cursor.getColumnIndex("direction"); - cacheColumnIndex[18] = cursor.getColumnIndex("distance"); - cacheColumnIndex[19] = cursor.getColumnIndex("terrain"); - cacheColumnIndex[20] = cursor.getColumnIndex("latlon"); - cacheColumnIndex[21] = cursor.getColumnIndex("location"); - cacheColumnIndex[22] = cursor.getColumnIndex("elevation"); - cacheColumnIndex[23] = cursor.getColumnIndex("personal_note"); - cacheColumnIndex[24] = cursor.getColumnIndex("shortdesc"); - cacheColumnIndex[25] = cursor.getColumnIndex("favourite_cnt"); - cacheColumnIndex[26] = cursor.getColumnIndex("rating"); - cacheColumnIndex[27] = cursor.getColumnIndex("votes"); - cacheColumnIndex[28] = cursor.getColumnIndex("myvote"); - cacheColumnIndex[29] = cursor.getColumnIndex("disabled"); - cacheColumnIndex[30] = cursor.getColumnIndex("archived"); - cacheColumnIndex[31] = cursor.getColumnIndex("members"); - cacheColumnIndex[32] = cursor.getColumnIndex("found"); - cacheColumnIndex[33] = cursor.getColumnIndex("favourite"); - cacheColumnIndex[34] = cursor.getColumnIndex("inventoryunknown"); - cacheColumnIndex[35] = cursor.getColumnIndex("onWatchlist"); - cacheColumnIndex[36] = cursor.getColumnIndex("reliable_latlon"); + int[] local_cci = new int[37]; // use a local variable to avoid having the not yet fully initialized array be visible to other threads + local_cci[0] = cursor.getColumnIndex("updated"); + local_cci[1] = cursor.getColumnIndex("reason"); + local_cci[2] = cursor.getColumnIndex("detailed"); + local_cci[3] = cursor.getColumnIndex("detailedupdate"); + local_cci[4] = cursor.getColumnIndex("visiteddate"); + local_cci[5] = cursor.getColumnIndex("geocode"); + local_cci[6] = cursor.getColumnIndex("cacheid"); + local_cci[7] = cursor.getColumnIndex("guid"); + local_cci[8] = cursor.getColumnIndex("type"); + local_cci[9] = cursor.getColumnIndex("name"); + local_cci[10] = cursor.getColumnIndex("own"); + local_cci[11] = cursor.getColumnIndex("owner"); + local_cci[12] = cursor.getColumnIndex("owner_real"); + local_cci[13] = cursor.getColumnIndex("hidden"); + local_cci[14] = cursor.getColumnIndex("hint"); + local_cci[15] = cursor.getColumnIndex("size"); + local_cci[16] = cursor.getColumnIndex("difficulty"); + local_cci[17] = cursor.getColumnIndex("direction"); + local_cci[18] = cursor.getColumnIndex("distance"); + local_cci[19] = cursor.getColumnIndex("terrain"); + local_cci[20] = cursor.getColumnIndex("latlon"); + local_cci[21] = cursor.getColumnIndex("location"); + local_cci[22] = cursor.getColumnIndex("elevation"); + local_cci[23] = cursor.getColumnIndex("personal_note"); + local_cci[24] = cursor.getColumnIndex("shortdesc"); + local_cci[25] = cursor.getColumnIndex("favourite_cnt"); + local_cci[26] = cursor.getColumnIndex("rating"); + local_cci[27] = cursor.getColumnIndex("votes"); + local_cci[28] = cursor.getColumnIndex("myvote"); + local_cci[29] = cursor.getColumnIndex("disabled"); + local_cci[30] = cursor.getColumnIndex("archived"); + local_cci[31] = cursor.getColumnIndex("members"); + local_cci[32] = cursor.getColumnIndex("found"); + local_cci[33] = cursor.getColumnIndex("favourite"); + local_cci[34] = cursor.getColumnIndex("inventoryunknown"); + local_cci[35] = cursor.getColumnIndex("onWatchlist"); + local_cci[36] = cursor.getColumnIndex("reliable_latlon"); + cacheColumnIndex = local_cci; } cache.setUpdated(cursor.getLong(cacheColumnIndex[0])); @@ -3166,12 +3167,8 @@ public class cgData { cursor.moveToFirst(); int indexId = cursor.getColumnIndex("_id"); int indexTitle = cursor.getColumnIndex("title"); - int indexUpdated = cursor.getColumnIndex("updated"); - do { cgList list = new cgList(cursor.getInt(indexId) + 10, cursor.getString(indexTitle)); - list.updated = cursor.getLong(indexUpdated); - result.add(list); } while (cursor.moveToNext()); } diff --git a/main/src/cgeo/geocaching/cgList.java b/main/src/cgeo/geocaching/cgList.java index f176129..273f6d8 100644 --- a/main/src/cgeo/geocaching/cgList.java +++ b/main/src/cgeo/geocaching/cgList.java @@ -6,7 +6,6 @@ public class cgList { public int id = 0; public String title = null; - public Long updated = null; public cgList(int idIn, String titleIn) { id = idIn; diff --git a/main/src/cgeo/geocaching/cgTrackable.java b/main/src/cgeo/geocaching/cgTrackable.java index 862f614..95971f8 100644 --- a/main/src/cgeo/geocaching/cgTrackable.java +++ b/main/src/cgeo/geocaching/cgTrackable.java @@ -98,7 +98,12 @@ public class cgTrackable implements ILogable { } public void setReleased(Date released) { - this.released = released; + if (released == null) { + this.released = null; + } + else { + this.released = new Date(released.getTime()); // avoid storing external reference in this object + } } public Float getDistance() { diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java index 841a7fa..839d365 100644 --- a/main/src/cgeo/geocaching/cgeoapplication.java +++ b/main/src/cgeo/geocaching/cgeoapplication.java @@ -37,7 +37,6 @@ public class cgeoapplication extends Application { final private Map<String, cgCache> cachesCache = new HashMap<String, cgCache>(); // caching caches into memory public boolean firstRun = true; // c:geo is just launched public boolean showLoginToast = true; //login toast shown just once. - public boolean warnedLanguage = false; // user was warned about different language settings on geocaching.com private boolean databaseCleaned = false; // database was cleaned private static cgeoapplication instance; diff --git a/main/src/cgeo/geocaching/cgeocoords.java b/main/src/cgeo/geocaching/cgeocoords.java index c0c0c0f..83d694c 100644 --- a/main/src/cgeo/geocaching/cgeocoords.java +++ b/main/src/cgeo/geocaching/cgeocoords.java @@ -285,6 +285,8 @@ public class cgeocoords extends Dialog { case 'W': button.setText("E"); break; + default: + break; } calc(true); } diff --git a/main/src/cgeo/geocaching/files/GPXImporter.java b/main/src/cgeo/geocaching/files/GPXImporter.java index ab3f869..a021af0 100644 --- a/main/src/cgeo/geocaching/files/GPXImporter.java +++ b/main/src/cgeo/geocaching/files/GPXImporter.java @@ -371,6 +371,9 @@ public class GPXImporter { fromActivity.showShortToast(res.getString(R.string.gpx_import_canceled)); importFinished(); break; + + default: + break; } } }; diff --git a/main/src/cgeo/geocaching/files/LocalStorage.java b/main/src/cgeo/geocaching/files/LocalStorage.java index edfb93a..932bbf7 100644 --- a/main/src/cgeo/geocaching/files/LocalStorage.java +++ b/main/src/cgeo/geocaching/files/LocalStorage.java @@ -180,13 +180,21 @@ public class LocalStorage { public static boolean copy(final File source, final File destination) { destination.getParentFile().mkdirs(); - InputStream input; + InputStream input = null; OutputStream output; try { input = new FileInputStream(source); output = new FileOutputStream(destination); } catch (FileNotFoundException e) { Log.e(Settings.tag, "LocalStorage.copy: could not open file", e); + if (input != null) { + try { + input.close(); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } return false; } diff --git a/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java b/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java index 94399bd..5bdc209 100644 --- a/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java +++ b/main/src/cgeo/geocaching/go4cache/Go4CacheUser.java @@ -26,7 +26,7 @@ public class Go4CacheUser { public Go4CacheUser(final String username, final Geopoint coords, final Date date, final String action, final String client) { this.username = username; this.coords = coords; - this.date = date; + this.date = new Date(date.getTime()); this.action = action; this.client = client; } |
