all: fixes/reformat

This commit is contained in:
Alexander Capehart 2024-06-08 11:57:32 -06:00
parent 248fc89c9b
commit 1c74f05222
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 25 additions and 21 deletions

View file

@ -28,8 +28,6 @@ import dagger.hilt.android.AndroidEntryPoint
import javax.inject.Inject
import org.oxycblt.auxio.music.service.IndexerServiceFragment
import org.oxycblt.auxio.playback.service.MediaSessionServiceFragment
import org.oxycblt.auxio.tasker.indicateServiceRunning
import org.oxycblt.auxio.tasker.indicateServiceStopped
@AndroidEntryPoint
class AuxioService : MediaLibraryService(), ForegroundListener {
@ -42,7 +40,6 @@ class AuxioService : MediaLibraryService(), ForegroundListener {
super.onCreate()
mediaSessionFragment.attach(this, this)
indexingFragment.attach(this)
indicateServiceRunning()
}
override fun onBind(intent: Intent?): IBinder? {
@ -73,7 +70,6 @@ class AuxioService : MediaLibraryService(), ForegroundListener {
override fun onDestroy() {
super.onDestroy()
indicateServiceStopped()
indexingFragment.release()
mediaSessionFragment.release()
}

View file

@ -164,8 +164,10 @@ constructor(
}
val deviceLibrary = musicRepository.deviceLibrary ?: return@launch
val songs = importedPlaylist.paths.mapNotNull {
it.firstNotNullOfOrNull(deviceLibrary::findSongByPath) }
val songs =
importedPlaylist.paths.mapNotNull {
it.firstNotNullOfOrNull(deviceLibrary::findSongByPath)
}
if (songs.isEmpty()) {
logE("No songs found")

View file

@ -122,48 +122,54 @@ class M3UImpl @Inject constructor(@ApplicationContext private val context: Conte
// the same volume as the M3U file. There's no sane way to map the volume
// to the phone's volumes, so this is the only thing we can do.
val absoluteInterpretation = Components.parseUnix(path)
val relativeInterpretation = absoluteInterpretation.absoluteTo(workingDirectory.components)
val relativeInterpretation =
absoluteInterpretation.absoluteTo(workingDirectory.components)
listOf(absoluteInterpretation, relativeInterpretation)
}
path.startsWith("./") -> {
// Unix relative path, resolve it
val absoluteInterpretation = Components.parseUnix(path)
val relativeInterpretation = absoluteInterpretation.absoluteTo(workingDirectory.components)
val relativeInterpretation =
absoluteInterpretation.absoluteTo(workingDirectory.components)
listOf(relativeInterpretation, absoluteInterpretation)
}
path.matches(WINDOWS_VOLUME_PREFIX_REGEX) -> {
// Windows absolute path, we should get rid of the volume prefix, but
// otherwise the rest should be fine. Again, we have to disregard what the
// volume actually is since there's no sane way to map it to the phone's volumes.
// volume actually is since there's no sane way to map it to the phone's
// volumes.
val absoluteInterpretation = Components.parseWindows(path.substring(2))
val relativeInterpretation = absoluteInterpretation.absoluteTo(workingDirectory.components)
val relativeInterpretation =
absoluteInterpretation.absoluteTo(workingDirectory.components)
listOf(absoluteInterpretation, relativeInterpretation)
}
path.startsWith("\\") -> {
// Weird unix/windows hybrid absolute path that appears sometimes
val absoluteInterpretation = Components.parseWindows(path)
val relativeInterpretation = absoluteInterpretation.absoluteTo(workingDirectory.components)
val relativeInterpretation =
absoluteInterpretation.absoluteTo(workingDirectory.components)
listOf(absoluteInterpretation, relativeInterpretation)
}
path.startsWith(".\\") -> {
// Windows-style relative path
val absoluteInterpretation = Components.parseWindows(path)
val relativeInterpretation = absoluteInterpretation.absoluteTo(workingDirectory.components)
val relativeInterpretation =
absoluteInterpretation.absoluteTo(workingDirectory.components)
listOf(relativeInterpretation, absoluteInterpretation)
}
else -> {
// No clue, just go wild and assume all possible combinations.
val unixAbsoluteInterpretation = Components.parseUnix(path)
val unixRelativeInterpretation = unixAbsoluteInterpretation.absoluteTo(workingDirectory.components)
val unixRelativeInterpretation =
unixAbsoluteInterpretation.absoluteTo(workingDirectory.components)
val windowsAbsoluteInterpretation = Components.parseWindows(path)
val windowsRelativeInterpretation = windowsAbsoluteInterpretation.absoluteTo(workingDirectory.components)
listOf(unixRelativeInterpretation, unixAbsoluteInterpretation,
windowsRelativeInterpretation, windowsAbsoluteInterpretation)
val windowsRelativeInterpretation =
windowsAbsoluteInterpretation.absoluteTo(workingDirectory.components)
listOf(
unixRelativeInterpretation,
unixAbsoluteInterpretation,
windowsRelativeInterpretation,
windowsAbsoluteInterpretation)
}
}