public interface DynamicProvider
Represents a service provider that can be switched at runtime. It is important to pass around an instance of this
interface rather than individual service provider interfaces (e.g.
MusicCache, MusicFetcher, etc.)
because if the service provider is switched, the underlying implementations will need to be changed too.-
Method Summary
Modifier and TypeMethodDescriptionvoidaddServiceProvider(ServiceProvider serviceProvider) Adds a service provider to the list of available service providers.Gets the current service provider.Gets the music cache used by the current service provider.Gets the music fetcher used by the current service provider.Gets thePlayActorused by the current service provider.getProvider(String providerName) Gets the service provider with the given name.Gets theStringIdentifierused by the current service provider.Gets the track orchestrator used by the current service provider.voidinitFactories(SongTypeFactory songTypeFactory, CollectionTypeFactory collectionTypeFactory, AlbumTypeFactory albumTypeFactory) Initializes the music factories.voidinitializeInitialProvider(PackageConfig internalPackageConfig) Initializes the service provider that is initially used by the program.voidShuts down all service providers.voidswitchProvider(String providerName) Switches the current service provider to the one with the given name.
-
Method Details
-
addServiceProvider
Adds a service provider to the list of available service providers.- Parameters:
serviceProvider- The service provider to add
-
switchProvider
Switches the current service provider to the one with the given name.- Parameters:
providerName- The name of the service provider to switch to
-
initializeInitialProvider
Initializes the service provider that is initially used by the program.- Parameters:
internalPackageConfig- ThePackageConfigused by the internal system
-
getProvider
Gets the service provider with the given name.- Parameters:
providerName- The name of the service provider to get- Returns:
- The found service provider
-
getCurrentProvider
ServiceProvider getCurrentProvider()Gets the current service provider.- Returns:
- The current service provider
-
initFactories
void initFactories(SongTypeFactory songTypeFactory, CollectionTypeFactory collectionTypeFactory, AlbumTypeFactory albumTypeFactory) Initializes the music factories. This only needs to be called once.- Parameters:
songTypeFactory- The song type factory to usecollectionTypeFactory- The collection type factory to usealbumTypeFactory- The album type factory to use
-
shutdownProviders
void shutdownProviders()Shuts down all service providers. This should clean up any async tasks currently running. -
getMusicCache
MusicCache getMusicCache()Gets the music cache used by the current service provider. Do not keep a reference to this object that may span a nonatomic context, as the implementation may switch.- Returns:
- The current music cache
-
getMusicFetcher
MusicFetcher getMusicFetcher()Gets the music fetcher used by the current service provider. Do not keep a reference to this object that may span a nonatomic context, as the implementation may switch.- Returns:
- The current music fetcher
-
getTrackOrchestrator
TrackOrchestrator getTrackOrchestrator()Gets the track orchestrator used by the current service provider. Do not keep a reference to this object that may span a nonatomic context, as the implementation may switch.- Returns:
- The current track orchestrator
-
getStringIdentifier
StringIdentifier getStringIdentifier()Gets theStringIdentifierused by the current service provider. Do not keep a reference to this object that may span a nonatomic context, as the implementation may switch.- Returns:
- The current
StringIdentifier
-
getPlayActor
-