コード例 #1
0
ファイル: OkapiClientTest.java プロジェクト: sababys/cgeo
  public static void testOCCacheWithWaypoints() {
    final String geoCode = "OCDDD2";
    removeCacheCompletely(geoCode);
    Geocache cache = OkapiClient.getCache(geoCode);
    assertThat(cache).as("Cache from OKAPI").isNotNull();
    // cache should be stored to DB (to listID 0) when loaded above
    cache = DataStore.loadCache(geoCode, LoadFlags.LOAD_ALL_DB_ONLY);
    assert cache != null;
    assertThat(cache).isNotNull();
    assertThat(cache.getWaypoints()).hasSize(3);

    // load again
    cache.refreshSynchronous(null);
    assertThat(cache.getWaypoints()).hasSize(3);
  }
コード例 #2
0
  private void addWaypoints(final SubMenu subMenu) {
    subMenu.clear();
    for (final Waypoint waypoint : geocache.getWaypoints()) {
      if (waypoint.getCoords() != null) {
        subMenu
            .add(Menu.NONE, waypoint.getId(), Menu.NONE, waypoint.getName())
            .setOnMenuItemClickListener(
                new OnMenuItemClickListener() {

                  @Override
                  public boolean onMenuItemClick(final MenuItem item) {
                    callback.onWaypointSelected(waypoint);
                    return true;
                  }
                });
      }
    }
    subMenu
        .add(Menu.NONE, Menu.NONE, Menu.NONE, getContext().getString(R.string.cache))
        .setOnMenuItemClickListener(
            new OnMenuItemClickListener() {

              @Override
              public boolean onMenuItemClick(final MenuItem item) {
                callback.onGeocacheSelected(geocache);
                return true;
              }
            });
  }
コード例 #3
0
 private static boolean hasTargets(final Geocache cache) {
   for (final Waypoint waypoint : cache.getWaypoints()) {
     if (waypoint.getCoords() != null) {
       return true;
     }
   }
   return false;
 }