mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 10:23:33 +00:00
Fix overwriting of data in song_genre_cross table
This commit is contained in:
parent
c6254c8416
commit
0305af2f9f
4 changed files with 17 additions and 16 deletions
|
|
@ -53,9 +53,17 @@ public class GenreRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertAll(ArrayList<Genre> genres) {
|
public void insertAll(ArrayList<Genre> genres) {
|
||||||
InsertAllThreadSafe insertAll = new InsertAllThreadSafe(genreDao, genres);
|
try {
|
||||||
Thread thread = new Thread(insertAll);
|
final Thread deleteAll = new Thread(new DeleteAllGenreThreadSafe(genreDao));
|
||||||
thread.start();
|
final Thread insertAll = new Thread(new InsertAllThreadSafe(genreDao, genres));
|
||||||
|
|
||||||
|
deleteAll.start();
|
||||||
|
deleteAll.join();
|
||||||
|
insertAll.start();
|
||||||
|
insertAll.join();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAll() {
|
public void deleteAll() {
|
||||||
|
|
|
||||||
|
|
@ -21,17 +21,9 @@ public class SongGenreRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void insertAll(List<SongGenreCross> crosses) {
|
public void insertAll(List<SongGenreCross> crosses) {
|
||||||
try {
|
InsertAllThreadSafe insert = new InsertAllThreadSafe(songGenreCrossDao, crosses);
|
||||||
final Thread delete = new Thread(new DeleteAllSongGenreCrossThreadSafe(songGenreCrossDao));
|
Thread thread = new Thread(insert);
|
||||||
final Thread insertAll = new Thread(new InsertAllThreadSafe(songGenreCrossDao, crosses));
|
thread.start();
|
||||||
|
|
||||||
delete.start();
|
|
||||||
delete.join();
|
|
||||||
insertAll.start();
|
|
||||||
insertAll.join();
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteAll() {
|
public void deleteAll() {
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,7 @@ public class SyncFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onLoadMedia(List<?> media) {
|
public void onLoadMedia(List<?> media) {
|
||||||
syncViewModel.setGenreList((ArrayList<Genre>) media);
|
syncViewModel.setGenreList((ArrayList<Genre>) media);
|
||||||
|
songGenreRepository.deleteAll();
|
||||||
genreRepository.insertAll(syncViewModel.getGenreList());
|
genreRepository.insertAll(syncViewModel.getGenreList());
|
||||||
loadSectorInfo(GENRES, "Found " + syncViewModel.getGenreList().size() + " elements", true);
|
loadSectorInfo(GENRES, "Found " + syncViewModel.getGenreList().size() + " elements", true);
|
||||||
}
|
}
|
||||||
|
|
@ -264,7 +265,6 @@ public class SyncFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onLoadMedia(List<?> media) {
|
public void onLoadMedia(List<?> media) {
|
||||||
syncViewModel.setSongList((ArrayList<Song>) media);
|
syncViewModel.setSongList((ArrayList<Song>) media);
|
||||||
songGenreRepository.deleteAll();
|
|
||||||
songRepository.insertAll(syncViewModel.getSongList());
|
songRepository.insertAll(syncViewModel.getSongList());
|
||||||
syncSongArtistCross(syncViewModel.getSongList());
|
syncSongArtistCross(syncViewModel.getSongList());
|
||||||
syncDownloadedSong();
|
syncDownloadedSong();
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,11 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class SyncUtil {
|
public class SyncUtil {
|
||||||
|
private static final String TAG = "SyncUtil";
|
||||||
|
|
||||||
public static final String SONG = "song";
|
public static final String SONG = "song";
|
||||||
public static final String ALBUM = "album";
|
public static final String ALBUM = "album";
|
||||||
public static final String ARTIST = "artist";
|
public static final String ARTIST = "artist";
|
||||||
private static final String TAG = "SyncUtil";
|
|
||||||
|
|
||||||
public static void getLibraries(Context context, MediaCallback callback) {
|
public static void getLibraries(Context context, MediaCallback callback) {
|
||||||
String id = App.getApiClientInstance(context).getCurrentUserId();
|
String id = App.getApiClientInstance(context).getCurrentUserId();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue