Пример #1
0
 private void setCoordsModificationVisibility(final IConnector con, final Geocache cache) {
   if (cache != null
       && (cache.getType() == CacheType.MYSTERY || cache.getType() == CacheType.MULTI)) {
     coordinatesGroup.setVisibility(View.VISIBLE);
     modifyBoth.setVisibility(con.supportsOwnCoordinates() ? View.VISIBLE : View.GONE);
   } else {
     coordinatesGroup.setVisibility(View.GONE);
     modifyBoth.setVisibility(View.GONE);
   }
 }
Пример #2
0
  public static void testMergeLivemapStored() {
    final Geocache stored = new Geocache();
    stored.setGeocode("GC12345");
    stored.setDetailed(true);
    stored.setDisabled(true);
    stored.setType(CacheType.TRADITIONAL);
    stored.setCoords(new Geopoint(40.0, 8.0));
    saveFreshCacheToDB(stored);

    final Geocache livemap = new Geocache();
    livemap.setGeocode("GC12345");
    livemap.setType(CacheType.MULTI, 12);
    livemap.setCoords(new Geopoint(41.0, 9.0), 12);

    livemap.gatherMissingFrom(stored);

    assertThat(livemap.isDetailed()).as("merged detailed").isTrue();
    assertThat(livemap.isDisabled()).as("merged disabled").isTrue();
    assertThat(livemap.getType()).as("merged type").isEqualTo(CacheType.TRADITIONAL);
    assertThat(livemap.getCoords())
        .as("merged coordinates")
        .isEqualToComparingFieldByField(new Geopoint(40.0, 8.0));
    assertThat(livemap.getCoordZoomLevel())
        .as("merged zoomlevel")
        .isEqualTo(stored.getCoordZoomLevel());
  }
Пример #3
0
  public static void testMergeLivemap() {
    final Geocache previous = new Geocache();
    previous.setGeocode("GC12345");
    previous.setDetailed(true);
    previous.setDisabled(true);
    previous.setType(CacheType.TRADITIONAL);
    previous.setCoords(new Geopoint(40.0, 8.0));
    removeCacheCompletely(previous.getGeocode());

    final Geocache livemap = new Geocache();
    livemap.setGeocode("GC12345");
    livemap.setType(CacheType.MULTI, 12);
    livemap.setCoords(new Geopoint(41.0, 9.0), 12);

    livemap.gatherMissingFrom(previous);

    assertThat(livemap.isDetailed()).as("merged detailed").isTrue();
    assertThat(livemap.isDisabled()).as("merged disabled").isTrue();
    assertThat(livemap.getType()).as("merged type").isEqualTo(CacheType.TRADITIONAL);
    assertThat(livemap.getCoords())
        .as("merged coordinates")
        .isEqualToComparingFieldByField(new Geopoint(40.0, 8.0));
    assertThat(livemap.getCoordZoomLevel())
        .as("merged zoomlevel")
        .isEqualTo(previous.getCoordZoomLevel());
  }
Пример #4
0
  public static void testMergeDownloadedStored() {
    final Geocache stored = new Geocache();
    stored.setGeocode("GC12345");
    stored.setDetailed(true);
    stored.setDisabled(true);
    stored.setType(CacheType.TRADITIONAL);
    stored.setCoords(new Geopoint(40.0, 8.0));
    stored.setDescription("Test1");
    stored.setAttributes(Collections.singletonList("TestAttribute"));
    stored.setShortDescription("Short");
    stored.setHint("Hint");
    saveFreshCacheToDB(stored);

    final Geocache download = new Geocache();
    download.setGeocode("GC12345");
    download.setDetailed(true);
    download.setDisabled(false);
    download.setType(CacheType.MULTI);
    download.setCoords(new Geopoint(41.0, 9.0));
    download.setDescription("Test2");
    download.setAttributes(Collections.<String>emptyList());

    download.gatherMissingFrom(stored);

    assertThat(download.isDetailed()).as("merged detailed").isTrue();
    assertThat(download.isDisabled()).as("merged disabled").isFalse();
    assertThat(download.getType()).as("merged download").isEqualTo(CacheType.MULTI);
    assertThat(download.getCoords()).as("merged coordinates").isEqualTo(new Geopoint(41.0, 9.0));
    assertThat(download.getDescription()).as("merged description").isEqualTo("Test2");
    assertThat(download.getShortDescription()).as("merged short description").isEmpty();
    assertThat(download.getAttributes()).as("merged attributes").isEmpty();
    assertThat(download.getHint()).as("merged hint").isEmpty();
  }
Пример #5
0
  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);
  }
Пример #6
0
  public static void testMergeLivemapZoomout() {
    final Geocache livemapFirst = new Geocache();
    livemapFirst.setGeocode("GC12345");
    livemapFirst.setType(CacheType.TRADITIONAL, 12);
    livemapFirst.setCoords(new Geopoint(40.0, 8.0), 12);

    final Geocache livemapSecond = new Geocache();
    livemapSecond.setGeocode("GC12345");
    livemapSecond.setType(CacheType.MULTI, 11);
    livemapSecond.setCoords(new Geopoint(41.0, 9.0), 11);

    livemapSecond.gatherMissingFrom(livemapFirst);

    assertThat(livemapSecond.getType()).as("merged type").isEqualTo(CacheType.TRADITIONAL);
    assertThat(livemapSecond.getCoords())
        .as("merged coordinates")
        .isEqualTo(new Geopoint(40.0, 8.0));
    assertThat(livemapSecond.getCoordZoomLevel()).as("merged zoomlevel").isEqualTo(12);
  }
Пример #7
0
  private int getDefaultWaypointType() {
    // potentially restore saved instance state
    if (waypointTypeSelectorPosition >= 0) {
      return waypointTypeSelectorPosition;
    }

    // when editing, use the existing type
    if (waypoint != null) {
      return POSSIBLE_WAYPOINT_TYPES.indexOf(waypoint.getWaypointType());
    }

    // make default for new waypoint depend on cache type
    switch (cache.getType()) {
      case MYSTERY:
        return POSSIBLE_WAYPOINT_TYPES.indexOf(WaypointType.FINAL);
      case MULTI:
        return POSSIBLE_WAYPOINT_TYPES.indexOf(WaypointType.STAGE);
      default:
        return POSSIBLE_WAYPOINT_TYPES.indexOf(WaypointType.WAYPOINT);
    }
  }