Added grow animation to LrcView

This commit is contained in:
Prathamesh More 2022-01-04 14:26:22 +05:30
parent 956cce6989
commit 5a5b464057
4 changed files with 23 additions and 12 deletions

View file

@ -88,7 +88,6 @@ static def getDate() {
new Date().format('MMddyyyyss')
}
dependencies {
implementation project(':appthemehelper')
implementation "androidx.gridlayout:gridlayout:1.0.0"

View file

@ -167,7 +167,7 @@ class CoverLrcView @JvmOverloads constructor(
isShowTimeline = false
removeCallbacks(hideTimelineRunnable)
mCurrentLine = centerLine
invalidate()
animateCurrentTextSize()
return true
}
} else {
@ -458,6 +458,7 @@ class CoverLrcView @JvmOverloads constructor(
mCurrentLine = line
if (!isShowTimeline) {
smoothScrollTo(line)
animateCurrentTextSize()
} else {
invalidate()
}
@ -536,6 +537,18 @@ class CoverLrcView @JvmOverloads constructor(
canvas.restore()
}
fun animateCurrentTextSize() {
val currentTextSize = mCurrentTextSize
ValueAnimator.ofFloat(mNormalTextSize, currentTextSize).apply {
addUpdateListener {
mCurrentTextSize = it.animatedValue as Float
invalidate()
}
duration = 300L
start()
}
}
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean {
if (event.action == MotionEvent.ACTION_UP
@ -613,7 +626,7 @@ class CoverLrcView @JvmOverloads constructor(
private fun adjustCenter() {
smoothScrollTo(centerLine, ADJUST_DURATION)
}
/** 滚动到某一行 */
/** 滚动到某一行 */
private fun smoothScrollTo(line: Int, duration: Long = mAnimationDuration) {
val offset = getOffset(line)

View file

@ -25,8 +25,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:fel_edge="top|bottom"
app:fel_size_bottom="80dp"
app:fel_size_top="80dp">
app:fel_size_bottom="100dp"
app:fel_size_top="100dp">
<code.name.monkey.retromusic.lyrics.CoverLrcView
android:id="@+id/lyricsView"