all: fix version-specific issues

Fix a few version-specific issues so that I don't make a critical
blunder like I did in 2.4.0.
This commit is contained in:
OxygenCobalt
2022-07-12 12:13:49 -06:00
parent f3aca45690
commit ae00a308fe
4 changed files with 14 additions and 3 deletions
@@ -104,6 +104,11 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
binding.homeToolbar.setOnMenuItemClickListener(this@HomeFragment)
binding.homeIndexingContainer.setOnApplyWindowInsetsListener { v, insets ->
logD("do basics you retard")
insets
}
updateTabConfiguration()
// Load the track color in manually as it's unclear whether the track actually supports
@@ -129,6 +134,11 @@ class HomeFragment : ViewBindingFragment<FragmentHomeBinding>(), Toolbar.OnMenuI
TabLayoutMediator(binding.homeTabs, this, AdaptiveTabStrategy(context, homeModel))
.attach()
// ViewPager2 will nominally consume window insets, which will then break the window
// insets applied to the indexing view before API 30. Fix this by overriding the
// callback with a no-op listener.
setOnApplyWindowInsetsListener { _, insets -> insets }
}
binding.homeFab.setOnClickListener { playbackModel.shuffleAll() }
@@ -69,14 +69,14 @@ val String.plainTrackNo: Int?
* invalid.
*/
val Int.packedTrackNo: Int?
get() = div(1000).nonZeroOrNull()
get() = mod(1000).nonZeroOrNull()
/**
* Parse out the disc number field as if the given Int is formatted as DTTT, where D Is the disc and
* T is the track number. Values of zero will be ignored under the assumption that they are invalid.
*/
val Int.packedDiscNo: Int?
get() = mod(1000).nonZeroOrNull()
get() = div(1000).nonZeroOrNull()
/**
* Parse out the number field from an NN/TT string that is typically found in DISC_NUMBER and
@@ -454,6 +454,7 @@ class Api21MediaStoreBackend : MediaStoreBackend() {
val rawTrack = cursor.getIntOrNull(trackIndex)
if (rawTrack != null) {
logD(rawTrack)
rawTrack.packedTrackNo?.let {
logD(it)
audio.track = it