Add light animation when scrolling listings.
This commit is contained in:
parent
098048ac49
commit
13f3c2d465
|
@ -1,14 +1,10 @@
|
|||
package com.github.apognu.otter.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.os.Bundle
|
||||
import android.util.DisplayMetrics
|
||||
import android.view.Gravity
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.graphics.drawable.toDrawable
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
|
@ -25,7 +21,6 @@ import com.github.apognu.otter.views.LoadingFlotingActionButton
|
|||
import com.squareup.picasso.Picasso
|
||||
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation
|
||||
import kotlinx.android.synthetic.main.fragment_albums.*
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
|
@ -139,6 +134,24 @@ class AlbumsFragment : FunkwhaleFragment<Album, AlbumsAdapter>() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
var coverHeight: Float? = null
|
||||
|
||||
scroller.setOnScrollChangeListener { _: View?, _: Int, scrollY: Int, _: Int, _: Int ->
|
||||
if (coverHeight == null) {
|
||||
coverHeight = cover.measuredHeight.toFloat()
|
||||
}
|
||||
|
||||
cover.translationY = (scrollY / 2).toFloat()
|
||||
|
||||
coverHeight?.let { height ->
|
||||
cover.alpha = (height - scrollY.toFloat()) / height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inner class OnAlbumClickListener : AlbumsAdapter.OnAlbumClickListener {
|
||||
override fun onClick(view: View?, album: Album) {
|
||||
openTracks(context, album, fragment = this@AlbumsFragment)
|
||||
|
|
|
@ -80,6 +80,20 @@ class PlaylistTracksFragment : FunkwhaleFragment<PlaylistTrack, PlaylistTracksAd
|
|||
}
|
||||
}
|
||||
|
||||
var coverHeight: Float? = null
|
||||
|
||||
scroller.setOnScrollChangeListener { _: View?, _: Int, scrollY: Int, _: Int, _: Int ->
|
||||
if (coverHeight == null) {
|
||||
coverHeight = covers.measuredHeight.toFloat()
|
||||
}
|
||||
|
||||
covers.translationY = (scrollY / 2).toFloat()
|
||||
|
||||
coverHeight?.let { height ->
|
||||
covers.alpha = (height - scrollY.toFloat()) / height
|
||||
}
|
||||
}
|
||||
|
||||
play.setOnClickListener {
|
||||
CommandBus.send(Command.ReplaceQueue(adapter.data.map { it.track }.shuffled()))
|
||||
|
||||
|
|
|
@ -92,6 +92,20 @@ class TracksFragment : FunkwhaleFragment<Track, TracksAdapter>() {
|
|||
refreshDownloadedTracks()
|
||||
}
|
||||
|
||||
var coverHeight: Float? = null
|
||||
|
||||
scroller.setOnScrollChangeListener { _: View?, _: Int, scrollY: Int, _: Int, _: Int ->
|
||||
if (coverHeight == null) {
|
||||
coverHeight = cover.measuredHeight.toFloat()
|
||||
}
|
||||
|
||||
cover.translationY = (scrollY / 2).toFloat()
|
||||
|
||||
coverHeight?.let { height ->
|
||||
cover.alpha = (height - scrollY.toFloat()) / height
|
||||
}
|
||||
}
|
||||
|
||||
play.setOnClickListener {
|
||||
CommandBus.send(Command.ReplaceQueue(adapter.data.shuffled()))
|
||||
|
||||
|
|
Loading…
Reference in New Issue