mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Fix bug in image visualization
This commit is contained in:
parent
a0f417fa94
commit
18fae806a6
36 changed files with 431 additions and 150 deletions
|
|
@ -2,6 +2,7 @@ package com.cappielloantonio.play.util;
|
|||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
|
|
@ -23,8 +24,11 @@ import org.jellyfin.apiclient.model.querying.ItemsResult;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SyncUtil {
|
||||
private static final String TAG = "SyncUtil";
|
||||
|
||||
public static void getLibraries(Context context, MediaCallback callback) {
|
||||
String id = App.getApiClientInstance(context).getCurrentUserId();
|
||||
|
||||
|
|
@ -44,7 +48,7 @@ public class SyncUtil {
|
|||
});
|
||||
}
|
||||
|
||||
public static void getSongs(Context context, MediaCallback callback) {
|
||||
public static void getSongs(Context context, Map<Integer, Song> currentCatalogue, MediaCallback callback) {
|
||||
ItemQuery query = new ItemQuery();
|
||||
|
||||
query.setIncludeItemTypes(new String[]{"Audio"});
|
||||
|
|
@ -59,7 +63,7 @@ public class SyncUtil {
|
|||
ArrayList<Song> songs = new ArrayList<>();
|
||||
|
||||
for (BaseItemDto itemDto : result.getItems()) {
|
||||
songs.add(new Song(itemDto));
|
||||
songs.add(updateSongData(currentCatalogue, new Song(itemDto)));
|
||||
}
|
||||
|
||||
callback.onLoadMedia(songs);
|
||||
|
|
@ -215,4 +219,18 @@ public class SyncUtil {
|
|||
|
||||
return bundle;
|
||||
}
|
||||
|
||||
private static Song updateSongData(Map<Integer, Song> library, Song newSong) {
|
||||
if(library.containsKey(newSong.hashCode())) {
|
||||
Log.d(TAG, "updateSongData: " + newSong.getTitle());
|
||||
|
||||
Song oldSong = library.get(newSong.hashCode());
|
||||
newSong.setFavorite(oldSong.isFavorite());
|
||||
newSong.setAdded(oldSong.getAdded());
|
||||
newSong.setLastPlay(oldSong.getLastPlay());
|
||||
newSong.setPlayCount(oldSong.getPlayCount());
|
||||
}
|
||||
|
||||
return newSong;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue