music: dont inject contentresolver
I don't know why, but I can't inject it without causing errors.
This commit is contained in:
parent
e553744c8e
commit
2195431c66
2 changed files with 9 additions and 3 deletions
|
@ -18,12 +18,13 @@
|
||||||
|
|
||||||
package org.oxycblt.auxio.music.external
|
package org.oxycblt.auxio.music.external
|
||||||
|
|
||||||
import android.content.ContentResolver
|
import android.content.Context
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import dagger.hilt.android.qualifiers.ApplicationContext
|
import dagger.hilt.android.qualifiers.ApplicationContext
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import org.oxycblt.auxio.music.fs.ContentPathResolver
|
import org.oxycblt.auxio.music.fs.ContentPathResolver
|
||||||
import org.oxycblt.auxio.music.fs.Path
|
import org.oxycblt.auxio.music.fs.Path
|
||||||
|
import org.oxycblt.auxio.music.fs.contentResolverSafe
|
||||||
|
|
||||||
interface PlaylistImporter {
|
interface PlaylistImporter {
|
||||||
suspend fun import(uri: Uri): ImportedPlaylist?
|
suspend fun import(uri: Uri): ImportedPlaylist?
|
||||||
|
@ -34,13 +35,13 @@ data class ImportedPlaylist(val name: String?, val paths: List<Path>)
|
||||||
class PlaylistImporterImpl
|
class PlaylistImporterImpl
|
||||||
@Inject
|
@Inject
|
||||||
constructor(
|
constructor(
|
||||||
@ApplicationContext private val contentResolver: ContentResolver,
|
@ApplicationContext private val context: Context,
|
||||||
private val contentPathResolver: ContentPathResolver,
|
private val contentPathResolver: ContentPathResolver,
|
||||||
private val m3u: M3U
|
private val m3u: M3U
|
||||||
) : PlaylistImporter {
|
) : PlaylistImporter {
|
||||||
override suspend fun import(uri: Uri): ImportedPlaylist? {
|
override suspend fun import(uri: Uri): ImportedPlaylist? {
|
||||||
val workingDirectory = contentPathResolver.resolve(uri) ?: return null
|
val workingDirectory = contentPathResolver.resolve(uri) ?: return null
|
||||||
return contentResolver.openInputStream(uri)?.use {
|
return context.contentResolverSafe.openInputStream(uri)?.use {
|
||||||
val paths = m3u.read(it, workingDirectory) ?: return null
|
val paths = m3u.read(it, workingDirectory) ?: return null
|
||||||
return ImportedPlaylist(null, paths)
|
return ImportedPlaylist(null, paths)
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
package org.oxycblt.auxio.music.fs
|
package org.oxycblt.auxio.music.fs
|
||||||
|
|
||||||
|
import android.content.ContentResolver
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.storage.StorageManager
|
import android.os.storage.StorageManager
|
||||||
import dagger.Module
|
import dagger.Module
|
||||||
|
@ -41,4 +42,8 @@ class FsModule {
|
||||||
@Provides
|
@Provides
|
||||||
fun contentPathResolver(@ApplicationContext context: Context, volumeManager: VolumeManager) =
|
fun contentPathResolver(@ApplicationContext context: Context, volumeManager: VolumeManager) =
|
||||||
ContentPathResolver.from(context, volumeManager)
|
ContentPathResolver.from(context, volumeManager)
|
||||||
|
|
||||||
|
@Provides
|
||||||
|
fun contentResolver(@ApplicationContext context: Context): ContentResolver =
|
||||||
|
context.contentResolverSafe
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue