musikr: move storage/interpretation dependence to construction
This makes some testing and certain code more ergonomic.
This commit is contained in:
@@ -26,7 +26,6 @@ import dagger.hilt.InstallIn
|
||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import javax.inject.Singleton
|
||||
import org.oxycblt.musikr.Musikr
|
||||
import org.oxycblt.musikr.cache.CacheDatabase
|
||||
import org.oxycblt.musikr.playlist.db.PlaylistDatabase
|
||||
|
||||
@@ -48,6 +47,4 @@ class MusikrShimModule {
|
||||
@Singleton
|
||||
@Provides
|
||||
fun playlistDatabase(@ApplicationContext context: Context) = PlaylistDatabase.from(context)
|
||||
|
||||
@Provides fun musikr(@ApplicationContext context: Context) = Musikr.new(context)
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ import timber.log.Timber as L
|
||||
*/
|
||||
interface MusicRepository {
|
||||
val library: Library?
|
||||
|
||||
/** The current state of music loading. Null if no load has occurred yet. */
|
||||
val indexingState: IndexingState?
|
||||
|
||||
@@ -212,7 +213,6 @@ interface MusicRepository {
|
||||
class MusicRepositoryImpl
|
||||
@Inject
|
||||
constructor(
|
||||
private val musikr: Musikr,
|
||||
@ApplicationContext private val context: Context,
|
||||
private val cacheDatabase: CacheDatabase,
|
||||
private val playlistDatabase: PlaylistDatabase,
|
||||
@@ -375,9 +375,11 @@ constructor(
|
||||
StoredCovers.from(context, "covers"),
|
||||
StoredPlaylists.from(playlistDatabase))
|
||||
}
|
||||
|
||||
val interpretation = Interpretation(nameFactory, separators)
|
||||
|
||||
val newLibrary =
|
||||
musikr.run(
|
||||
locations, storage, Interpretation(nameFactory, separators), ::emitIndexingProgress)
|
||||
Musikr.new(context, storage, interpretation).run(locations, ::emitIndexingProgress)
|
||||
|
||||
emitIndexingCompletion(null)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user