mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
Added similar items in album page
This commit is contained in:
parent
d24b14453d
commit
e7713ce19c
10 changed files with 148 additions and 11 deletions
|
|
@ -26,6 +26,7 @@ public class PreferenceUtil {
|
|||
public static final String IMAGE_CACHE_SIZE = "image_cache_size";
|
||||
public static final String MEDIA_CACHE_SIZE = "media_cache_size";
|
||||
public static final String INSTANT_MIX_SONG_NUMBER = "instant_mix_song_number";
|
||||
public static final String SIMILAR_ITEMS_NUMBER = "similar_items_number";
|
||||
public static final String TRANSCODE_CODEC = "transcode_codec";
|
||||
public static final String DIRECT_PLAY_CODECS = "direct_play_codecs";
|
||||
public static final String MAXIMUM_BITRATE = "maximum_bitrate";
|
||||
|
|
@ -139,6 +140,10 @@ public class PreferenceUtil {
|
|||
return Integer.parseInt(mPreferences.getString(INSTANT_MIX_SONG_NUMBER, "10"));
|
||||
}
|
||||
|
||||
public final int getSimilarItemsNumber() {
|
||||
return Integer.parseInt(mPreferences.getString(SIMILAR_ITEMS_NUMBER, "10"));
|
||||
}
|
||||
|
||||
public final int getSearchElementPerCategory() {
|
||||
return Integer.parseInt(mPreferences.getString(SEARCH_ELEMENT_PER_CATEGORY, "10"));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -274,6 +274,39 @@ public class SyncUtil {
|
|||
});
|
||||
}
|
||||
|
||||
public static void getSimilarItems(Context context, MediaCallback callback, String resultType, String itemID, int limit) {
|
||||
SimilarItemsQuery query = new SimilarItemsQuery();
|
||||
|
||||
query.setId(itemID);
|
||||
query.setUserId(App.getApiClientInstance(context).getCurrentUserId());
|
||||
query.setFields(new ItemFields[]{ItemFields.MediaSources});
|
||||
query.setLimit(limit);
|
||||
|
||||
App.getApiClientInstance(context).GetSimilarItems(query, new Response<ItemsResult>() {
|
||||
@Override
|
||||
public void onResponse(ItemsResult result) {
|
||||
List<Object> items = new ArrayList<>();
|
||||
|
||||
for (BaseItemDto itemDto : result.getItems()) {
|
||||
if (resultType.equals(ARTIST) && itemDto.getBaseItemType() == BaseItemType.MusicArtist) {
|
||||
items.add(new Artist(itemDto));
|
||||
} else if (resultType.equals(ALBUM) && itemDto.getBaseItemType() == BaseItemType.MusicAlbum) {
|
||||
items.add(new Album(itemDto));
|
||||
} else if (resultType.equals(SONG) && itemDto.getBaseItemType() == BaseItemType.Audio) {
|
||||
items.add(new Song(itemDto));
|
||||
}
|
||||
}
|
||||
|
||||
callback.onLoadMedia(items);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Exception exception) {
|
||||
callback.onError(exception);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Bundle getSyncBundle(Boolean syncAlbum, Boolean syncArtist, Boolean syncGenres, Boolean syncPlaylist, Boolean syncSong, Boolean crossSyncSongGenre) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putBoolean("sync_album", syncAlbum);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue