- long lastUpdate = profile.getLongOption(MLDB.OPT_LAST_SCRAPE, 0L);
-
- Logger.debug("transactions", String.format(Locale.ENGLISH, "Last update = %d", lastUpdate));
- if (lastUpdate == 0) {
- Data.lastUpdateDate.postValue(null);
- }
- else {
- Data.lastUpdateDate.postValue(new Date(lastUpdate));
- }
-
- scheduleDataRetrievalIfStale(lastUpdate);
-
+ DB.get()
+ .getOptionDAO()
+ .load(profile.getId(), Option.OPT_LAST_SCRAPE)
+ .observe(this, opt -> {
+ long lastUpdate = 0;
+ if (opt != null) {
+ try {
+ lastUpdate = Long.parseLong(opt.getValue());
+ }
+ catch (NumberFormatException ex) {
+ Logger.debug(TAG, String.format("Error parsing '%s' as long", opt.getValue()),
+ ex);
+ }
+ }
+
+ if (lastUpdate == 0) {
+ Data.lastUpdateDate.postValue(null);
+ }
+ else {
+ Data.lastUpdateDate.postValue(new Date(lastUpdate));
+ }
+
+ scheduleDataRetrievalIfStale(lastUpdate);
+ });