diff --git a/app/src/main/java/core/notevault/sync/SyncWorker.java b/app/src/main/java/core/notevault/sync/SyncWorker.java index c3b978e..33fa9a5 100644 --- a/app/src/main/java/core/notevault/sync/SyncWorker.java +++ b/app/src/main/java/core/notevault/sync/SyncWorker.java @@ -39,6 +39,7 @@ public class SyncWorker extends Worker{ public Result doWork() { try { songSyncWorker.syncSongCreations(); + songSyncWorker.syncSongModifications(); return Result.success(); } catch (Exception e) { return Result.failure(); diff --git a/app/src/main/java/core/notevault/sync/synchronisation/songs/SongSyncWorker.java b/app/src/main/java/core/notevault/sync/synchronisation/songs/SongSyncWorker.java index 2ba1d39..f48e7fd 100644 --- a/app/src/main/java/core/notevault/sync/synchronisation/songs/SongSyncWorker.java +++ b/app/src/main/java/core/notevault/sync/synchronisation/songs/SongSyncWorker.java @@ -17,6 +17,7 @@ import retrofit2.Call; import retrofit2.Callback; import retrofit2.Response; +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.List; import java.util.concurrent.ExecutorService; @@ -79,7 +80,7 @@ public class SongSyncWorker { @Override public void onResponse(Call call, Response response) { executorService.execute(() -> { - + database.storeSongSyncModifyResponses(response.body().getUpdated_songs(), SyncStatus.SYNCED, LocalDateTime.now()); }); } diff --git a/app/src/main/java/core/notevault/sync/synchronisation/songs/modification/SongModificationBatchResponse.java b/app/src/main/java/core/notevault/sync/synchronisation/songs/modification/SongModificationBatchResponse.java index 86fa4a4..1ad55ac 100644 --- a/app/src/main/java/core/notevault/sync/synchronisation/songs/modification/SongModificationBatchResponse.java +++ b/app/src/main/java/core/notevault/sync/synchronisation/songs/modification/SongModificationBatchResponse.java @@ -3,17 +3,17 @@ package core.notevault.sync.synchronisation.songs.modification; import java.util.List; public class SongModificationBatchResponse { - private List updated_songs; + private List songs; - public SongModificationBatchResponse(List updated_songs) { - this.updated_songs = updated_songs; + public SongModificationBatchResponse(List songs) { + this.songs = songs; } public List getUpdated_songs() { - return updated_songs; + return songs; } public void setUpdated_songs(List updated_songs) { - this.updated_songs = updated_songs; + this.songs = updated_songs; } } diff --git a/app/src/main/java/core/notevault/sync/synchronisation/songs/modification/SongModificationRequest.java b/app/src/main/java/core/notevault/sync/synchronisation/songs/modification/SongModificationRequest.java index bfb8d73..e2fc333 100644 --- a/app/src/main/java/core/notevault/sync/synchronisation/songs/modification/SongModificationRequest.java +++ b/app/src/main/java/core/notevault/sync/synchronisation/songs/modification/SongModificationRequest.java @@ -14,4 +14,44 @@ public class SongModificationRequest { this.genre = genre; this.year = year; } + + public String getServerID() { + return serverID; + } + + public void setServerID(String serverID) { + this.serverID = serverID; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getComposer() { + return composer; + } + + public void setComposer(String composer) { + this.composer = composer; + } + + public String getGenre() { + return genre; + } + + public void setGenre(String genre) { + this.genre = genre; + } + + public int getYear() { + return year; + } + + public void setYear(int year) { + this.year = year; + } } diff --git a/app/src/main/java/core/notevault/ui/metadatadialog/SongEditDialog.java b/app/src/main/java/core/notevault/ui/metadatadialog/SongEditDialog.java index d0e156d..85bc808 100644 --- a/app/src/main/java/core/notevault/ui/metadatadialog/SongEditDialog.java +++ b/app/src/main/java/core/notevault/ui/metadatadialog/SongEditDialog.java @@ -56,7 +56,10 @@ public class SongEditDialog extends DialogFragment { song.setComposer(composer); song.setGenre(genre); song.setYear(year); - song.setSyncStatus(SyncStatus.MODIFIED); + + if(song.getSyncStatus() == SyncStatus.SYNCED) { + song.setSyncStatus(SyncStatus.MODIFIED); + } songEditorListener.onSongEdited(song); } )