From e7d5532bee2f04ed081d3d98a2bc785d3dcd6767 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Fri, 13 Mar 2015 15:16:34 -0400 Subject: [PATCH] adjust default image provider --- .../FolderImages/DefaultImageProvider.cs | 58 ++++++++++--------- .../Collections/CollectionImageProvider.cs | 2 +- .../Photos/BaseDynamicImageProvider.cs | 4 +- .../Photos/DynamicImageProvider.cs | 2 +- .../Photos/PhotoAlbumImageProvider.cs | 2 +- .../Playlists/PlaylistImageProvider.cs | 2 +- 6 files changed, 37 insertions(+), 33 deletions(-) diff --git a/MediaBrowser.Providers/FolderImages/DefaultImageProvider.cs b/MediaBrowser.Providers/FolderImages/DefaultImageProvider.cs index 8ddbbba7dc..e1c2eb0edb 100644 --- a/MediaBrowser.Providers/FolderImages/DefaultImageProvider.cs +++ b/MediaBrowser.Providers/FolderImages/DefaultImageProvider.cs @@ -36,36 +36,42 @@ namespace MediaBrowser.Providers.FolderImages if (view != null) { - return GetImages(view.ViewType, cancellationToken); + return GetImages(view.ViewType, view.UserId.HasValue, cancellationToken); } var folder = (ICollectionFolder)item; - return GetImages(folder.CollectionType, cancellationToken); + return GetImages(folder.CollectionType, false, cancellationToken); } - private Task> GetImages(string viewType, CancellationToken cancellationToken) + private Task> GetImages(string viewType, bool isUserSpecificView, CancellationToken cancellationToken) { - var url = GetImageUrl(viewType); + var url = GetImageUrl(viewType, isUserSpecificView); + var list = new List(); - return Task.FromResult>(new List + if (!string.IsNullOrWhiteSpace(url)) { - new RemoteImageInfo - { - ProviderName = Name, - Url = url, - Type = ImageType.Primary - }, - - new RemoteImageInfo - { - ProviderName = Name, - Url = url, - Type = ImageType.Thumb - } - }); + list.AddRange(new List + { + new RemoteImageInfo + { + ProviderName = Name, + Url = url, + Type = ImageType.Primary + }, + + new RemoteImageInfo + { + ProviderName = Name, + Url = url, + Type = ImageType.Thumb + } + }); + } + + return Task.FromResult>(list); } - private string GetImageUrl(string viewType) + private string GetImageUrl(string viewType, bool isUserSpecificView) { const string urlPrefix = "https://raw.githubusercontent.com/MediaBrowser/MediaBrowser.Resources/master/images/folders/"; @@ -102,6 +108,11 @@ namespace MediaBrowser.Providers.FolderImages return urlPrefix + "movies.png"; } + if (isUserSpecificView) + { + return null; + } + return urlPrefix + "generic.png"; } @@ -112,13 +123,6 @@ namespace MediaBrowser.Providers.FolderImages public bool Supports(IHasImages item) { - var view = item as UserView; - - if (view != null) - { - return !view.UserId.HasValue; - } - return item is ICollectionFolder; } diff --git a/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs b/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs index b756fb6c4d..80a7c50d19 100644 --- a/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Collections/CollectionImageProvider.cs @@ -14,7 +14,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Collections { - public class CollectionImageProvider : BaseDynamicImageProvider, ICustomMetadataProvider + public class CollectionImageProvider : BaseDynamicImageProvider { public CollectionImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths) : base(fileSystem, providerManager, applicationPaths) { diff --git a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs index 40b85dad10..8f20d32cc7 100644 --- a/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/BaseDynamicImageProvider.cs @@ -15,8 +15,8 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Photos { - public abstract class BaseDynamicImageProvider : IHasChangeMonitor, IForcedProvider - where T : IHasImages + public abstract class BaseDynamicImageProvider : IHasChangeMonitor, IForcedProvider, ICustomMetadataProvider + where T : IHasMetadata { protected IFileSystem FileSystem { get; private set; } protected IProviderManager ProviderManager { get; private set; } diff --git a/MediaBrowser.Server.Implementations/Photos/DynamicImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/DynamicImageProvider.cs index 4e1330144e..dcbf3a7f02 100644 --- a/MediaBrowser.Server.Implementations/Photos/DynamicImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/DynamicImageProvider.cs @@ -13,7 +13,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Photos { - public class DynamicImageProvider : BaseDynamicImageProvider, ICustomMetadataProvider + public class DynamicImageProvider : BaseDynamicImageProvider { private readonly IUserManager _userManager; private readonly ILibraryManager _libraryManager; diff --git a/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs b/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs index e369869705..73d9183a5d 100644 --- a/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Photos/PhotoAlbumImageProvider.cs @@ -8,7 +8,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Photos { - public class PhotoAlbumImageProvider : BaseDynamicImageProvider, ICustomMetadataProvider + public class PhotoAlbumImageProvider : BaseDynamicImageProvider { public PhotoAlbumImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths) : base(fileSystem, providerManager, applicationPaths) { diff --git a/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs b/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs index d009a03aee..81f9438b9f 100644 --- a/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs +++ b/MediaBrowser.Server.Implementations/Playlists/PlaylistImageProvider.cs @@ -14,7 +14,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Server.Implementations.Playlists { - public class PlaylistImageProvider : BaseDynamicImageProvider, ICustomMetadataProvider + public class PlaylistImageProvider : BaseDynamicImageProvider { public PlaylistImageProvider(IFileSystem fileSystem, IProviderManager providerManager, IApplicationPaths applicationPaths) : base(fileSystem, providerManager, applicationPaths) {