Skip to content

Commit

Permalink
Lyric: BackgroundSpeaker: Correctly display it with v2 labels
Browse files Browse the repository at this point in the history
  • Loading branch information
lightsummer233 committed Nov 22, 2024
1 parent 8341758 commit abe8351
Showing 1 changed file with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,8 @@ class FullBottomSheet @JvmOverloads constructor(
val hasMultiSpeaker = lyricList.any {
it.label == LrcUtils.SpeakerLabel.Voice2 || it.label == LrcUtils.SpeakerLabel.Female
}
val currentLyricHasMultiSpeaker = lyric.label == LrcUtils.SpeakerLabel.Voice2 || lyric.label == LrcUtils.SpeakerLabel.Female
val currentLyricIsAnotherSpeaker = lyric.label == LrcUtils.SpeakerLabel.Voice2 || lyric.label == LrcUtils.SpeakerLabel.Female
val lastLyricIsAnotherSpeaker = lyricList.getOrNull(position - 1)?.label == LrcUtils.SpeakerLabel.Voice2 || lyricList.getOrNull(position - 1)?.label == LrcUtils.SpeakerLabel.Female
val currentLyricIsBgSpeaker = lyric.label == LrcUtils.SpeakerLabel.Background

with(holder.lyricCard) {
Expand All @@ -1487,7 +1488,7 @@ class FullBottomSheet @JvmOverloads constructor(
isFocusable = false
isClickable = false
}
lyric.timeStamp?.let { it1 ->
lyric.timeStamp?.let { timestamp ->
setOnClickListener {
performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK)
activity.getPlayer()?.apply {
Expand All @@ -1497,7 +1498,7 @@ class FullBottomSheet @JvmOverloads constructor(
} else {
ignoredPositionAtMost = lyricList.indexOf(lyric)
}
seekTo(it1)
seekTo(timestamp)
if (!isPlaying) play()
}
}
Expand Down Expand Up @@ -1529,7 +1530,7 @@ class FullBottomSheet @JvmOverloads constructor(
with(holder.transitionFrame) {
visibility = VISIBLE
translationY = 0f
pivotX = if (currentLyricHasMultiSpeaker) width / 1f else 0f
pivotX = if (currentLyricIsAnotherSpeaker || (currentLyricIsBgSpeaker && lastLyricIsAnotherSpeaker)) width / 1f else 0f
pivotY = height / 2f
val paddingStart = 12.5f
val paddingEnd = if (hasMultiSpeaker) 66.5f else 12.5f
Expand Down Expand Up @@ -1559,13 +1560,13 @@ class FullBottomSheet @JvmOverloads constructor(
with(holder.lyricFlexboxLayout) {
visibility = if (lyric.content.isNotEmpty()) VISIBLE else GONE
justifyContent =
if (currentLyricHasMultiSpeaker)
if (currentLyricIsAnotherSpeaker || (currentLyricIsBgSpeaker && lastLyricIsAnotherSpeaker))
JustifyContent.FLEX_END
else
JustifyContent.FLEX_START

translationY = 0f
pivotX = if (currentLyricHasMultiSpeaker) width / 1f else 0f
pivotX = if (currentLyricIsAnotherSpeaker || (currentLyricIsBgSpeaker && lastLyricIsAnotherSpeaker)) width / 1f else 0f
pivotY = height / 2f

val paddingTop =
Expand Down

0 comments on commit abe8351

Please sign in to comment.