aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2012-08-13 20:14:18 +0200
committerBananeweizen <bananeweizen@gmx.de>2012-08-13 20:14:18 +0200
commit1825b569318b908f1f2e9fbec6b66c2a2b9e8850 (patch)
tree518e2ea366eca221220badf712f01ee02018fd0f
parentaa0e5484ce74bcbe33b199a718d265dce76be9cc (diff)
downloadcgeo-1825b569318b908f1f2e9fbec6b66c2a2b9e8850.zip
cgeo-1825b569318b908f1f2e9fbec6b66c2a2b9e8850.tar.gz
cgeo-1825b569318b908f1f2e9fbec6b66c2a2b9e8850.tar.bz2
refactoring: only iterate selected caches during refresh
-rw-r--r--main/src/cgeo/geocaching/cgeocaches.java23
1 files changed, 6 insertions, 17 deletions
diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java
index dad1a2c..d735327 100644
--- a/main/src/cgeo/geocaching/cgeocaches.java
+++ b/main/src/cgeo/geocaching/cgeocaches.java
@@ -1367,18 +1367,15 @@ public class cgeocaches extends AbstractListActivity {
final private Handler handler;
final private int listIdLD;
private volatile boolean needToStop = false;
- private int checked = 0;
private long last = 0L;
+ final private List<cgCache> selected;
public LoadDetailsThread(Handler handlerIn, int listId) {
handler = handlerIn;
+ selected = adapter.getCheckedOrAllCaches();
// in case of online lists, set the list id to the standard list
this.listIdLD = Math.max(listId, StoredList.STANDARD_LIST_ID);
-
- if (adapter != null) {
- checked = adapter.getCheckedCount();
- }
}
public void kill() {
@@ -1389,15 +1386,8 @@ public class cgeocaches extends AbstractListActivity {
public void run() {
removeGeoAndDir();
- final List<cgCache> cacheListTemp = new ArrayList<cgCache>(cacheList);
- final List<cgCache> weHaveStaticMaps = new ArrayList<cgCache>(cacheList.size());
- for (cgCache cache : cacheListTemp) {
- if (checked > 0 && !cache.isStatusChecked()) {
- handler.sendEmptyMessage(0);
-
- yield();
- continue;
- }
+ final List<cgCache> weHaveStaticMaps = new ArrayList<cgCache>(selected.size());
+ for (cgCache cache : selected) {
if (Settings.isStoreOfflineMaps() && StaticMapsProvider.hasStaticMapForCache(cache.getGeocode())) {
weHaveStaticMaps.add(cache);
continue;
@@ -1408,7 +1398,6 @@ public class cgeocaches extends AbstractListActivity {
Log.i(e.getMessage());
}
}
- cacheListTemp.clear();
for (cgCache cache : weHaveStaticMaps) {
try {
@@ -1424,11 +1413,11 @@ public class cgeocaches extends AbstractListActivity {
/**
* Refreshes the cache information.
- *
+ *
* @param cache
* The cache to refresh
* @throws InterruptedException
- * interruted
+ * Interrupted
*/
private void refreshCache(cgCache cache) throws InterruptedException {
try {