From 37cd0da85f1dfdcf61c477762458f5268be73f77 Mon Sep 17 00:00:00 2001 From: casey langen Date: Sun, 7 Jul 2019 17:59:03 -0700 Subject: [PATCH] Some renames I've been wanting to do for a while, but was dragging my feet. In musikcube/musikcore: * ISimpleDataProvider -> IMetadataProxy * LocalSimpleDataProvider -> LocalMetadataProxy In musikdroid: * IDataProvider -> IMetadataProxy * RemoteDataProvider -> RemoteMetadataProxy * DataProviderMixin -> MetadataProxyMixin --- CHANGELOG.txt | 18 +++++++ src/core/CMakeLists.txt | 2 +- src/core/core.vcxproj | 6 +-- src/core/core.vcxproj.filters | 18 +++---- src/core/io/DataStreamFactory.cpp | 25 ---------- src/core/io/DataStreamFactory.h | 2 - ...ataProvider.cpp => LocalMetadataProxy.cpp} | 50 +++++++++---------- ...pleDataProvider.h => LocalMetadataProxy.h} | 8 +-- .../query/local/util/CategoryQueryUtil.h | 2 +- src/core/plugin/Plugins.cpp | 30 +++++------ ...ISimpleDataProvider.h => IMetadataProxy.h} | 2 +- .../remote/injection/AppComponent.kt | 4 +- .../musikcube/remote/injection/DataModule.kt | 21 ++++---- .../remote/injection/ViewComponent.kt | 4 +- .../impl/remote/RemotePlaybackService.kt | 12 ++--- .../streaming/StreamingPlaybackService.kt | 32 ++++++------ .../{IDataProvider.kt => IMetadataProxy.kt} | 2 +- .../remote/IdListTrackListQueryFactory.kt | 10 ++-- ...DataProvider.kt => RemoteMetadataProxy.kt} | 16 +++--- .../ui/albums/fragment/AlbumBrowseFragment.kt | 10 ++-- .../fragment/AllCategoriesFragment.kt | 10 ++-- .../fragment/CategoryBrowseFragment.kt | 12 ++--- .../remote/ui/home/activity/MainActivity.kt | 14 +++--- .../playqueue/fragment/PlayQueueFragment.kt | 10 ++-- .../ui/settings/activity/RemoteEqActivity.kt | 6 +-- .../activity/RemoteSettingsActivity.kt | 6 +-- .../ui/settings/activity/SettingsActivity.kt | 6 +-- .../settings/viewmodel/BaseRemoteViewModel.kt | 8 +-- .../ui/shared/mixin/ItemContextMenuMixin.kt | 4 +- ...ProviderMixin.kt => MetadataProxyMixin.kt} | 6 +-- .../ui/shared/model/BaseSlidingWindow.kt | 6 +-- .../ui/shared/model/DefaultSlidingWindow.kt | 6 +-- .../remote/ui/shared/view/EmptyListView.kt | 6 +-- .../tracks/activity/EditPlaylistActivity.kt | 6 +-- .../ui/tracks/fragment/TrackListFragment.kt | 12 ++--- .../ui/tracks/model/EditPlaylistViewModel.kt | 16 +++--- src/musikdroid/build.gradle | 2 +- src/plugins/server/Context.h | 6 +-- src/plugins/server/HttpServer.cpp | 4 +- src/plugins/server/WebSocketServer.cpp | 34 ++++++------- src/plugins/server/main.cpp | 8 +-- 41 files changed, 225 insertions(+), 237 deletions(-) rename src/core/library/{LocalSimpleDataProvider.cpp => LocalMetadataProxy.cpp} (93%) rename src/core/library/{LocalSimpleDataProvider.h => LocalMetadataProxy.h} (96%) rename src/core/sdk/{ISimpleDataProvider.h => IMetadataProxy.h} (99%) rename src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/{IDataProvider.kt => IMetadataProxy.kt} (99%) rename src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/impl/remote/{RemoteDataProvider.kt => RemoteMetadataProxy.kt} (97%) rename src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/mixin/{DataProviderMixin.kt => MetadataProxyMixin.kt} (83%) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 42776effb..77431d090 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,21 @@ +0.65.2 + +musikcube: +* updated `ru_RU` locale (adem4ik) + +musikcore: +* renamed some classes: + * `ISimpleDataProvider` -> `IMetadataProxy` + * `LocalSimpleDataProvider` -> `LocalMetadataProxy` + +musikdroid: +* renamed some classes: + * `IDataProvider` -> `IMetadataProxy` + * `RemoteDataProvider` -> `RemoteMetadataProxy` + * `DataProviderMixin` -> `MetadataProxyMixin` + +-------------------------------------------------------------------------------- + 0.65.1 musikcube: diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f19a6e225..d8b460367 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -20,7 +20,7 @@ set(CORE_SOURCES ./library/Indexer.cpp ./library/LibraryFactory.cpp ./library/LocalLibrary.cpp - ./library/LocalSimpleDataProvider.cpp + ./library/LocalMetadataProxy.cpp ./library/query/local/AlbumListQuery.cpp ./library/query/local/AllCategoriesQuery.cpp ./library/query/local/AppendPlaylistQuery.cpp diff --git a/src/core/core.vcxproj b/src/core/core.vcxproj index 63f7aeb02..907a3b8ac 100755 --- a/src/core/core.vcxproj +++ b/src/core/core.vcxproj @@ -104,7 +104,7 @@ - + @@ -171,7 +171,7 @@ - + @@ -241,7 +241,7 @@ - + diff --git a/src/core/core.vcxproj.filters b/src/core/core.vcxproj.filters index c2827f806..e9b6445fe 100755 --- a/src/core/core.vcxproj.filters +++ b/src/core/core.vcxproj.filters @@ -175,9 +175,6 @@ src\library\query\local - - src\library - src\plugin @@ -229,6 +226,9 @@ src\support + + src\library + @@ -390,9 +390,6 @@ src\library\query\local - - src\library - src\plugin @@ -447,9 +444,6 @@ src\sdk\vis - - src\sdk\metadata - src\sdk\audio @@ -555,5 +549,11 @@ src\support + + src\sdk\metadata + + + src\library + \ No newline at end of file diff --git a/src/core/io/DataStreamFactory.cpp b/src/core/io/DataStreamFactory.cpp index 1fe238a72..bf7d33d31 100644 --- a/src/core/io/DataStreamFactory.cpp +++ b/src/core/io/DataStreamFactory.cpp @@ -98,28 +98,3 @@ DataStreamPtr DataStreamFactory::OpenSharedDataStream(const char *uri) { auto stream = OpenDataStream(uri); return stream ? DataStreamPtr(stream, StreamDeleter()) : DataStreamPtr(); } - -bool DataStreamFactory::IsLocalFileStream(const char *uri) { - if (uri) { - /* see if a plugin can handle this. if it can, then it's not - considered to be a local file stream */ - DataStreamFactoryVector::iterator it = - DataStreamFactory::Instance()->dataStreamFactories.begin(); - - for( ; it != DataStreamFactory::Instance()->dataStreamFactories.end(); ++it) { - if ((*it)->CanRead(uri)) { - return false; - } - } - - /* now test local filesystem */ - boost::filesystem::path filename(uri); - try { - return boost::filesystem::exists(filename); - } - catch(...) { - } - } - - return false; -} diff --git a/src/core/io/DataStreamFactory.h b/src/core/io/DataStreamFactory.h index ad02efe2f..35bb39512 100644 --- a/src/core/io/DataStreamFactory.h +++ b/src/core/io/DataStreamFactory.h @@ -47,8 +47,6 @@ namespace musik { namespace core { namespace io { static DataStreamPtr OpenSharedDataStream(const char *uri); static musik::core::sdk::IDataStream* OpenDataStream(const char* uri); - static bool IsLocalFileStream(const char *uri); - private: typedef std::vector > DataStreamFactoryVector; diff --git a/src/core/library/LocalSimpleDataProvider.cpp b/src/core/library/LocalMetadataProxy.cpp similarity index 93% rename from src/core/library/LocalSimpleDataProvider.cpp rename to src/core/library/LocalMetadataProxy.cpp index 498f68019..1e587c1f5 100644 --- a/src/core/library/LocalSimpleDataProvider.cpp +++ b/src/core/library/LocalMetadataProxy.cpp @@ -33,7 +33,7 @@ ////////////////////////////////////////////////////////////////////////////// #include "pch.hpp" -#include "LocalSimpleDataProvider.h" +#include "LocalMetadataProxy.h" #include #include @@ -56,7 +56,7 @@ #include #include -#define TAG "LocalSimpleDataProvider" +#define TAG "LocalMetadataProxy" using namespace musik::core; using namespace musik::core::db; @@ -284,16 +284,16 @@ class RemoveFromPlaylistQuery : public LocalQueryBase { /* DATA PROVIDER */ -LocalSimpleDataProvider::LocalSimpleDataProvider(musik::core::ILibraryPtr library) +LocalMetadataProxy::LocalMetadataProxy(musik::core::ILibraryPtr library) : library(library) { } -LocalSimpleDataProvider::~LocalSimpleDataProvider() { +LocalMetadataProxy::~LocalMetadataProxy() { } -ITrackList* LocalSimpleDataProvider::QueryTracks(const char* query, int limit, int offset) { +ITrackList* LocalMetadataProxy::QueryTracks(const char* query, int limit, int offset) { try { std::shared_ptr search( new SearchTrackListQuery(this->library, std::string(query ? query : ""))); @@ -315,7 +315,7 @@ ITrackList* LocalSimpleDataProvider::QueryTracks(const char* query, int limit, i return nullptr; } -ITrack* LocalSimpleDataProvider::QueryTrackById(int64_t trackId) { +ITrack* LocalMetadataProxy::QueryTrackById(int64_t trackId) { try { TrackPtr target(new LibraryTrack(trackId, this->library)); @@ -335,7 +335,7 @@ ITrack* LocalSimpleDataProvider::QueryTrackById(int64_t trackId) { return nullptr; } -ITrack* LocalSimpleDataProvider::QueryTrackByExternalId(const char* externalId) { +ITrack* LocalMetadataProxy::QueryTrackByExternalId(const char* externalId) { if (strlen(externalId)) { try { TrackPtr target(new LibraryTrack(0, this->library)); @@ -358,7 +358,7 @@ ITrack* LocalSimpleDataProvider::QueryTrackByExternalId(const char* externalId) return nullptr; } -ITrackList* LocalSimpleDataProvider::QueryTracksByCategory( +ITrackList* LocalMetadataProxy::QueryTracksByCategory( const char* categoryType, int64_t selectedId, const char* filter, int limit, int offset) { try { @@ -394,7 +394,7 @@ ITrackList* LocalSimpleDataProvider::QueryTracksByCategory( return nullptr; } -ITrackList* LocalSimpleDataProvider::QueryTracksByCategories( +ITrackList* LocalMetadataProxy::QueryTracksByCategories( IValue** categories, size_t categoryCount, const char* filter, int limit, int offset) { try { @@ -419,11 +419,11 @@ ITrackList* LocalSimpleDataProvider::QueryTracksByCategories( return nullptr; } -IValueList* LocalSimpleDataProvider::QueryCategory(const char* type, const char* filter) { +IValueList* LocalMetadataProxy::QueryCategory(const char* type, const char* filter) { return QueryCategoryWithPredicate(type, "", -1LL, filter); } -IValueList* LocalSimpleDataProvider::ListCategories() { +IValueList* LocalMetadataProxy::ListCategories() { try { auto query = std::make_shared(); this->library->Enqueue(query, ILibrary::QuerySynchronous); @@ -440,7 +440,7 @@ IValueList* LocalSimpleDataProvider::ListCategories() { } -IValueList* LocalSimpleDataProvider::QueryCategoryWithPredicate( +IValueList* LocalMetadataProxy::QueryCategoryWithPredicate( const char* type, const char* predicateType, int64_t predicateId, const char* filter) { try { @@ -465,7 +465,7 @@ IValueList* LocalSimpleDataProvider::QueryCategoryWithPredicate( return nullptr; } -IValueList* LocalSimpleDataProvider::QueryCategoryWithPredicates( +IValueList* LocalMetadataProxy::QueryCategoryWithPredicates( const char* type, IValue** predicates, size_t predicateCount, const char* filter) { try { @@ -487,7 +487,7 @@ IValueList* LocalSimpleDataProvider::QueryCategoryWithPredicates( return nullptr; } -IMapList* LocalSimpleDataProvider::QueryAlbums( +IMapList* LocalMetadataProxy::QueryAlbums( const char* categoryIdName, int64_t categoryIdValue, const char* filter) { try { @@ -509,7 +509,7 @@ IMapList* LocalSimpleDataProvider::QueryAlbums( return nullptr; } -IMapList* LocalSimpleDataProvider::QueryAlbums(const char* filter) { +IMapList* LocalMetadataProxy::QueryAlbums(const char* filter) { return this->QueryAlbums(nullptr, -1, filter); } @@ -561,7 +561,7 @@ static uint64_t savePlaylist( return 0; } -int64_t LocalSimpleDataProvider::SavePlaylistWithIds( +int64_t LocalMetadataProxy::SavePlaylistWithIds( int64_t* trackIds, size_t trackIdCount, const char* playlistName, @@ -577,7 +577,7 @@ int64_t LocalSimpleDataProvider::SavePlaylistWithIds( return savePlaylist(this->library, trackList, playlistName, playlistId); } -int64_t LocalSimpleDataProvider::SavePlaylistWithExternalIds( +int64_t LocalMetadataProxy::SavePlaylistWithExternalIds( const char** externalIds, size_t externalIdCount, const char* playlistName, @@ -606,7 +606,7 @@ int64_t LocalSimpleDataProvider::SavePlaylistWithExternalIds( return 0; } -int64_t LocalSimpleDataProvider::SavePlaylistWithTrackList( +int64_t LocalMetadataProxy::SavePlaylistWithTrackList( ITrackList* trackList, const char* playlistName, const int64_t playlistId) @@ -618,7 +618,7 @@ int64_t LocalSimpleDataProvider::SavePlaylistWithTrackList( return savePlaylist(this->library, trackList, playlistName, playlistId); } -bool LocalSimpleDataProvider::RenamePlaylist(const int64_t playlistId, const char* name) +bool LocalMetadataProxy::RenamePlaylist(const int64_t playlistId, const char* name) { if (strlen(name)) { try { @@ -639,7 +639,7 @@ bool LocalSimpleDataProvider::RenamePlaylist(const int64_t playlistId, const cha return false; } -bool LocalSimpleDataProvider::DeletePlaylist(const int64_t playlistId) { +bool LocalMetadataProxy::DeletePlaylist(const int64_t playlistId) { try { std::shared_ptr query = std::make_shared(library, playlistId); @@ -682,7 +682,7 @@ static bool appendToPlaylist( return false; } -bool LocalSimpleDataProvider::AppendToPlaylistWithIds( +bool LocalMetadataProxy::AppendToPlaylistWithIds( const int64_t playlistId, const int64_t* ids, size_t idCount, @@ -694,7 +694,7 @@ bool LocalSimpleDataProvider::AppendToPlaylistWithIds( return appendToPlaylist(this->library, playlistId, trackList, offset); } -bool LocalSimpleDataProvider::AppendToPlaylistWithExternalIds( +bool LocalMetadataProxy::AppendToPlaylistWithExternalIds( const int64_t playlistId, const char** externalIds, size_t externalIdCount, @@ -720,7 +720,7 @@ bool LocalSimpleDataProvider::AppendToPlaylistWithExternalIds( } -bool LocalSimpleDataProvider::AppendToPlaylistWithTrackList( +bool LocalMetadataProxy::AppendToPlaylistWithTrackList( const int64_t playlistId, ITrackList* trackList, int offset) { static auto deleter = [](musik::core::sdk::ITrackList* trackList) {}; @@ -731,7 +731,7 @@ bool LocalSimpleDataProvider::AppendToPlaylistWithTrackList( return result; } -size_t LocalSimpleDataProvider::RemoveTracksFromPlaylist( +size_t LocalMetadataProxy::RemoveTracksFromPlaylist( const int64_t playlistId, const char** externalIds, const int* sortOrders, @@ -754,7 +754,7 @@ size_t LocalSimpleDataProvider::RemoveTracksFromPlaylist( return 0; } -ITrackList* LocalSimpleDataProvider::QueryTracksByExternalId( +ITrackList* LocalMetadataProxy::QueryTracksByExternalId( const char** externalIds, size_t externalIdCount) { try { diff --git a/src/core/library/LocalSimpleDataProvider.h b/src/core/library/LocalMetadataProxy.h similarity index 96% rename from src/core/library/LocalSimpleDataProvider.h rename to src/core/library/LocalMetadataProxy.h index ef92534c9..f8234e618 100644 --- a/src/core/library/LocalSimpleDataProvider.h +++ b/src/core/library/LocalMetadataProxy.h @@ -35,15 +35,15 @@ #pragma once #include -#include +#include namespace musik { namespace core { namespace db { namespace local { - class LocalSimpleDataProvider : public musik::core::sdk::ISimpleDataProvider { + class LocalMetadataProxy : public musik::core::sdk::IMetadataProxy { public: - LocalSimpleDataProvider(musik::core::ILibraryPtr library); + LocalMetadataProxy(musik::core::ILibraryPtr library); - virtual ~LocalSimpleDataProvider(); + virtual ~LocalMetadataProxy(); virtual musik::core::sdk::ITrackList* QueryTracks( diff --git a/src/core/library/query/local/util/CategoryQueryUtil.h b/src/core/library/query/local/util/CategoryQueryUtil.h index e314c8205..e082567a5 100644 --- a/src/core/library/query/local/util/CategoryQueryUtil.h +++ b/src/core/library/query/local/util/CategoryQueryUtil.h @@ -187,7 +187,7 @@ namespace musik { namespace core { namespace db { namespace local { "{{limit_and_offset}} "; /* ALBUM_LIST_QUERY is like a specialized REGULAR_PROPERTY_QUERY used by - LocalSimpleDataProvider to return album resources with thumbnail, artist, + LocalMetadataProxy to return album resources with thumbnail, artist, and other supplementary information. */ static const std::string ALBUM_LIST_FILTER = diff --git a/src/core/plugin/Plugins.cpp b/src/core/plugin/Plugins.cpp index 2016c8dea..8a76ff373 100644 --- a/src/core/plugin/Plugins.cpp +++ b/src/core/plugin/Plugins.cpp @@ -46,7 +46,7 @@ #include #include #include -#include +#include #include #include @@ -63,7 +63,7 @@ using namespace musik::core::sdk; typedef void(*SetEnvironment)(IEnvironment*); typedef void(*SetDebug)(IDebug*); -typedef void(*SetSimpleDataProvider)(ISimpleDataProvider*); +typedef void(*SetMetadataProxy)(IMetadataProxy*); typedef void(*SetIndexerNotifier)(IIndexerNotifier*); static const std::string SUPEREQ_PLUGIN_GUID = "6f0ed53b-0f13-4220-9b0a-ca496b6421cc"; @@ -71,7 +71,7 @@ static const std::string SUPEREQ_PLUGIN_GUID = "6f0ed53b-0f13-4220-9b0a-ca496b64 static IMessageQueue* messageQueue = nullptr; static ILibraryPtr library; static IPlaybackService* playback = nullptr; -static LocalSimpleDataProvider* dataProvider = nullptr; +static LocalMetadataProxy* metadataProxy = nullptr; static std::shared_ptr playbackPrefs; static void saveEnvironment() { @@ -357,18 +357,18 @@ namespace musik { namespace core { namespace plugin { func(&debugger); }); - /* data providers */ - delete dataProvider; + /* metadata proxies */ + delete metadataProxy; ::messageQueue = messageQueue; ::library = library; ::playback = playback; - ::dataProvider = new LocalSimpleDataProvider(library); + ::metadataProxy = new LocalMetadataProxy(library); ::playbackPrefs = Preferences::ForComponent(prefs::components::Playback); - PluginFactory::Instance().QueryFunction( - "SetSimpleDataProvider", - [](musik::core::sdk::IPlugin* plugin, SetSimpleDataProvider func) { - func(dataProvider); + PluginFactory::Instance().QueryFunction( + "SetMetadataProxy", + [](musik::core::sdk::IPlugin* plugin, SetMetadataProxy func) { + func(metadataProxy); }); /* indexer */ @@ -394,15 +394,15 @@ namespace musik { namespace core { namespace plugin { Preferences::SavePluginPreferences(); /* data providers */ - PluginFactory::Instance().QueryFunction( - "SetSimpleDataProvider", - [](musik::core::sdk::IPlugin* plugin, SetSimpleDataProvider func) { + PluginFactory::Instance().QueryFunction( + "SetMetadataProxy", + [](musik::core::sdk::IPlugin* plugin, SetMetadataProxy func) { func(nullptr); }); - delete dataProvider; + delete metadataProxy; ::messageQueue = nullptr; - ::dataProvider = nullptr; + ::metadataProxy = nullptr; ::library.reset(); ::playback = nullptr; ::playbackPrefs.reset(); diff --git a/src/core/sdk/ISimpleDataProvider.h b/src/core/sdk/IMetadataProxy.h similarity index 99% rename from src/core/sdk/ISimpleDataProvider.h rename to src/core/sdk/IMetadataProxy.h index 55c41e02d..bc6bcb2cd 100644 --- a/src/core/sdk/ISimpleDataProvider.h +++ b/src/core/sdk/IMetadataProxy.h @@ -41,7 +41,7 @@ namespace musik { namespace core { namespace sdk { - class ISimpleDataProvider { + class IMetadataProxy { public: virtual ITrackList* QueryTracks( const char* query = nullptr, diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/AppComponent.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/AppComponent.kt index 35c90232d..3308e9121 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/AppComponent.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/AppComponent.kt @@ -8,7 +8,7 @@ import io.casey.musikcube.remote.service.gapless.db.GaplessDb import io.casey.musikcube.remote.service.playback.impl.streaming.StreamProxy import io.casey.musikcube.remote.service.playback.impl.streaming.db.OfflineDb import io.casey.musikcube.remote.service.websocket.WebSocketService -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.ui.settings.model.ConnectionsDb @ApplicationScope @@ -22,6 +22,6 @@ interface AppComponent { fun offlineDb(): OfflineDb /* via DataModule */ fun gaplessDb(): GaplessDb /* via DataModule */ fun connectionsDb(): ConnectionsDb /* via DataModule */ - fun dataProvider(): IDataProvider /* via DataModule */ + fun metadataProxy(): IMetadataProxy /* via DataModule */ fun context(): Context /* via AppModule */ } diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/DataModule.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/DataModule.kt index 9da74bf1d..e128010ef 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/DataModule.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/DataModule.kt @@ -7,30 +7,27 @@ import dagger.Provides import io.casey.musikcube.remote.service.gapless.db.GaplessDb import io.casey.musikcube.remote.service.playback.impl.streaming.db.OfflineDb import io.casey.musikcube.remote.service.websocket.WebSocketService -import io.casey.musikcube.remote.service.websocket.model.IDataProvider -import io.casey.musikcube.remote.service.websocket.model.impl.remote.RemoteDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy +import io.casey.musikcube.remote.service.websocket.model.impl.remote.RemoteMetadataProxy import io.casey.musikcube.remote.ui.settings.model.ConnectionsDb @Module class DataModule { @Provides - fun providesDataProvider(wss: WebSocketService): IDataProvider = RemoteDataProvider(wss) + fun providesMetadataProxy(wss: WebSocketService): IMetadataProxy = RemoteMetadataProxy(wss) @ApplicationScope @Provides - fun providesOfflineDb(context: Context): OfflineDb { - return Room.databaseBuilder(context, OfflineDb::class.java, "offline").build() - } + fun providesOfflineDb(context: Context): OfflineDb = + Room.databaseBuilder(context, OfflineDb::class.java, "offline").build() @ApplicationScope @Provides - fun providesConnectionsDb(context: Context): ConnectionsDb { - return Room.databaseBuilder(context, ConnectionsDb::class.java, "connections").build() - } + fun providesConnectionsDb(context: Context): ConnectionsDb = + Room.databaseBuilder(context, ConnectionsDb::class.java, "connections").build() @ApplicationScope @Provides - fun providesGaplessDb(context: Context): GaplessDb { - return Room.databaseBuilder(context, GaplessDb::class.java, "gapless").build() - } + fun providesGaplessDb(context: Context): GaplessDb = + Room.databaseBuilder(context, GaplessDb::class.java, "gapless").build() } \ No newline at end of file diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/ViewComponent.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/ViewComponent.kt index 5e5468af4..93e7acd80 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/ViewComponent.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/injection/ViewComponent.kt @@ -16,7 +16,7 @@ import io.casey.musikcube.remote.ui.playqueue.fragment.PlayQueueFragment import io.casey.musikcube.remote.ui.settings.activity.* import io.casey.musikcube.remote.ui.shared.activity.BaseActivity import io.casey.musikcube.remote.ui.shared.fragment.BaseFragment -import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin +import io.casey.musikcube.remote.ui.shared.mixin.MetadataProxyMixin import io.casey.musikcube.remote.ui.shared.mixin.ItemContextMenuMixin import io.casey.musikcube.remote.ui.shared.view.EmptyListView import io.casey.musikcube.remote.ui.tracks.activity.TrackListActivity @@ -50,7 +50,7 @@ interface ViewComponent { fun inject(view: EmptyListView) fun inject(view: MainMetadataView) - fun inject(mixin: DataProviderMixin) + fun inject(mixin: MetadataProxyMixin) fun inject(mixin: ItemContextMenuMixin) } diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/remote/RemotePlaybackService.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/remote/RemotePlaybackService.kt index 51ee4186d..188a59eeb 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/remote/RemotePlaybackService.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/remote/RemotePlaybackService.kt @@ -10,7 +10,7 @@ import io.casey.musikcube.remote.service.playback.RepeatMode import io.casey.musikcube.remote.service.websocket.Messages import io.casey.musikcube.remote.service.websocket.SocketMessage import io.casey.musikcube.remote.service.websocket.WebSocketService -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.service.websocket.model.ITrack import io.casey.musikcube.remote.service.websocket.model.ITrackListQueryFactory import io.casey.musikcube.remote.service.websocket.model.impl.remote.RemoteTrack @@ -95,7 +95,7 @@ class RemotePlaybackService : IPlaybackService { } @Inject lateinit var wss: WebSocketService - @Inject lateinit var dataProvider: IDataProvider + @Inject lateinit var metadataProxy: IMetadataProxy private val handler = Handler() private val listeners = HashSet<() -> Unit>() @@ -279,7 +279,7 @@ class RemotePlaybackService : IPlaybackService { if (listeners.size == 1) { wss.addClient(client) - dataProvider.attach() + metadataProxy.attach() scheduleTimeSyncMessage() } } @@ -289,7 +289,7 @@ class RemotePlaybackService : IPlaybackService { if (listeners.size == 0) { wss.removeClient(client) - dataProvider.detach() + metadataProxy.detach() handler.removeCallbacks(syncTimeRunnable) } } @@ -405,8 +405,8 @@ class RemotePlaybackService : IPlaybackService { get() = QueryContext(Messages.Request.QueryPlayQueueTracks) override val playlistQueryFactory: ITrackListQueryFactory = object : ITrackListQueryFactory { - override fun count(): Observable = dataProvider.getPlayQueueTracksCount() - override fun page(offset: Int, limit: Int): Observable> = dataProvider.getPlayQueueTracks(limit, offset) + override fun count(): Observable = metadataProxy.getPlayQueueTracksCount() + override fun page(offset: Int, limit: Int): Observable> = metadataProxy.getPlayQueueTracks(limit, offset) override fun offline(): Boolean = false } diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/streaming/StreamingPlaybackService.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/streaming/StreamingPlaybackService.kt index 768a9d450..cf6b5d96e 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/streaming/StreamingPlaybackService.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/playback/impl/streaming/StreamingPlaybackService.kt @@ -16,7 +16,7 @@ import io.casey.musikcube.remote.service.playback.* import io.casey.musikcube.remote.service.playback.impl.remote.Metadata import io.casey.musikcube.remote.service.system.SystemService import io.casey.musikcube.remote.service.websocket.Messages -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.service.websocket.model.ITrack import io.casey.musikcube.remote.service.websocket.model.ITrackListQueryFactory import io.casey.musikcube.remote.service.websocket.model.PlayQueueType @@ -30,7 +30,7 @@ import java.util.* import javax.inject.Inject class StreamingPlaybackService(context: Context) : IPlaybackService { - @Inject lateinit var dataProvider: IDataProvider + @Inject lateinit var metadataProxy: IMetadataProxy private val prefs: SharedPreferences = context.getSharedPreferences(Prefs.NAME, Context.MODE_PRIVATE) private val listeners = HashSet<() -> Unit>() @@ -125,8 +125,8 @@ class StreamingPlaybackService(context: Context) : IPlaybackService { @Synchronized override fun connect(listener: () -> Unit) { listeners.add(listener) if (listeners.size == 1) { - handler.removeCallbacks(dataProviderDisconnectRunnable) - dataProvider.attach() + handler.removeCallbacks(metadataProxyDisconnectRunnable) + metadataProxy.attach() } } @@ -138,7 +138,7 @@ class StreamingPlaybackService(context: Context) : IPlaybackService { conditions between Activity changes, so we make sure to give things a couple seconds to settle... */ handler.postDelayed( - dataProviderDisconnectRunnable, + metadataProxyDisconnectRunnable, DATA_PROVIDER_DISCONNECT_DELAY_MS.toLong()) } } @@ -150,7 +150,7 @@ class StreamingPlaybackService(context: Context) : IPlaybackService { override fun playAll(index: Int, filter: String) { if (requestAudioFocus()) { trackMetadataCache.clear() - dataProvider.invalidatePlayQueueSnapshot() + metadataProxy.invalidatePlayQueueSnapshot() resetPlayContextAndQueryFactory() val type = Messages.Request.QueryTracks loadQueueAndPlay(QueryContext(filter, type), index) @@ -160,7 +160,7 @@ class StreamingPlaybackService(context: Context) : IPlaybackService { override fun play(category: String, categoryId: Long, index: Int, filter: String) { if (requestAudioFocus()) { trackMetadataCache.clear() - dataProvider.invalidatePlayQueueSnapshot() + metadataProxy.invalidatePlayQueueSnapshot() resetPlayContextAndQueryFactory() val type = Messages.Request.QueryTracksByCategory loadQueueAndPlay(QueryContext(category, categoryId, filter, type), index) @@ -185,16 +185,16 @@ class StreamingPlaybackService(context: Context) : IPlaybackService { val type = PlayQueueType.Snapshot service.queryContext?.let { - dataProvider.snapshotPlayQueue().subscribeBy( + metadataProxy.snapshotPlayQueue().subscribeBy( onNext = { resetPlayContextAndQueryFactory() snapshotQueryFactory = object: ITrackListQueryFactory { override fun count(): Observable? = - dataProvider.getPlayQueueTracksCount(type) + metadataProxy.getPlayQueueTracksCount(type) override fun page(offset: Int, limit: Int): Observable>? = - dataProvider.getPlayQueueTracks(limit, offset, type) + metadataProxy.getPlayQueueTracks(limit, offset, type) override fun offline(): Boolean = false } @@ -789,11 +789,11 @@ class StreamingPlaybackService(context: Context) : IPlaybackService { val params = queryContext if (params != null) { if (params.hasCategory()) { - return dataProvider.getTrackCountByCategory( + return metadataProxy.getTrackCountByCategory( params.category ?: "", params.categoryId, params.filter) } else { - return dataProvider.getTrackCount(params.filter) + return metadataProxy.getTrackCount(params.filter) } } return null @@ -803,11 +803,11 @@ class StreamingPlaybackService(context: Context) : IPlaybackService { val params = queryContext if (params != null) { if (params.hasCategory()) { - return dataProvider.getTracksByCategory( + return metadataProxy.getTracksByCategory( params.category ?: "", params.categoryId, limit, offset, params.filter) } else { - return dataProvider.getTracks(limit, offset, params.filter) + return metadataProxy.getTracks(limit, offset, params.filter) } } return null @@ -840,10 +840,10 @@ class StreamingPlaybackService(context: Context) : IPlaybackService { private fun detachable() = listeners.size == 0 && state == PlaybackState.Stopped - private val dataProviderDisconnectRunnable = object: Runnable { + private val metadataProxyDisconnectRunnable = object: Runnable { override fun run() { if (detachable()) { - dataProvider.detach() + metadataProxy.detach() } } } diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/IDataProvider.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/IMetadataProxy.kt similarity index 99% rename from src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/IDataProvider.kt rename to src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/IMetadataProxy.kt index c06576fc9..8cb3eb308 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/IDataProvider.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/IMetadataProxy.kt @@ -2,7 +2,7 @@ package io.casey.musikcube.remote.service.websocket.model import io.reactivex.Observable -interface IDataProvider { +interface IMetadataProxy { enum class State { Disconnected, Connecting, Connected } fun attach() diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/impl/remote/IdListTrackListQueryFactory.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/impl/remote/IdListTrackListQueryFactory.kt index f33c77e0f..e7362ef4b 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/impl/remote/IdListTrackListQueryFactory.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/impl/remote/IdListTrackListQueryFactory.kt @@ -2,7 +2,7 @@ package io.casey.musikcube.remote.service.websocket.model.impl.remote import io.casey.musikcube.remote.Application import io.casey.musikcube.remote.injection.DaggerDataComponent -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.service.websocket.model.ITrack import io.casey.musikcube.remote.service.websocket.model.ITrackListQueryFactory import io.reactivex.Observable @@ -10,14 +10,14 @@ import org.json.JSONObject import javax.inject.Inject class IdListTrackListQueryFactory(private val idList: List): ITrackListQueryFactory { - @Inject protected lateinit var dataProvider: IDataProvider + @Inject protected lateinit var metadataProxy: IMetadataProxy init { DaggerDataComponent.builder() .appComponent(Application.appComponent) .build().inject(this) - dataProvider.attach() + metadataProxy.attach() } override fun page(offset: Int, limit: Int): Observable>? { @@ -29,7 +29,7 @@ class IdListTrackListQueryFactory(private val idList: List): ITrackListQ } val missing = RemoteTrack(JSONObject()) - return dataProvider.getTracks(window) + return metadataProxy.getTracks(window) .flatMap{ it -> val result = mutableListOf() for (i in 0 until max) { @@ -43,6 +43,6 @@ class IdListTrackListQueryFactory(private val idList: List): ITrackListQ override fun offline(): Boolean = false fun destroy() { - dataProvider.destroy() + metadataProxy.destroy() } } \ No newline at end of file diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/impl/remote/RemoteDataProvider.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/impl/remote/RemoteMetadataProxy.kt similarity index 97% rename from src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/impl/remote/RemoteDataProvider.kt rename to src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/impl/remote/RemoteMetadataProxy.kt index f820f9e11..4930dc10e 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/impl/remote/RemoteDataProvider.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/service/websocket/model/impl/remote/RemoteMetadataProxy.kt @@ -15,12 +15,12 @@ import io.reactivex.subjects.ReplaySubject import org.json.JSONArray import org.json.JSONObject -class RemoteDataProvider(private val service: WebSocketService) : IDataProvider { +class RemoteMetadataProxy(private val service: WebSocketService) : IMetadataProxy { private var disposables = CompositeDisposable() private var currentState = mapState(service.state) private val connectionStatePublisher: ReplaySubject< - Pair> = ReplaySubject.createWithSize(1) + Pair> = ReplaySubject.createWithSize(1) private val playQueueStatePublisher: PublishSubject = PublishSubject.create() @@ -32,7 +32,7 @@ class RemoteDataProvider(private val service: WebSocketService) : IDataProvider }, { /*error */ })) } - override val state: IDataProvider.State + override val state: IMetadataProxy.State get() = currentState override fun getAlbums(filter: String): Observable> = @@ -550,7 +550,7 @@ class RemoteDataProvider(private val service: WebSocketService) : IDataProvider .observeOn(AndroidSchedulers.mainThread()) } - override fun observeState(): Observable> = + override fun observeState(): Observable> = connectionStatePublisher.observeOn(AndroidSchedulers.mainThread()) override fun observePlayQueue(): Observable = @@ -602,11 +602,11 @@ class RemoteDataProvider(private val service: WebSocketService) : IDataProvider } } - private fun mapState(state: WebSocketService.State): IDataProvider.State = + private fun mapState(state: WebSocketService.State): IMetadataProxy.State = when (state) { - WebSocketService.State.Disconnected -> IDataProvider.State.Disconnected - WebSocketService.State.Connecting -> IDataProvider.State.Connecting - WebSocketService.State.Connected -> IDataProvider.State.Connected + WebSocketService.State.Disconnected -> IMetadataProxy.State.Disconnected + WebSocketService.State.Connecting -> IMetadataProxy.State.Connecting + WebSocketService.State.Connected -> IMetadataProxy.State.Connected } companion object { diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/albums/fragment/AlbumBrowseFragment.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/albums/fragment/AlbumBrowseFragment.kt index 5d6657a54..ae18d9013 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/albums/fragment/AlbumBrowseFragment.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/albums/fragment/AlbumBrowseFragment.kt @@ -9,7 +9,7 @@ import android.view.ViewGroup import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView import io.casey.musikcube.remote.R import io.casey.musikcube.remote.service.websocket.model.IAlbum -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.ui.albums.adapter.AlbumBrowseAdapter import io.casey.musikcube.remote.ui.albums.constant.Album import io.casey.musikcube.remote.ui.navigation.Navigate @@ -22,7 +22,7 @@ import io.casey.musikcube.remote.ui.shared.extension.getLayoutId import io.casey.musikcube.remote.ui.shared.extension.getTitleOverride import io.casey.musikcube.remote.ui.shared.extension.setupDefaultRecyclerView import io.casey.musikcube.remote.ui.shared.fragment.BaseFragment -import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin +import io.casey.musikcube.remote.ui.shared.mixin.MetadataProxyMixin import io.casey.musikcube.remote.ui.shared.mixin.ItemContextMenuMixin import io.casey.musikcube.remote.ui.shared.mixin.PlaybackMixin import io.casey.musikcube.remote.ui.shared.view.EmptyListView @@ -35,7 +35,7 @@ class AlbumBrowseFragment: BaseFragment(), IFilterable, ITitleProvider, ITranspo private var lastFilter = "" private lateinit var adapter: AlbumBrowseAdapter private lateinit var playback: PlaybackMixin - private lateinit var data: DataProviderMixin + private lateinit var data: MetadataProxyMixin private lateinit var emptyView: EmptyListView override val title: String @@ -43,7 +43,7 @@ class AlbumBrowseFragment: BaseFragment(), IFilterable, ITitleProvider, ITranspo override fun onCreate(savedInstanceState: Bundle?) { component.inject(this) - data = mixin(DataProviderMixin()) + data = mixin(MetadataProxyMixin()) playback = mixin(PlaybackMixin()) mixin(ItemContextMenuMixin(appCompatActivity, fragment = this)) @@ -87,7 +87,7 @@ class AlbumBrowseFragment: BaseFragment(), IFilterable, ITitleProvider, ITranspo override fun onInitObservables() { disposables.add(data.provider.observeState().subscribeBy( onNext = { state -> - if (state.first == IDataProvider.State.Connected) { + if (state.first == IMetadataProxy.State.Connected) { requery() } else { emptyView.update(state.first, adapter.itemCount) diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/category/fragment/AllCategoriesFragment.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/category/fragment/AllCategoriesFragment.kt index e0bd452ff..37aedaae2 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/category/fragment/AllCategoriesFragment.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/category/fragment/AllCategoriesFragment.kt @@ -6,18 +6,18 @@ import android.view.View import android.view.ViewGroup import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView import io.casey.musikcube.remote.R -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.ui.category.adapter.AllCategoriesAdapter import io.casey.musikcube.remote.ui.navigation.Navigate import io.casey.musikcube.remote.ui.shared.activity.ITitleProvider import io.casey.musikcube.remote.ui.shared.extension.getLayoutId import io.casey.musikcube.remote.ui.shared.extension.setupDefaultRecyclerView import io.casey.musikcube.remote.ui.shared.fragment.BaseFragment -import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin +import io.casey.musikcube.remote.ui.shared.mixin.MetadataProxyMixin import io.reactivex.rxkotlin.subscribeBy class AllCategoriesFragment: BaseFragment(), ITitleProvider { - private lateinit var data: DataProviderMixin + private lateinit var data: MetadataProxyMixin private lateinit var adapter: AllCategoriesAdapter override val title: String @@ -25,7 +25,7 @@ class AllCategoriesFragment: BaseFragment(), ITitleProvider { override fun onCreate(savedInstanceState: Bundle?) { component.inject(this) - data = mixin(DataProviderMixin()) + data = mixin(MetadataProxyMixin()) super.onCreate(savedInstanceState) @@ -41,7 +41,7 @@ class AllCategoriesFragment: BaseFragment(), ITitleProvider { override fun onInitObservables() { disposables.add(data.provider.observeState().subscribeBy( onNext = { states -> - if (states.first == IDataProvider.State.Connected) { + if (states.first == IMetadataProxy.State.Connected) { requery() } }, diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/category/fragment/CategoryBrowseFragment.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/category/fragment/CategoryBrowseFragment.kt index 0b96c025e..874bafebd 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/category/fragment/CategoryBrowseFragment.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/category/fragment/CategoryBrowseFragment.kt @@ -13,7 +13,7 @@ import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView import io.casey.musikcube.remote.R import io.casey.musikcube.remote.service.playback.impl.remote.Metadata import io.casey.musikcube.remote.service.websocket.model.ICategoryValue -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.ui.category.adapter.CategoryBrowseAdapter import io.casey.musikcube.remote.ui.category.constant.Category import io.casey.musikcube.remote.ui.category.constant.NavigationType @@ -28,7 +28,7 @@ import io.casey.musikcube.remote.ui.shared.extension.getLayoutId import io.casey.musikcube.remote.ui.shared.extension.getTitleOverride import io.casey.musikcube.remote.ui.shared.extension.setupDefaultRecyclerView import io.casey.musikcube.remote.ui.shared.fragment.BaseFragment -import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin +import io.casey.musikcube.remote.ui.shared.mixin.MetadataProxyMixin import io.casey.musikcube.remote.ui.shared.mixin.ItemContextMenuMixin import io.casey.musikcube.remote.ui.shared.mixin.PlaybackMixin import io.casey.musikcube.remote.ui.shared.view.EmptyListView @@ -40,7 +40,7 @@ class CategoryBrowseFragment: BaseFragment(), IFilterable, ITitleProvider, ITran private var lastFilter: String? = null private lateinit var rootView: View private lateinit var emptyView: EmptyListView - private lateinit var data: DataProviderMixin + private lateinit var data: MetadataProxyMixin private lateinit var playback: PlaybackMixin private val navigationType: NavigationType @@ -68,7 +68,7 @@ class CategoryBrowseFragment: BaseFragment(), IFilterable, ITitleProvider, ITran super.onCreate(savedInstanceState) component.inject(this) - data = mixin(DataProviderMixin()) + data = mixin(MetadataProxyMixin()) playback = mixin(PlaybackMixin()) mixin(ItemContextMenuMixin(appCompatActivity, contextMenuListener, this)) @@ -118,11 +118,11 @@ class CategoryBrowseFragment: BaseFragment(), IFilterable, ITitleProvider, ITran disposables.add(data.provider.observeState().subscribeBy( onNext = { states -> when (states.first) { - IDataProvider.State.Connected -> { + IMetadataProxy.State.Connected -> { filterDebouncer.cancel() requery() } - IDataProvider.State.Disconnected -> { + IMetadataProxy.State.Disconnected -> { emptyView.update(states.first, adapter.itemCount) } else -> { diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/home/activity/MainActivity.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/home/activity/MainActivity.kt index da6870383..7d094a839 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/home/activity/MainActivity.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/home/activity/MainActivity.kt @@ -19,7 +19,7 @@ import io.casey.musikcube.remote.service.playback.PlaybackState import io.casey.musikcube.remote.service.playback.RepeatMode import io.casey.musikcube.remote.service.playback.impl.remote.Metadata import io.casey.musikcube.remote.service.websocket.WebSocketService -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.ui.home.fragment.InvalidPasswordDialogFragment import io.casey.musikcube.remote.ui.home.view.MainMetadataView import io.casey.musikcube.remote.ui.navigation.Navigate @@ -31,7 +31,7 @@ import io.casey.musikcube.remote.ui.shared.extension.getColorCompat import io.casey.musikcube.remote.ui.shared.extension.setCheckWithoutEvent import io.casey.musikcube.remote.ui.shared.extension.showSnackbar import io.casey.musikcube.remote.ui.shared.extension.toolbar -import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin +import io.casey.musikcube.remote.ui.shared.mixin.MetadataProxyMixin import io.casey.musikcube.remote.ui.shared.mixin.PlaybackMixin import io.casey.musikcube.remote.ui.shared.util.Duration import io.casey.musikcube.remote.ui.shared.util.UpdateCheck @@ -42,7 +42,7 @@ class MainActivity : BaseActivity() { private var seekbarValue = -1 private var blink = 0 - private lateinit var data: DataProviderMixin + private lateinit var data: MetadataProxyMixin private lateinit var playback: PlaybackMixin /* views */ @@ -64,7 +64,7 @@ class MainActivity : BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { component.inject(this) - data = mixin(DataProviderMixin()) + data = mixin(MetadataProxyMixin()) playback = mixin(PlaybackMixin { rebindUi() }) super.onCreate(savedInstanceState) @@ -174,12 +174,12 @@ class MainActivity : BaseActivity() { disposables.add(data.provider.observeState().subscribe( { states -> when (states.first) { - IDataProvider.State.Connected -> { + IMetadataProxy.State.Connected -> { rebindUi() checkShowSpotlight() checkShowApiMismatch() } - IDataProvider.State.Disconnected -> { + IMetadataProxy.State.Disconnected -> { clearUi() } else -> { @@ -424,7 +424,7 @@ class MainActivity : BaseActivity() { object : ViewTreeObserver.OnGlobalLayoutListener { override fun onGlobalLayout() { val toolbarButton = findViewById(R.id.action_remote_toggle) - if (toolbarButton != null && data.provider.state == IDataProvider.State.Connected) { + if (toolbarButton != null && data.provider.state == IMetadataProxy.State.Connected) { checkShowSpotlight() window.decorView.viewTreeObserver.removeOnGlobalLayoutListener(this) } diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/playqueue/fragment/PlayQueueFragment.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/playqueue/fragment/PlayQueueFragment.kt index 4faa9600b..2b4c15849 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/playqueue/fragment/PlayQueueFragment.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/playqueue/fragment/PlayQueueFragment.kt @@ -6,7 +6,7 @@ import android.view.View import android.view.ViewGroup import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView import io.casey.musikcube.remote.R -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.service.websocket.model.ITrack import io.casey.musikcube.remote.ui.playqueue.adapter.PlayQueueAdapter import io.casey.musikcube.remote.ui.playqueue.constant.PlayQueue @@ -14,7 +14,7 @@ import io.casey.musikcube.remote.ui.shared.activity.ITitleProvider import io.casey.musikcube.remote.ui.shared.extension.getLayoutId import io.casey.musikcube.remote.ui.shared.extension.setupDefaultRecyclerView import io.casey.musikcube.remote.ui.shared.fragment.BaseFragment -import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin +import io.casey.musikcube.remote.ui.shared.mixin.MetadataProxyMixin import io.casey.musikcube.remote.ui.shared.mixin.ItemContextMenuMixin import io.casey.musikcube.remote.ui.shared.mixin.PlaybackMixin import io.casey.musikcube.remote.ui.shared.model.DefaultSlidingWindow @@ -24,7 +24,7 @@ import io.reactivex.rxkotlin.subscribeBy class PlayQueueFragment: BaseFragment(), ITitleProvider { private var offlineQueue: Boolean = false - private lateinit var data: DataProviderMixin + private lateinit var data: MetadataProxyMixin private lateinit var playback: PlaybackMixin private lateinit var tracks: DefaultSlidingWindow private lateinit var adapter: PlayQueueAdapter @@ -35,7 +35,7 @@ class PlayQueueFragment: BaseFragment(), ITitleProvider { override fun onCreate(savedInstanceState: Bundle?) { component.inject(this) - data = mixin(DataProviderMixin()) + data = mixin(MetadataProxyMixin()) playback = mixin(PlaybackMixin(playbackEvents)) mixin(ItemContextMenuMixin(appCompatActivity, null, this)) super.onCreate(savedInstanceState) @@ -76,7 +76,7 @@ class PlayQueueFragment: BaseFragment(), ITitleProvider { override fun onInitObservables() { disposables.add(data.provider.observeState().subscribeBy( onNext = { states -> - if (states.first == IDataProvider.State.Connected) { + if (states.first == IMetadataProxy.State.Connected) { tracks.requery() } else { diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/RemoteEqActivity.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/RemoteEqActivity.kt index 58a40fb8d..0675bbdb7 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/RemoteEqActivity.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/RemoteEqActivity.kt @@ -11,12 +11,12 @@ import io.casey.musikcube.remote.framework.ViewModel import io.casey.musikcube.remote.ui.settings.viewmodel.BaseRemoteViewModel import io.casey.musikcube.remote.ui.settings.viewmodel.RemoteEqViewModel import io.casey.musikcube.remote.ui.shared.activity.BaseActivity -import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin +import io.casey.musikcube.remote.ui.shared.mixin.MetadataProxyMixin import io.casey.musikcube.remote.ui.shared.mixin.ViewModelMixin import io.reactivex.rxkotlin.subscribeBy class RemoteEqActivity: BaseActivity() { - private lateinit var data: DataProviderMixin + private lateinit var data: MetadataProxyMixin private lateinit var viewModel: RemoteEqViewModel private lateinit var loadingOverlay: View private lateinit var table: TableLayout @@ -26,7 +26,7 @@ class RemoteEqActivity: BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { component.inject(this) - data = mixin(DataProviderMixin()) + data = mixin(MetadataProxyMixin()) mixin(ViewModelMixin(this)) title = getString(R.string.remote_settings_eq_title) diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/RemoteSettingsActivity.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/RemoteSettingsActivity.kt index f3ef65ca2..2930fb6d2 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/RemoteSettingsActivity.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/RemoteSettingsActivity.kt @@ -14,14 +14,14 @@ import io.casey.musikcube.remote.service.websocket.model.TransportType import io.casey.musikcube.remote.ui.navigation.Transition import io.casey.musikcube.remote.ui.settings.viewmodel.RemoteSettingsViewModel import io.casey.musikcube.remote.ui.shared.activity.BaseActivity -import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin +import io.casey.musikcube.remote.ui.shared.mixin.MetadataProxyMixin import io.casey.musikcube.remote.ui.shared.mixin.ViewModelMixin import io.reactivex.rxkotlin.subscribeBy import io.casey.musikcube.remote.ui.settings.viewmodel.BaseRemoteViewModel.State as ViewModelState class RemoteSettingsActivity: BaseActivity() { private var initialized = false - private lateinit var data: DataProviderMixin + private lateinit var data: MetadataProxyMixin private lateinit var viewModel: RemoteSettingsViewModel private lateinit var loadingOverlay: View private lateinit var driverSpinner: Spinner @@ -37,7 +37,7 @@ class RemoteSettingsActivity: BaseActivity() { override fun onCreate(savedInstanceState: Bundle?) { component.inject(this) - data = mixin(DataProviderMixin()) + data = mixin(MetadataProxyMixin()) mixin(ViewModelMixin(this)) super.onCreate(savedInstanceState) diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/SettingsActivity.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/SettingsActivity.kt index 79a40df0a..bb3f88d02 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/SettingsActivity.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/activity/SettingsActivity.kt @@ -23,7 +23,7 @@ import io.casey.musikcube.remote.ui.settings.model.Connection import io.casey.musikcube.remote.ui.settings.model.ConnectionsDb import io.casey.musikcube.remote.ui.shared.activity.BaseActivity import io.casey.musikcube.remote.ui.shared.extension.* -import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin +import io.casey.musikcube.remote.ui.shared.mixin.MetadataProxyMixin import io.casey.musikcube.remote.ui.shared.mixin.PlaybackMixin import java.util.* import javax.inject.Inject @@ -49,10 +49,10 @@ class SettingsActivity : BaseActivity() { private lateinit var cacheSpinner: Spinner private lateinit var titleEllipsisSpinner: Spinner private lateinit var playback: PlaybackMixin - private lateinit var data: DataProviderMixin + private lateinit var data: MetadataProxyMixin override fun onCreate(savedInstanceState: Bundle?) { - data = mixin(DataProviderMixin()) + data = mixin(MetadataProxyMixin()) playback = mixin(PlaybackMixin()) component.inject(this) super.onCreate(savedInstanceState) diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/viewmodel/BaseRemoteViewModel.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/viewmodel/BaseRemoteViewModel.kt index 3d835861d..2405caa88 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/viewmodel/BaseRemoteViewModel.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/settings/viewmodel/BaseRemoteViewModel.kt @@ -1,22 +1,22 @@ package io.casey.musikcube.remote.ui.settings.viewmodel import io.casey.musikcube.remote.framework.ViewModel -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.reactivex.disposables.CompositeDisposable import io.reactivex.rxkotlin.subscribeBy abstract class BaseRemoteViewModel: ViewModel() { - protected var provider: IDataProvider? = null + protected var provider: IMetadataProxy? = null protected var disposables = CompositeDisposable() enum class State { Disconnected, Saving, Saved, Loading, Ready, Error } - fun attach(provider: IDataProvider) { + fun attach(provider: IMetadataProxy) { this.provider = provider this.provider?.let { this.disposables.add(it.observeState().subscribeBy( onNext = { - if (it.first == IDataProvider.State.Connected) { + if (it.first == IMetadataProxy.State.Connected) { onConnected() } }, diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/mixin/ItemContextMenuMixin.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/mixin/ItemContextMenuMixin.kt index 943cc82b5..b14177300 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/mixin/ItemContextMenuMixin.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/mixin/ItemContextMenuMixin.kt @@ -18,7 +18,7 @@ import io.casey.musikcube.remote.service.playback.PlaybackServiceFactory import io.casey.musikcube.remote.service.playback.impl.remote.Metadata import io.casey.musikcube.remote.service.websocket.model.IAlbum import io.casey.musikcube.remote.service.websocket.model.ICategoryValue -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.service.websocket.model.ITrack import io.casey.musikcube.remote.ui.category.constant.Category import io.casey.musikcube.remote.ui.navigation.Navigate @@ -38,7 +38,7 @@ class ItemContextMenuMixin(private val activity: AppCompatActivity, internal val fragment: BaseFragment? = null): MixinBase() { private enum class TrackType { Normal, Playlist } - @Inject lateinit var provider: IDataProvider + @Inject lateinit var provider: IMetadataProxy open class EventListener { open fun onPlaylistDeleted(id: Long, name: String) { } diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/mixin/DataProviderMixin.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/mixin/MetadataProxyMixin.kt similarity index 83% rename from src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/mixin/DataProviderMixin.kt rename to src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/mixin/MetadataProxyMixin.kt index 8dd69d9c9..ead8f4366 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/mixin/DataProviderMixin.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/mixin/MetadataProxyMixin.kt @@ -5,12 +5,12 @@ import io.casey.musikcube.remote.Application import io.casey.musikcube.remote.framework.MixinBase import io.casey.musikcube.remote.injection.DaggerViewComponent import io.casey.musikcube.remote.service.websocket.WebSocketService -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import javax.inject.Inject -class DataProviderMixin : MixinBase() { +class MetadataProxyMixin : MixinBase() { @Inject lateinit var wss: WebSocketService - @Inject lateinit var provider: IDataProvider + @Inject lateinit var provider: IMetadataProxy override fun onCreate(bundle: Bundle) { super.onCreate(bundle) diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/model/BaseSlidingWindow.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/model/BaseSlidingWindow.kt index fb424fad5..7ab4299a6 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/model/BaseSlidingWindow.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/model/BaseSlidingWindow.kt @@ -3,14 +3,14 @@ package io.casey.musikcube.remote.ui.shared.model import androidx.recyclerview.widget.RecyclerView import com.simplecityapps.recyclerview_fastscroll.interfaces.OnFastScrollStateChangeListener import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.service.websocket.model.ITrack import io.casey.musikcube.remote.util.Debouncer import io.reactivex.disposables.CompositeDisposable abstract class BaseSlidingWindow( private val recyclerView: FastScrollRecyclerView, - private val dataProvider: IDataProvider) : ITrackListSlidingWindow + private val metadataProxy: IMetadataProxy) : ITrackListSlidingWindow { private var scrollState = RecyclerView.SCROLL_STATE_IDLE private var fastScrollerActive = false @@ -40,7 +40,7 @@ abstract class BaseSlidingWindow( } override fun resume() { - disposables.add(dataProvider.observePlayQueue() + disposables.add(metadataProxy.observePlayQueue() .subscribe({ requery() }, { /* error */ })) recyclerView.setOnFastScrollStateChangeListener(fastScrollStateChangeListener) diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/model/DefaultSlidingWindow.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/model/DefaultSlidingWindow.kt index ef1b8ca3c..918d8f93a 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/model/DefaultSlidingWindow.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/model/DefaultSlidingWindow.kt @@ -2,16 +2,16 @@ package io.casey.musikcube.remote.ui.shared.model import android.util.Log import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.service.websocket.model.ITrack import io.casey.musikcube.remote.service.websocket.model.ITrackListQueryFactory import io.reactivex.rxkotlin.subscribeBy class DefaultSlidingWindow( private val recyclerView: FastScrollRecyclerView, - dataProvider: IDataProvider, + metadataProxy: IMetadataProxy, private val queryFactory: ITrackListQueryFactory) - : BaseSlidingWindow(recyclerView, dataProvider) + : BaseSlidingWindow(recyclerView, metadataProxy) { private var queryOffset = -1 private var queryLimit = -1 diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/view/EmptyListView.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/view/EmptyListView.kt index 6ee3eac85..789e57fbe 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/view/EmptyListView.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/shared/view/EmptyListView.kt @@ -13,7 +13,7 @@ import io.casey.musikcube.remote.injection.DaggerViewComponent import io.casey.musikcube.remote.service.playback.PlaybackServiceFactory import io.casey.musikcube.remote.service.playback.impl.streaming.StreamingPlaybackService import io.casey.musikcube.remote.service.websocket.WebSocketService -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.ui.shared.extension.setVisible import io.casey.musikcube.remote.ui.tracks.activity.TrackListActivity import javax.inject.Inject @@ -86,7 +86,7 @@ class EmptyListView : FrameLayout { } } - fun update(state: IDataProvider.State, count: Int) { + fun update(state: IMetadataProxy.State, count: Int) { if (count > 0) { visibility = View.INVISIBLE } @@ -96,7 +96,7 @@ class EmptyListView : FrameLayout { val showOfflineContainer = capability == Capability.OnlineOnly && PlaybackServiceFactory.instance(context) is StreamingPlaybackService && - state != IDataProvider.State.Connected + state != IMetadataProxy.State.Connected offlineContainer?.setVisible(showOfflineContainer) emptyContainer?.setVisible(!showOfflineContainer) diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/activity/EditPlaylistActivity.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/activity/EditPlaylistActivity.kt index 64f7dcba3..d7111ed24 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/activity/EditPlaylistActivity.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/activity/EditPlaylistActivity.kt @@ -17,7 +17,7 @@ import io.casey.musikcube.remote.ui.shared.activity.BaseActivity import io.casey.musikcube.remote.ui.shared.extension.setupDefaultRecyclerView import io.casey.musikcube.remote.ui.shared.extension.showErrorSnackbar import io.casey.musikcube.remote.ui.shared.fragment.BaseDialogFragment -import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin +import io.casey.musikcube.remote.ui.shared.mixin.MetadataProxyMixin import io.casey.musikcube.remote.ui.shared.mixin.ViewModelMixin import io.casey.musikcube.remote.ui.tracks.adapter.EditPlaylistAdapter import io.casey.musikcube.remote.ui.tracks.model.EditPlaylistViewModel @@ -26,13 +26,13 @@ import io.reactivex.rxkotlin.subscribeBy class EditPlaylistActivity: BaseActivity() { private lateinit var viewModel: EditPlaylistViewModel - private lateinit var data: DataProviderMixin + private lateinit var data: MetadataProxyMixin private lateinit var adapter: EditPlaylistAdapter private var playlistName = "" override fun onCreate(savedInstanceState: Bundle?) { mixin(ViewModelMixin(this)) - data = mixin(DataProviderMixin()) + data = mixin(MetadataProxyMixin()) super.onCreate(savedInstanceState) playlistName = extras.getString(EXTRA_PLAYLIST_NAME, "-") title = getString(R.string.playlist_edit_activity, playlistName) diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/fragment/TrackListFragment.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/fragment/TrackListFragment.kt index fa61cdf6e..908ba1245 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/fragment/TrackListFragment.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/fragment/TrackListFragment.kt @@ -8,7 +8,7 @@ import androidx.appcompat.app.AppCompatActivity import com.simplecityapps.recyclerview_fastscroll.views.FastScrollRecyclerView import io.casey.musikcube.remote.R import io.casey.musikcube.remote.service.playback.impl.remote.Metadata -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.service.websocket.model.ITrack import io.casey.musikcube.remote.service.websocket.model.ITrackListQueryFactory import io.casey.musikcube.remote.ui.shared.activity.IFilterable @@ -18,7 +18,7 @@ import io.casey.musikcube.remote.ui.shared.activity.ITransportObserver import io.casey.musikcube.remote.ui.shared.constant.Shared import io.casey.musikcube.remote.ui.shared.extension.* import io.casey.musikcube.remote.ui.shared.fragment.BaseFragment -import io.casey.musikcube.remote.ui.shared.mixin.DataProviderMixin +import io.casey.musikcube.remote.ui.shared.mixin.MetadataProxyMixin import io.casey.musikcube.remote.ui.shared.mixin.ItemContextMenuMixin import io.casey.musikcube.remote.ui.shared.mixin.PlaybackMixin import io.casey.musikcube.remote.ui.shared.model.DefaultSlidingWindow @@ -38,7 +38,7 @@ class TrackListFragment: BaseFragment(), IFilterable, ITitleProvider, ITransport private lateinit var adapter: TrackListAdapter private lateinit var queryFactory: ITrackListQueryFactory - private lateinit var data: DataProviderMixin + private lateinit var data: MetadataProxyMixin private lateinit var playback: PlaybackMixin private var categoryType: String = "" @@ -49,7 +49,7 @@ class TrackListFragment: BaseFragment(), IFilterable, ITitleProvider, ITransport override fun onCreate(savedInstanceState: Bundle?) { component.inject(this) - data = mixin(DataProviderMixin()) + data = mixin(MetadataProxyMixin()) playback = mixin(PlaybackMixin()) super.onCreate(savedInstanceState) @@ -83,8 +83,8 @@ class TrackListFragment: BaseFragment(), IFilterable, ITitleProvider, ITransport disposables.add(data.provider.observeState().subscribeBy( onNext = { states -> val shouldRequery = - states.first === IDataProvider.State.Connected || - (states.first === IDataProvider.State.Disconnected && isOfflineTracks) + states.first === IMetadataProxy.State.Connected || + (states.first === IMetadataProxy.State.Disconnected && isOfflineTracks) if (shouldRequery) { filterDebouncer.cancel() diff --git a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/model/EditPlaylistViewModel.kt b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/model/EditPlaylistViewModel.kt index 0c02eabd7..8ec3d9f24 100644 --- a/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/model/EditPlaylistViewModel.kt +++ b/src/musikdroid/app/src/main/java/io/casey/musikcube/remote/ui/tracks/model/EditPlaylistViewModel.kt @@ -2,7 +2,7 @@ package io.casey.musikcube.remote.ui.tracks.model import io.casey.musikcube.remote.framework.ViewModel import io.casey.musikcube.remote.service.playback.impl.remote.Metadata.Category.PLAYLISTS -import io.casey.musikcube.remote.service.websocket.model.IDataProvider +import io.casey.musikcube.remote.service.websocket.model.IMetadataProxy import io.casey.musikcube.remote.service.websocket.model.ITrack import io.casey.musikcube.remote.service.websocket.model.impl.remote.RemoteTrack import io.reactivex.Observable @@ -17,7 +17,7 @@ class EditPlaylistViewModel(private val playlistId: Long): ViewModel = mutableListOf() private val cache = object : LinkedHashMap() { @@ -29,13 +29,13 @@ class EditPlaylistViewModel(private val playlistId: Long): ViewModel +#include #include #include #include @@ -64,12 +64,12 @@ class ReadWriteLock { struct Context { Context() { - this->dataProvider = nullptr; + this->metadataProxy = nullptr; this->prefs = nullptr; this->playback = nullptr; } - musik::core::sdk::ISimpleDataProvider* dataProvider; + musik::core::sdk::IMetadataProxy* metadataProxy; musik::core::sdk::IPreferences* prefs; musik::core::sdk::IPlaybackService* playback; musik::core::sdk::IEnvironment* environment; diff --git a/src/plugins/server/HttpServer.cpp b/src/plugins/server/HttpServer.cpp index 58114fb37..03fc261c2 100644 --- a/src/plugins/server/HttpServer.cpp +++ b/src/plugins/server/HttpServer.cpp @@ -412,7 +412,7 @@ int HttpServer::HandleAudioTrackRequest( if (byExternalId) { std::string externalId = urlDecode(pathParts.at(2)); - track = server->context.dataProvider->QueryTrackByExternalId(externalId.c_str()); + track = server->context.metadataProxy->QueryTrackByExternalId(externalId.c_str()); #ifdef ENABLE_DEBUG std::cerr << "externalId: " << externalId << "\n"; @@ -421,7 +421,7 @@ int HttpServer::HandleAudioTrackRequest( } else if (pathParts.at(1) == fragment::id) { uint64_t id = std::stoull(urlDecode(pathParts.at(2))); - track = server->context.dataProvider->QueryTrackById(id); + track = server->context.metadataProxy->QueryTrackById(id); } if (track) { diff --git a/src/plugins/server/WebSocketServer.cpp b/src/plugins/server/WebSocketServer.cpp index 4bb7bebde..d02c4571d 100644 --- a/src/plugins/server/WebSocketServer.cpp +++ b/src/plugins/server/WebSocketServer.cpp @@ -694,7 +694,7 @@ ITrackList* WebSocketServer::QueryTracks(json& request, int& limit, int& offset) json& options = request[message::options]; std::string filter = options.value(key::filter, ""); this->GetLimitAndOffset(options, limit, offset); - return context.dataProvider->QueryTracks(filter.c_str(), limit, offset); + return context.metadataProxy->QueryTracks(filter.c_str(), limit, offset); } return nullptr; } @@ -718,7 +718,7 @@ void WebSocketServer::RespondWithQueryTracksByExternalIds(connection_hdl connect json& externalIds = options[key::external_ids]; if (externalIds.is_array()) { auto externalIdArray = jsonToStringArray(externalIds); - ITrackList* trackList = context.dataProvider + ITrackList* trackList = context.metadataProxy ->QueryTracksByExternalId( (const char**) externalIdArray.get(), externalIds.size()); @@ -856,7 +856,7 @@ void WebSocketServer::RespondWithQueryAlbums(connection_hdl connection, json& re std::string category = options.value(key::category, ""); int64_t categoryId = options.value(key::category_id, -1); - IMapList* albumList = context.dataProvider + IMapList* albumList = context.metadataProxy ->QueryAlbums(category.c_str(), categoryId, filter.c_str()); json result = json::array(); @@ -916,7 +916,7 @@ void WebSocketServer::RespondWithPlayTracks(connection_hdl connection, json& req if (externalIds.is_array()) { auto externalIdArray = jsonToStringArray(externalIds); - ITrackList* trackList = context.dataProvider + ITrackList* trackList = context.metadataProxy ->QueryTracksByExternalId( (const char**)externalIdArray.get(), externalIds.size()); @@ -970,11 +970,11 @@ ITrackList* WebSocketServer::QueryTracksByCategory(json& request, int& limit, in if (predicates.size()) { auto predicateList = jsonToPredicateList(predicates); - return context.dataProvider->QueryTracksByCategories( + return context.metadataProxy->QueryTracksByCategories( predicateList.get(), predicates.size(), filter.c_str(), limit, offset); } else { - return context.dataProvider->QueryTracksByCategory( + return context.metadataProxy->QueryTracksByCategory( category.c_str(), selectedId, filter.c_str(), limit, offset); } } @@ -995,7 +995,7 @@ void WebSocketServer::RespondWithQueryTracksByCategory(connection_hdl connection } void WebSocketServer::RespondWithListCategories(connection_hdl connection, json& request) { - IValueList* result = context.dataProvider->ListCategories(); + IValueList* result = context.metadataProxy->ListCategories(); if (result != nullptr) { json list = json::array(); @@ -1031,7 +1031,7 @@ void WebSocketServer::RespondWithQueryCategory(connection_hdl connection, json& if (predicates.size()) { auto predicateList = jsonToPredicateList(predicates); - result = context.dataProvider + result = context.metadataProxy ->QueryCategoryWithPredicates( category.c_str(), predicateList.get(), @@ -1039,7 +1039,7 @@ void WebSocketServer::RespondWithQueryCategory(connection_hdl connection, json& filter.c_str()); } else { - result = context.dataProvider + result = context.metadataProxy ->QueryCategoryWithPredicate( category.c_str(), predicate.c_str(), @@ -1086,7 +1086,7 @@ void WebSocketServer::RespondWithPlayAllTracks(connection_hdl connection, json& time = request[message::options].value(key::time, 0.0); } - ITrackList* tracks = context.dataProvider->QueryTracks(filter.c_str()); + ITrackList* tracks = context.metadataProxy->QueryTracks(filter.c_str()); if (tracks) { context.playback->Play(tracks, index); @@ -1175,7 +1175,7 @@ void WebSocketServer::RespondWithSavePlaylist(connection_hdl connection, json& r if (externalIds.is_array()) { auto externalIdArray = jsonToStringArray(externalIds); - int64_t newPlaylistId = this->context.dataProvider + int64_t newPlaylistId = this->context.metadataProxy ->SavePlaylistWithExternalIds( (const char**) externalIdArray.get(), externalIds.size(), @@ -1209,7 +1209,7 @@ void WebSocketServer::RespondWithSavePlaylist(connection_hdl connection, json& r } if (tracks) { - int64_t newPlaylistId = this->context.dataProvider + int64_t newPlaylistId = this->context.metadataProxy ->SavePlaylistWithTrackList(tracks, name.c_str(), id); tracks->Release(); @@ -1236,7 +1236,7 @@ void WebSocketServer::RespondWithRenamePlaylist(connection_hdl connection, json& int64_t id = options[key::playlist_id]; std::string name = options[key::playlist_name]; - this->context.dataProvider->RenamePlaylist(id, name.c_str()) + this->context.metadataProxy->RenamePlaylist(id, name.c_str()) ? this->RespondWithSuccess(connection, request) : this->RespondWithFailure(connection, request); } @@ -1245,7 +1245,7 @@ void WebSocketServer::RespondWithDeletePlaylist(connection_hdl connection, json& auto& options = request[message::options]; int64_t id = options[key::playlist_id]; - this->context.dataProvider->DeletePlaylist(id) + this->context.metadataProxy->DeletePlaylist(id) ? this->RespondWithSuccess(connection, request) : this->RespondWithFailure(connection, request); } @@ -1265,7 +1265,7 @@ void WebSocketServer::RespondWithAppendToPlaylist(connection_hdl connection, jso if (externalIds.is_array()) { auto externalIdArray = jsonToStringArray(externalIds); - bool result = this->context.dataProvider + bool result = this->context.metadataProxy ->AppendToPlaylistWithExternalIds( id, (const char**) externalIdArray.get(), @@ -1295,7 +1295,7 @@ void WebSocketServer::RespondWithAppendToPlaylist(connection_hdl connection, jso } if (tracks) { - bool result = this->context.dataProvider + bool result = this->context.metadataProxy ->AppendToPlaylistWithTrackList(id, tracks, offset); tracks->Release(); @@ -1527,7 +1527,7 @@ void WebSocketServer::RespondWithRemoveTracksFromPlaylist(connection_hdl connect auto ids = jsonToStringArray(*externalIdsIt); auto orders = jsonToIntArray(*sortOrdersIt); - updated = this->context.dataProvider + updated = this->context.metadataProxy ->RemoveTracksFromPlaylist( id, (const char**)ids.get(), diff --git a/src/plugins/server/main.cpp b/src/plugins/server/main.cpp index 1de314963..482b65818 100644 --- a/src/plugins/server/main.cpp +++ b/src/plugins/server/main.cpp @@ -84,10 +84,10 @@ static class PlaybackRemote : public IPlaybackRemote { } void CheckRunningStatus() { - if (!thread && context.environment && context.playback && context.prefs && context.dataProvider) { + if (!thread && context.environment && context.playback && context.prefs && context.metadataProxy) { thread.reset(new std::thread(std::bind(&PlaybackRemote::ThreadProc, this))); } - else if (thread && (!context.environment || !context.playback || !context.prefs || !context.dataProvider)) { + else if (thread && (!context.environment || !context.playback || !context.prefs || !context.metadataProxy)) { this->Stop(); } } @@ -202,8 +202,8 @@ extern "C" DLL_EXPORT void SetPreferences(musik::core::sdk::IPreferences* prefs) remote.CheckRunningStatus(); } -extern "C" DLL_EXPORT void SetSimpleDataProvider(musik::core::sdk::ISimpleDataProvider* dataProvider) { +extern "C" DLL_EXPORT void SetMetadataProxy(musik::core::sdk::IMetadataProxy* metadataProxy) { auto wl = context.lock.Write(); - context.dataProvider = dataProvider; + context.metadataProxy = metadataProxy; remote.CheckRunningStatus(); }