private void setDefaultValues() { date = Calendar.getInstance(); rating = 0.0; if (cache.isEventCache()) { final Date eventDate = cache.getHiddenDate(); boolean expired = DateUtils.daysSince(eventDate.getTime()) > 0; if (cache.hasOwnLog(LogType.WILL_ATTEND) || expired) { if (cache.hasOwnLog(LogType.ATTENDED)) { typeSelected = LogType.NOTE; } else { typeSelected = LogType.ATTENDED; } } else { typeSelected = LogType.WILL_ATTEND; } } else { if (cache.isFound()) { typeSelected = LogType.NOTE; } else { typeSelected = LogType.FOUND_IT; } } text = null; imageCaption = StringUtils.EMPTY; imageDescription = StringUtils.EMPTY; imageUri = Uri.EMPTY; }
/** * @param excludeDisabled * @param excludeMine * @param cacheType * @return */ public SearchResult filterSearchResults( final boolean excludeDisabled, final boolean excludeMine, final CacheType cacheType) { SearchResult result = new SearchResult(this); result.geocodes.clear(); final ArrayList<Geocache> includedCaches = new ArrayList<Geocache>(); final Set<Geocache> caches = DataStore.loadCaches(geocodes, LoadFlags.LOAD_CACHE_OR_DB); int excluded = 0; for (Geocache cache : caches) { // Is there any reason to exclude the cache from the list? final boolean excludeCache = (excludeDisabled && cache.isDisabled()) || (excludeMine && (cache.isOwner() || cache.isFound())) || (!cacheType.contains(cache)); if (excludeCache) { excluded++; } else { includedCaches.add(cache); } } result.addAndPutInCache(includedCaches); // decrease maximum number of caches by filtered ones result.setTotalCountGC(result.getTotalCountGC() - excluded); GCVote.loadRatings(includedCaches); return result; }
public static void testMergePopupLivemap() { final Geocache livemap = new Geocache(); livemap.setGeocode("GC12345"); livemap.setCoords(new Geopoint(40.0, 8.0), 12); livemap.setFound(true); final Geocache popup = new Geocache(); popup.setGeocode("GC12345"); popup.setType(CacheType.MULTI); popup.gatherMissingFrom(livemap); assertThat(popup.getType()).as("merged type").isEqualTo(CacheType.MULTI); assertThat(popup.getCoords()).as("merged coordinates").isEqualTo(new Geopoint(40.0, 8.0)); assertThat(popup.isFound()).overridingErrorMessage("merged found").isTrue(); assertThat(popup.getCoordZoomLevel()).as("merged zoomlevel").isEqualTo(12); }