Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
funkwhale
Funkwhale Android
Commits
a6b1730c
Commit
a6b1730c
authored
Apr 22, 2022
by
Ryan Harg
Committed by
Ryan Harg
Apr 22, 2022
Browse files
#116
: Fix playback order to respect preference setting on albums fragment
parent
2996c85f
Pipeline
#20361
passed with stages
in 17 minutes and 51 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/audio/funkwhale/ffa/fragments/AlbumsFragment.kt
View file @
a6b1730c
...
...
@@ -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>() {
):
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>() {
}
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,38 +190,21 @@ 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
))
withContext
(
Main
)
{
binding
.
play
.
icon
=
AppCompatResources
.
getDrawable
(
binding
.
root
.
context
,
R
.
drawable
.
play
)
binding
.
play
.
isClickable
=
true
}
}
}
}
}
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
()
when
(
PowerPreference
.
getDefaultFile
().
getString
(
"play_order"
))
{
"in_order"
->
CommandBus
.
send
(
Command
.
ReplaceQueue
(
tracks
))
else
->
CommandBus
.
send
(
Command
.
ReplaceQueue
(
tracks
.
shuffled
()))
}
coverHeight
?.
let
{
height
->
binding
.
cover
.
alpha
=
(
height
-
scrollY
.
toFloat
())
/
height
withContext
(
Main
)
{
binding
.
play
.
icon
=
AppCompatResources
.
getDrawable
(
binding
.
root
.
context
,
R
.
drawable
.
play
)
binding
.
play
.
isClickable
=
true
}
}
}
}
...
...
app/src/main/java/audio/funkwhale/ffa/fragments/TracksFragment.kt
View file @
a6b1730c
...
...
@@ -129,6 +129,12 @@ class TracksFragment : FFAFragment<Track, TracksAdapter>() {
):
View
{
_binding
=
FragmentTracksBinding
.
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
}
...
...
changes/changelog.d/116.bugfix
0 → 100644
View file @
a6b1730c
Fix playback order to respect preference setting on albums fragment
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment