From 86010e896e9368d0e0c46e42095c4404ac495e68 Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Wed, 22 Jun 2022 09:05:22 -0600 Subject: [PATCH] music: remove redundant null checks Remove more redundant null checks in MediaStoreBackend. Again, no need to check if there is no issue where they might be null. --- .../auxio/music/backend/MediaStoreBackend.kt | 17 ++++++----------- ...nbounded_ripple.xml => ui_remote_ripple.xml} | 0 .../main/res/drawable/ui_unbounded_ripple.xml | 4 ---- app/src/main/res/layout/view_seek_bar.xml | 4 ++-- app/src/main/res/values-v31/styles_android.xml | 3 +-- 5 files changed, 9 insertions(+), 19 deletions(-) rename app/src/main/res/drawable/{ui_large_unbounded_ripple.xml => ui_remote_ripple.xml} (100%) delete mode 100644 app/src/main/res/drawable/ui_unbounded_ripple.xml diff --git a/app/src/main/java/org/oxycblt/auxio/music/backend/MediaStoreBackend.kt b/app/src/main/java/org/oxycblt/auxio/music/backend/MediaStoreBackend.kt index da11cc99d..376c023f1 100644 --- a/app/src/main/java/org/oxycblt/auxio/music/backend/MediaStoreBackend.kt +++ b/app/src/main/java/org/oxycblt/auxio/music/backend/MediaStoreBackend.kt @@ -276,7 +276,7 @@ abstract class MediaStoreBackend : Indexer.Backend { // to null if they are not present. If this field is , null it so that // it's easier to handle later. audio.artist = - cursor.getStringOrNull(artistIndex)?.run { + cursor.getString(artistIndex).run { if (this != MediaStore.UNKNOWN_STRING) { this } else { @@ -505,20 +505,15 @@ open class VolumeAwareMediaStoreBackend : MediaStoreBackend() { cursor.getColumnIndexOrThrow(MediaStore.Audio.AudioColumns.RELATIVE_PATH) } - val volumeName = cursor.getStringOrNull(volumeIndex) - val relativePath = cursor.getStringOrNull(relativePathIndex) + val volumeName = cursor.getString(volumeIndex) + val relativePath = cursor.getString(relativePathIndex) // We now have access to the volume name, so we try to leverage it instead. // I have no idea how well this works in practice, but I assume that the fields // probably exist. - // TODO: Remove redundant null checks for fields you are pretty sure are not null. - if (volumeName != null && relativePath != null) { - // Iterating through the volume list is cheaper than creating a map, - // interestingly enough. - val volume = volumes.find { it.mediaStoreVolumeNameCompat == volumeName } - if (volume != null) { - audio.dir = Directory(volume, relativePath.removeSuffix(File.separator)) - } + val volume = volumes.find { it.mediaStoreVolumeNameCompat == volumeName } + if (volume != null) { + audio.dir = Directory(volume, relativePath.removeSuffix(File.separator)) } return audio diff --git a/app/src/main/res/drawable/ui_large_unbounded_ripple.xml b/app/src/main/res/drawable/ui_remote_ripple.xml similarity index 100% rename from app/src/main/res/drawable/ui_large_unbounded_ripple.xml rename to app/src/main/res/drawable/ui_remote_ripple.xml diff --git a/app/src/main/res/drawable/ui_unbounded_ripple.xml b/app/src/main/res/drawable/ui_unbounded_ripple.xml deleted file mode 100644 index 0b98cc5db..000000000 --- a/app/src/main/res/drawable/ui_unbounded_ripple.xml +++ /dev/null @@ -1,4 +0,0 @@ - - diff --git a/app/src/main/res/layout/view_seek_bar.xml b/app/src/main/res/layout/view_seek_bar.xml index 53f63a997..cf5f47e3c 100644 --- a/app/src/main/res/layout/view_seek_bar.xml +++ b/app/src/main/res/layout/view_seek_bar.xml @@ -25,7 +25,7 @@ android:layout_gravity="bottom|start" android:layout_marginStart="@dimen/spacing_medium" android:layout_marginBottom="@dimen/spacing_tiny" - android:textAppearance="@style/TextAppearance.Auxio.BodyMedium" + android:textAppearance="@style/TextAppearance.Auxio.LabelMedium" android:textColor="@color/sel_accented_secondary" tools:text="11:38" /> @@ -36,7 +36,7 @@ android:layout_gravity="bottom|end" android:layout_marginEnd="@dimen/spacing_medium" android:layout_marginBottom="@dimen/spacing_tiny" - android:textAppearance="@style/TextAppearance.Auxio.BodyMedium" + android:textAppearance="@style/TextAppearance.Auxio.LabelMedium" android:textColor="?android:attr/textColorSecondary" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toBottomOf="@+id/playback_seek_bar" diff --git a/app/src/main/res/values-v31/styles_android.xml b/app/src/main/res/values-v31/styles_android.xml index b824b1307..03b04c7f0 100644 --- a/app/src/main/res/values-v31/styles_android.xml +++ b/app/src/main/res/values-v31/styles_android.xml @@ -1,7 +1,6 @@ - \ No newline at end of file