|
|
|
@ -31,6 +31,7 @@ import audio.funkwhale.ffa.utils.CommandBus
@@ -31,6 +31,7 @@ import audio.funkwhale.ffa.utils.CommandBus
|
|
|
|
|
import audio.funkwhale.ffa.utils.maybeLoad |
|
|
|
|
import audio.funkwhale.ffa.utils.maybeNormalizeUrl |
|
|
|
|
import audio.funkwhale.ffa.utils.onViewPager |
|
|
|
|
import com.preference.PowerPreference |
|
|
|
|
import com.squareup.picasso.Picasso |
|
|
|
|
import jp.wasabeef.picasso.transformations.RoundedCornersTransformation |
|
|
|
|
import kotlinx.coroutines.Dispatchers.IO |
|
|
|
@ -125,6 +126,12 @@ class AlbumsFragment : FFAFragment<Album, AlbumsAdapter>() {
@@ -125,6 +126,12 @@ class AlbumsFragment : FFAFragment<Album, AlbumsAdapter>() {
|
|
|
|
|
): View { |
|
|
|
|
_binding = FragmentAlbumsBinding.inflate(inflater) |
|
|
|
|
swiper = binding.swiper |
|
|
|
|
|
|
|
|
|
when (PowerPreference.getDefaultFile().getString("play_order")) { |
|
|
|
|
"in_order" -> binding.play.text = getString(R.string.playback_play) |
|
|
|
|
else -> binding.play.text = getString(R.string.playback_shuffle) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return binding.root |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -147,6 +154,29 @@ class AlbumsFragment : FFAFragment<Album, AlbumsAdapter>() {
@@ -147,6 +154,29 @@ class AlbumsFragment : FFAFragment<Album, AlbumsAdapter>() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
binding.artist.text = artistName |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onResume() { |
|
|
|
|
super.onResume() |
|
|
|
|
|
|
|
|
|
var coverHeight: Float? = null |
|
|
|
|
|
|
|
|
|
binding.scroller.setOnScrollChangeListener { _: View?, _: Int, scrollY: Int, _: Int, _: Int -> |
|
|
|
|
if (coverHeight == null) { |
|
|
|
|
coverHeight = binding.cover.measuredHeight.toFloat() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
binding.cover.translationY = (scrollY / 2).toFloat() |
|
|
|
|
|
|
|
|
|
coverHeight?.let { height -> |
|
|
|
|
binding.cover.alpha = (height - scrollY.toFloat()) / height |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
when (PowerPreference.getDefaultFile().getString("play_order")) { |
|
|
|
|
"in_order" -> binding.play.text = getString(R.string.playback_play) |
|
|
|
|
else -> binding.play.text = getString(R.string.playback_shuffle) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
binding.play.setOnClickListener { |
|
|
|
|
val loader = CircularProgressDrawable(requireContext()).apply { |
|
|
|
@ -160,13 +190,15 @@ class AlbumsFragment : FFAFragment<Album, AlbumsAdapter>() {
@@ -160,13 +190,15 @@ class AlbumsFragment : FFAFragment<Album, AlbumsAdapter>() {
|
|
|
|
|
binding.play.isClickable = false |
|
|
|
|
|
|
|
|
|
lifecycleScope.launch(IO) { |
|
|
|
|
artistTracksRepository.fetch(Repository.Origin.Network.origin) |
|
|
|
|
val tracks = artistTracksRepository.fetch(Repository.Origin.Network.origin) |
|
|
|
|
.map { it.data } |
|
|
|
|
.toList() |
|
|
|
|
.flatten() |
|
|
|
|
.shuffled() |
|
|
|
|
.also { |
|
|
|
|
CommandBus.send(Command.ReplaceQueue(it)) |
|
|
|
|
|
|
|
|
|
when (PowerPreference.getDefaultFile().getString("play_order")) { |
|
|
|
|
"in_order" -> CommandBus.send(Command.ReplaceQueue(tracks)) |
|
|
|
|
else -> CommandBus.send(Command.ReplaceQueue(tracks.shuffled())) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
withContext(Main) { |
|
|
|
|
binding.play.icon = |
|
|
|
@ -176,25 +208,6 @@ class AlbumsFragment : FFAFragment<Album, AlbumsAdapter>() {
@@ -176,25 +208,6 @@ class AlbumsFragment : FFAFragment<Album, AlbumsAdapter>() {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
override fun onResume() { |
|
|
|
|
super.onResume() |
|
|
|
|
|
|
|
|
|
var coverHeight: Float? = null |
|
|
|
|
|
|
|
|
|
binding.scroller.setOnScrollChangeListener { _: View?, _: Int, scrollY: Int, _: Int, _: Int -> |
|
|
|
|
if (coverHeight == null) { |
|
|
|
|
coverHeight = binding.cover.measuredHeight.toFloat() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
binding.cover.translationY = (scrollY / 2).toFloat() |
|
|
|
|
|
|
|
|
|
coverHeight?.let { height -> |
|
|
|
|
binding.cover.alpha = (height - scrollY.toFloat()) / height |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
inner class OnAlbumClickListener : AlbumsAdapter.OnAlbumClickListener { |
|
|
|
|
override fun onClick(view: View?, album: Album) { |
|
|
|
|