musikr: move storage/interpretation dependence to construction

This makes some testing and certain code more ergonomic.
This commit is contained in:
Alexander Capehart
2024-12-17 11:45:04 -05:00
parent f3913b148a
commit bdfd9d6e23
11 changed files with 87 additions and 81 deletions
@@ -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)