Sync Modifications with Server
This commit is contained in:
parent
03ffad650c
commit
a550ff0ac8
@ -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();
|
||||
|
@ -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<SongModificationBatchResponse> call, Response<SongModificationBatchResponse> response) {
|
||||
executorService.execute(() -> {
|
||||
|
||||
database.storeSongSyncModifyResponses(response.body().getUpdated_songs(), SyncStatus.SYNCED, LocalDateTime.now());
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -3,17 +3,17 @@ package core.notevault.sync.synchronisation.songs.modification;
|
||||
import java.util.List;
|
||||
|
||||
public class SongModificationBatchResponse {
|
||||
private List<String> updated_songs;
|
||||
private List<String> songs;
|
||||
|
||||
public SongModificationBatchResponse(List<String> updated_songs) {
|
||||
this.updated_songs = updated_songs;
|
||||
public SongModificationBatchResponse(List<String> songs) {
|
||||
this.songs = songs;
|
||||
}
|
||||
|
||||
public List<String> getUpdated_songs() {
|
||||
return updated_songs;
|
||||
return songs;
|
||||
}
|
||||
|
||||
public void setUpdated_songs(List<String> updated_songs) {
|
||||
this.updated_songs = updated_songs;
|
||||
this.songs = updated_songs;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,10 @@ public class SongEditDialog extends DialogFragment {
|
||||
song.setComposer(composer);
|
||||
song.setGenre(genre);
|
||||
song.setYear(year);
|
||||
|
||||
if(song.getSyncStatus() == SyncStatus.SYNCED) {
|
||||
song.setSyncStatus(SyncStatus.MODIFIED);
|
||||
}
|
||||
|
||||
songEditorListener.onSongEdited(song);
|
||||
} )
|
||||
|
Loading…
Reference in New Issue
Block a user