Skip to content

Commit b02df8a

Browse files
committed
Now calling onDatabaseUpdated even when the database revision stays the same
1 parent d8d7645 commit b02df8a

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

core/src/main/java/io/snabble/sdk/ProductDatabase.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,6 @@ synchronized void applyDeltaUpdate(InputStream inputStream) throws IOException {
399399

400400
long time2 = SystemClock.elapsedRealtime() - time;
401401
Logger.d("Delta update (%d -> %d) took %d ms", fromRevisionId, getRevisionId(), time2);
402-
403-
updateLastUpdateTimestamp(System.currentTimeMillis());
404-
405-
notifyOnDatabaseUpdated();
406-
407-
return;
408402
}
409403

410404
/**
@@ -437,10 +431,6 @@ synchronized void applyFullUpdate(InputStream inputStream) throws IOException {
437431

438432
long time2 = SystemClock.elapsedRealtime() - time;
439433
Logger.d("Full update took %d ms", time2);
440-
441-
updateLastUpdateTimestamp(System.currentTimeMillis());
442-
443-
notifyOnDatabaseUpdated();
444434
}
445435

446436
/**
@@ -464,6 +454,9 @@ public void update(final UpdateCallback callback) {
464454
productDatabaseDownloader.loadAsync(new Downloader.Callback() {
465455
@Override
466456
protected void onDataLoaded(boolean wasStillValid) {
457+
updateLastUpdateTimestamp(System.currentTimeMillis());
458+
notifyOnDatabaseUpdated();
459+
467460
if (callback != null) {
468461
callback.success();
469462
}
@@ -472,6 +465,9 @@ protected void onDataLoaded(boolean wasStillValid) {
472465
@Override
473466
protected void onError() {
474467
if (productDatabaseDownloader.wasSameRevision()) {
468+
updateLastUpdateTimestamp(System.currentTimeMillis());
469+
notifyOnDatabaseUpdated();
470+
475471
if (callback != null) {
476472
callback.success();
477473
}

core/src/main/java/io/snabble/sdk/ProductDatabaseDownloader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public void onStartDownload() {
4343
protected void onDownloadFailed(Response response) {
4444
if (response != null && response.code() == 304) {
4545
sameRevision = true;
46-
productDatabase.updateLastUpdateTimestamp(System.currentTimeMillis());
4746
} else {
4847
sameRevision = false;
4948
}

0 commit comments

Comments
 (0)