Example #1
0
 public static void testGetOCCache() {
   final String geoCode = "OU0331";
   Geocache cache = OkapiClient.getCache(geoCode);
   assertThat(cache).as("Cache from OKAPI").isNotNull();
   assert cache != null; // eclipse null analysis
   assertThat(cache.getGeocode()).isEqualTo(geoCode);
   assertThat(cache.getName()).isEqualTo("Oshkosh Municipal Tank");
   assertThat(cache.isDetailed()).isTrue();
   // 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.getGeocode()).isEqualTo(geoCode);
   assertThat(cache.getName()).isEqualTo("Oshkosh Municipal Tank");
   assertThat(cache.isDetailed()).isTrue();
   assertThat(cache.getOwnerDisplayName()).isNotEmpty();
   assertThat(cache.getOwnerUserId()).isEqualTo(cache.getOwnerDisplayName());
 }
Example #2
0
 public static void testOCSearchMustWorkWithoutOAuthAccessTokens() {
   final String geoCode = "OC1234";
   final Geocache cache = OkapiClient.getCache(geoCode);
   assertThat(cache)
       .overridingErrorMessage(
           "You must have a valid OKAPI key installed for running this test (but you do not need to set credentials in the app).")
       .isNotNull();
   assert cache != null; // eclipse null analysis
   assertThat(cache.getName()).isEqualTo("Wupper-Schein");
 }
Example #3
0
  @Override
  public void onCreate(final Bundle savedInstanceState) {
    onCreate(savedInstanceState, R.layout.logcache_activity);

    // Get parameters from intent and basic cache information from database
    final Bundle extras = getIntent().getExtras();
    if (extras != null) {
      geocode = extras.getString(Intents.EXTRA_GEOCODE);
      if (StringUtils.isBlank(geocode)) {
        final String cacheid = extras.getString(Intents.EXTRA_ID);
        if (StringUtils.isNotBlank(cacheid)) {
          geocode = DataStore.getGeocodeForGuid(cacheid);
        }
      }
    }

    cache = DataStore.loadCache(geocode, LoadFlags.LOAD_CACHE_OR_DB);
    invalidateOptionsMenuCompatible();
    possibleLogTypes = cache.getPossibleLogTypes();

    if (StringUtils.isNotBlank(cache.getName())) {
      setTitle(res.getString(R.string.log_new_log) + ": " + cache.getName());
    } else {
      setTitle(res.getString(R.string.log_new_log) + ": " + cache.getGeocode());
    }

    initializeRatingBar();

    // initialize with default values
    setDefaultValues();

    // Restore previous state
    if (savedInstanceState != null) {
      rating = savedInstanceState.getFloat(SAVED_STATE_RATING);
      typeSelected = LogType.getById(savedInstanceState.getInt(SAVED_STATE_TYPE));
      date.setTimeInMillis(savedInstanceState.getLong(SAVED_STATE_DATE));
      image = savedInstanceState.getParcelable(SAVED_STATE_IMAGE);
      premFavPoints = savedInstanceState.getInt(SAVED_STATE_FAVPOINTS);
    } else {
      // If log had been previously saved, load it now, otherwise initialize signature as needed
      loadLogFromDatabase();
    }
    if (image == null) {
      image = Image.NONE;
    }
    enablePostButton(false);

    final Button typeButton = ButterKnife.findById(this, R.id.type);
    typeButton.setText(typeSelected.getL10n());
    typeButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(final View view) {
            selectLogType();
          }
        });

    final Button dateButton = ButterKnife.findById(this, R.id.date);
    setDate(date);
    dateButton.setOnClickListener(new DateListener());

    if (StringUtils.isBlank(currentLogText()) && StringUtils.isNotBlank(text)) {
      setLogText();
    }

    tweetCheck.setChecked(true);
    updateTweetBox(typeSelected);
    updateLogPasswordBox(typeSelected);

    loggingManager = cache.getLoggingManager(this);
    loggingManager.init();

    // Load Generic Trackables
    AppObservable.bindActivity(
            this,
            // Obtain the actives connectors
            Observable.from(ConnectorFactory.getLoggableGenericTrackablesConnectors())
                .flatMap(
                    new Func1<TrackableConnector, Observable<TrackableLog>>() {
                      @Override
                      public Observable<TrackableLog> call(
                          final TrackableConnector trackableConnector) {
                        return Observable.defer(
                                new Func0<Observable<TrackableLog>>() {
                                  @Override
                                  public Observable<TrackableLog> call() {
                                    return trackableConnector.trackableLogInventory();
                                  }
                                })
                            .subscribeOn(AndroidRxUtils.networkScheduler);
                      }
                    })
                .toList())
        .subscribe(
            new Action1<List<TrackableLog>>() {
              @Override
              public void call(final List<TrackableLog> trackableLogs) {
                // Store trackables
                trackables.addAll(trackableLogs);
                // Update the UI
                initializeTrackablesAction();
                updateTrackablesList();
              }
            });

    requestKeyboardForLogging();
  }