home: distinguish no popup value from no popup

Do not show the popup if there is no provider or valid position.

Might be useful for later.
This commit is contained in:
Alexander Capehart 2022-08-27 20:03:41 -06:00
parent 4622235b5e
commit ab59ca02fd
No known key found for this signature in database
GPG key ID: 37DBE3621FE9AD47
3 changed files with 13 additions and 9 deletions

View file

@ -22,6 +22,7 @@ buttons
- Fixed issue where LG phones would not show metadata in the notification
- Fixed issue where the transition would be wrong when navigating out of the
detail views after a rotation
- Fixed issue where widget resizing would be far different than intended
#### What's Changed
- ReplayGain can now no longer be disabled. Remove ReplayGain tags from

View file

@ -29,6 +29,7 @@ import android.view.ViewGroup
import android.view.WindowInsets
import android.widget.FrameLayout
import androidx.annotation.AttrRes
import androidx.core.view.isInvisible
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
@ -207,15 +208,17 @@ constructor(context: Context, attrs: AttributeSet? = null, @AttrRes defStyleAttr
thumbView.layout(thumbLeft, thumbTop, thumbLeft + thumbWidth, thumbTop + thumbHeight)
// Get the popup text. If there is none, we default to "?".
val firstPos = firstAdapterPos
val popupText =
if (firstPos != NO_POSITION) {
popupProvider?.getPopup(firstPos)?.ifEmpty { null }
} else {
null
}
?: "?"
val popupText: String
val provider = popupProvider
if (firstPos != NO_POSITION && provider != null) {
// Get the popup text. If there is none, we default to "?".
popupText = provider.getPopup(firstPos) ?: "?"
} else {
// No valid position or provider, do not show the popup.
popupView.isInvisible = true
popupText = ""
}
val popupLayoutParams = popupView.layoutParams as FrameLayout.LayoutParams

View file

@ -6,5 +6,5 @@
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="m 11.999925,3.749925 c 0,0 1.6e-4,8.17593 0,8.50025 -1.6e-4,0.32431 -0.128,0.67073 -0.46296,0.75 h -0.75 -1.57365 c -0.48021,0 -0.94076,0.19077 -1.28032,0.53034 l -1.40228,1.40234 c -0.33957,0.33957 -0.53033,0.80012 -0.53033,1.28034 v 0.0219 l -4.1e-4,0.76519 4.1e-4,0.0152 v 0.77149 c 0,0.48022 0.19076,0.94078 0.53033,1.28035 l 1.40228,1.40234 c 0.33956,0.33957 0.8001,0.53034 1.28032,0.53034 h 1.57365 c 0.48022,0 0.94077,-0.19077 1.28033,-0.53034 l 1.40228,-1.40234 c 0.33956,-0.33957 0.53032,-0.80013 0.53032,-1.28035 v -0.0215 l 3.8e-4,-0.76519 v -9.25004 c 0,-0.41422 0.33578,-0.75 0.75,-0.75 h 2.49975 c 0.41421,0 0.75,-0.33579 0.75,-0.75001 v -2.4999 c 0,-0.41422 -0.33578,-0.75003 -0.75,-0.75005 l -4.5001,-2.9e-4 c -0.4142,-3e-5 -0.75,0.33575 -0.75,0.74995 z" />
android:pathData="m 11.999925,3.749925 c 0,0 0.0001600,8.17593 0,8.50025 -0.0001600,0.32431 -0.128,0.67073 -0.46296,0.75 h -0.75 -1.57365 c -0.48021,0 -0.94076,0.19077 -1.28032,0.53034 l -1.40228,1.40234 c -0.33957,0.33957 -0.53033,0.80012 -0.53033,1.28034 v 0.0219 l -0.0004100,0.76519 0.0004100,0.0152 v 0.77149 c 0,0.48022 0.19076,0.94078 0.53033,1.28035 l 1.40228,1.40234 c 0.33956,0.33957 0.8001,0.53034 1.28032,0.53034 h 1.57365 c 0.48022,0 0.94077,-0.19077 1.28033,-0.53034 l 1.40228,-1.40234 c 0.33956,-0.33957 0.53032,-0.80013 0.53032,-1.28035 v -0.0215 l 0.0003800,-0.76519 v -9.25004 c 0,-0.41422 0.33578,-0.75 0.75,-0.75 h 2.49975 c 0.41421,0 0.75,-0.33579 0.75,-0.75001 v -2.4999 c 0,-0.41422 -0.33578,-0.75003 -0.75,-0.75005 l -4.5001,-0.0002900 c -0.4142,-0.0000300 -0.75,0.33575 -0.75,0.74995 z" />
</vector>