Browse Source

Add light animation when scrolling listings.

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
13f3c2d465
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 23
      app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt
  2. 14
      app/src/main/java/com/github/apognu/otter/fragments/PlaylistTracksFragment.kt
  3. 14
      app/src/main/java/com/github/apognu/otter/fragments/TracksFragment.kt

23
app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt

@ -1,14 +1,10 @@ @@ -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 @@ -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>() { @@ -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)

14
app/src/main/java/com/github/apognu/otter/fragments/PlaylistTracksFragment.kt

@ -80,6 +80,20 @@ class PlaylistTracksFragment : FunkwhaleFragment<PlaylistTrack, PlaylistTracksAd @@ -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()))

14
app/src/main/java/com/github/apognu/otter/fragments/TracksFragment.kt

@ -92,6 +92,20 @@ class TracksFragment : FunkwhaleFragment<Track, TracksAdapter>() { @@ -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…
Cancel
Save