#1167 Use Calendar instead of long for modified date in NotesAPI

This commit is contained in:
Stefan Niedermann 2021-04-28 23:22:01 +02:00
parent 0d9eb364f5
commit 63cf471530
4 changed files with 10 additions and 10 deletions

View file

@ -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<Note> editResponse = notesAPI.editNote(note, note.getRemoteId()).execute();
final Response<Note> 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<List<Note>> fetchResponse = notesAPI.getNotes(localAccount.getModified().getTimeInMillis() / 1_000, localAccount.getETag()).blockingSingle();
final ParsedResponse<List<Note>> fetchResponse = notesAPI.getNotes(localAccount.getModified(), localAccount.getETag()).blockingSingle();
final List<Note> remoteNotes = fetchResponse.getResponse();
final Set<Long> remoteIDs = new HashSet<>();
// pull remote changes: update or create each remote note

View file

@ -58,11 +58,11 @@ public class NotesAPI {
}
}
public Observable<ParsedResponse<List<Note>>> getNotes(long lastModified, String lastETag) {
public Observable<ParsedResponse<List<Note>>> 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<Note> editNote(Note note, long remoteId) {
public Call<Note> 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().");
}

View file

@ -23,7 +23,7 @@ import retrofit2.http.Query;
public interface NotesAPI_0_2 {
@GET("notes")
Observable<ParsedResponse<List<Note>>> getNotes(@Query(value = "pruneBefore") long lastModified, @Header("If-None-Match") String lastETag);
Observable<ParsedResponse<List<Note>>> getNotes(@Query("pruneBefore") long lastModified, @Header("If-None-Match") String lastETag);
@POST("notes")
Call<Note> createNote(@Body NotesAPI.Note_0_2 note);

View file

@ -23,7 +23,7 @@ import retrofit2.http.Query;
public interface NotesAPI_1_0 {
@GET("notes")
Observable<ParsedResponse<List<Note>>> getNotes(@Query(value = "pruneBefore") long lastModified, @Header("If-None-Match") String lastETag);
Observable<ParsedResponse<List<Note>>> getNotes(@Query("pruneBefore") long lastModified, @Header("If-None-Match") String lastETag);
@POST("notes")
Call<Note> createNote(@Body Note note);