From 63cf471530459dc2dcccac8437f83e1638b6c2fa Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Wed, 28 Apr 2021 23:22:01 +0200 Subject: [PATCH] #1167 Use Calendar instead of long for modified date in NotesAPI --- .../notes/persistence/NotesServerSyncTask.java | 4 ++-- .../owncloud/notes/persistence/sync/NotesAPI.java | 12 ++++++------ .../notes/persistence/sync/NotesAPI_0_2.java | 2 +- .../notes/persistence/sync/NotesAPI_1_0.java | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesServerSyncTask.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesServerSyncTask.java index 92397c37..d1604695 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesServerSyncTask.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/NotesServerSyncTask.java @@ -119,7 +119,7 @@ abstract class NotesServerSyncTask extends Thread { Log.v(TAG, " ...create/edit"); if (note.getRemoteId() != null) { Log.v(TAG, " ...Note has remoteId → try to edit"); - final Response editResponse = notesAPI.editNote(note, note.getRemoteId()).execute(); + final Response editResponse = notesAPI.editNote(note).execute(); if (editResponse.isSuccessful()) { remoteNote = editResponse.body(); } else { @@ -203,7 +203,7 @@ abstract class NotesServerSyncTask extends Thread { localAccount.setModified(accountFromDatabase.getModified()); localAccount.setETag(accountFromDatabase.getETag()); - final ParsedResponse> fetchResponse = notesAPI.getNotes(localAccount.getModified().getTimeInMillis() / 1_000, localAccount.getETag()).blockingSingle(); + final ParsedResponse> fetchResponse = notesAPI.getNotes(localAccount.getModified(), localAccount.getETag()).blockingSingle(); final List remoteNotes = fetchResponse.getResponse(); final Set remoteIDs = new HashSet<>(); // pull remote changes: update or create each remote note diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI.java index 20d5523c..151d5162 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI.java @@ -58,11 +58,11 @@ public class NotesAPI { } } - public Observable>> getNotes(long lastModified, String lastETag) { + public Observable>> getNotes(@NonNull Calendar lastModified, String lastETag) { if (ApiVersion.API_VERSION_1_0.equals(usedApiVersion)) { - return notesAPI_1_0.getNotes(lastModified, lastETag); + return notesAPI_1_0.getNotes(lastModified.getTimeInMillis() / 1_000, lastETag); } else if (ApiVersion.API_VERSION_0_2.equals(usedApiVersion)) { - return notesAPI_0_2.getNotes(lastModified, lastETag); + return notesAPI_0_2.getNotes(lastModified.getTimeInMillis() / 1_000, lastETag); } else { throw new UnsupportedOperationException("Used API version " + usedApiVersion + " does not support getNotes()."); } @@ -78,11 +78,11 @@ public class NotesAPI { } } - public Call editNote(Note note, long remoteId) { + public Call editNote(@NonNull Note note) { if (ApiVersion.API_VERSION_1_0.equals(usedApiVersion)) { - return notesAPI_1_0.editNote(note, remoteId); + return notesAPI_1_0.editNote(note, note.getRemoteId()); } else if (ApiVersion.API_VERSION_0_2.equals(usedApiVersion)) { - return notesAPI_0_2.editNote(new Note_0_2(note), remoteId); + return notesAPI_0_2.editNote(new Note_0_2(note), note.getRemoteId()); } else { throw new UnsupportedOperationException("Used API version " + usedApiVersion + " does not support editNote()."); } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_0_2.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_0_2.java index 75097359..fd642064 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_0_2.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_0_2.java @@ -23,7 +23,7 @@ import retrofit2.http.Query; public interface NotesAPI_0_2 { @GET("notes") - Observable>> getNotes(@Query(value = "pruneBefore") long lastModified, @Header("If-None-Match") String lastETag); + Observable>> getNotes(@Query("pruneBefore") long lastModified, @Header("If-None-Match") String lastETag); @POST("notes") Call createNote(@Body NotesAPI.Note_0_2 note); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_1_0.java b/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_1_0.java index 58cebb3b..fc4103e3 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_1_0.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/persistence/sync/NotesAPI_1_0.java @@ -23,7 +23,7 @@ import retrofit2.http.Query; public interface NotesAPI_1_0 { @GET("notes") - Observable>> getNotes(@Query(value = "pruneBefore") long lastModified, @Header("If-None-Match") String lastETag); + Observable>> getNotes(@Query("pruneBefore") long lastModified, @Header("If-None-Match") String lastETag); @POST("notes") Call createNote(@Body Note note);