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() {
|
public Result doWork() {
|
||||||
try {
|
try {
|
||||||
songSyncWorker.syncSongCreations();
|
songSyncWorker.syncSongCreations();
|
||||||
|
songSyncWorker.syncSongModifications();
|
||||||
return Result.success();
|
return Result.success();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return Result.failure();
|
return Result.failure();
|
||||||
|
@ -17,6 +17,7 @@ import retrofit2.Call;
|
|||||||
import retrofit2.Callback;
|
import retrofit2.Callback;
|
||||||
import retrofit2.Response;
|
import retrofit2.Response;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
@ -79,7 +80,7 @@ public class SongSyncWorker {
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<SongModificationBatchResponse> call, Response<SongModificationBatchResponse> response) {
|
public void onResponse(Call<SongModificationBatchResponse> call, Response<SongModificationBatchResponse> response) {
|
||||||
executorService.execute(() -> {
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
public class SongModificationBatchResponse {
|
public class SongModificationBatchResponse {
|
||||||
private List<String> updated_songs;
|
private List<String> songs;
|
||||||
|
|
||||||
public SongModificationBatchResponse(List<String> updated_songs) {
|
public SongModificationBatchResponse(List<String> songs) {
|
||||||
this.updated_songs = updated_songs;
|
this.songs = songs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getUpdated_songs() {
|
public List<String> getUpdated_songs() {
|
||||||
return updated_songs;
|
return songs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUpdated_songs(List<String> updated_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.genre = genre;
|
||||||
this.year = year;
|
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.setComposer(composer);
|
||||||
song.setGenre(genre);
|
song.setGenre(genre);
|
||||||
song.setYear(year);
|
song.setYear(year);
|
||||||
song.setSyncStatus(SyncStatus.MODIFIED);
|
|
||||||
|
if(song.getSyncStatus() == SyncStatus.SYNCED) {
|
||||||
|
song.setSyncStatus(SyncStatus.MODIFIED);
|
||||||
|
}
|
||||||
|
|
||||||
songEditorListener.onSongEdited(song);
|
songEditorListener.onSongEdited(song);
|
||||||
} )
|
} )
|
||||||
|
Loading…
Reference in New Issue
Block a user