Merge pull request #1058 from OxygenCobalt/dev
v4.0.3 (with FSCovers fix)
This commit is contained in:
commit
2e212af77b
1 changed files with 3 additions and 6 deletions
|
@ -24,7 +24,6 @@ import android.net.Uri
|
||||||
import android.os.ParcelFileDescriptor
|
import android.os.ParcelFileDescriptor
|
||||||
import androidx.core.net.toUri
|
import androidx.core.net.toUri
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import kotlin.math.max
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import org.oxycblt.musikr.covers.Cover
|
import org.oxycblt.musikr.covers.Cover
|
||||||
|
@ -101,7 +100,7 @@ class MutableFSCovers(private val context: Context) : MutableCovers<FDCover> {
|
||||||
val bestCover =
|
val bestCover =
|
||||||
parent.children
|
parent.children
|
||||||
.filterIsInstance<DeviceFile>()
|
.filterIsInstance<DeviceFile>()
|
||||||
.map { it to coverArtScore(file) }
|
.map { it to coverArtScore(it) }
|
||||||
.maxBy { it.second }
|
.maxBy { it.second }
|
||||||
if (bestCover.second > 0) {
|
if (bestCover.second > 0) {
|
||||||
return CoverResult.Hit(FolderCoverImpl(context, bestCover.first.uri))
|
return CoverResult.Hit(FolderCoverImpl(context, bestCover.first.uri))
|
||||||
|
@ -135,10 +134,8 @@ class MutableFSCovers(private val context: Context) : MutableCovers<FDCover> {
|
||||||
.sumOf { it.index + 1 }
|
.sumOf { it.index + 1 }
|
||||||
// Multiply the score for preferred formats & extensions. Weirder formats are harder for
|
// Multiply the score for preferred formats & extensions. Weirder formats are harder for
|
||||||
// android to decode, but not the end of the world.
|
// android to decode, but not the end of the world.
|
||||||
score *=
|
score *= preferredFormats.indexOfFirst { file.mimeType.equals(it, ignoreCase = true) } + 2
|
||||||
max(preferredFormats.indexOfFirst { file.mimeType.equals(it, ignoreCase = true) }, 0)
|
score *= preferredExtensions.indexOfFirst { extension.equals(it, ignoreCase = true) } + 2
|
||||||
score *=
|
|
||||||
max(preferredExtensions.indexOfFirst { extension.equals(it, ignoreCase = true) }, 0)
|
|
||||||
return score
|
return score
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue