private void download() { try { showProgress(); final SearchResult searchResult = DataStore.loadCachedInViewport(getViewport(), Settings.getCacheType()); if (Settings.isGCConnectorActive() && tokens == null) { tokens = GCLogin.getInstance().getMapTokens(); if (StringUtils.isEmpty(tokens.getUserSession()) || StringUtils.isEmpty(tokens.getSessionToken())) { tokens = null; // TODO: show missing map token toast // if (!noMapTokenShowed) { // ActivityMixin.showToast(activity, // res.getString(R.string.map_token_err)); // noMapTokenShowed = true; // } } } searchResult.addSearchResult( ConnectorFactory.searchByViewport(getViewport().resize(1.2), tokens)); final Set<Geocache> result = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB); AbstractCachesOverlay.filter(result); // update the caches // first remove filtered out final Set<String> filteredCodes = searchResult.getFilteredGeocodes(); Log.d("Filtering out " + filteredCodes.size() + " caches: " + filteredCodes.toString()); DataStore.removeCaches(filteredCodes, EnumSet.of(RemoveFlag.CACHE)); Log.d(String.format(Locale.ENGLISH, "Live caches found: %d", result.size())); // render fill(result); } finally { hideProgress(); } }
@Override public void onDestroy() { timer.unsubscribe(); super.onDestroy(); }