Code refactor, fix animations on Album and Artist details
This commit is contained in:
parent
31a0ddd731
commit
c23c56649e
8 changed files with 205 additions and 114 deletions
|
@ -148,7 +148,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
miniPlayerFragment?.view?.alpha = alpha
|
||||
miniPlayerFragment?.view?.visibility = if (alpha == 0f) View.GONE else View.VISIBLE
|
||||
bottomNavigationView.translationY = progress * 500
|
||||
bottomNavigationView.alpha = alpha
|
||||
//bottomNavigationView.alpha = alpha
|
||||
}
|
||||
|
||||
open fun onPanelCollapsed() {
|
||||
|
@ -207,8 +207,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
|
||||
override fun onQueueChanged() {
|
||||
super.onQueueChanged()
|
||||
val isEmpty = MusicPlayerRemote.playingQueue.isEmpty()
|
||||
if (isEmpty) {
|
||||
if (MusicPlayerRemote.playingQueue.isEmpty()) {
|
||||
libraryViewModel.setPanelState(HIDE)
|
||||
} else {
|
||||
if (bottomNavigationView.isVisible) {
|
||||
|
@ -229,6 +228,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
collapsePanel()
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -323,17 +323,20 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
val isQueueEmpty = MusicPlayerRemote.playingQueue.isEmpty()
|
||||
when (state) {
|
||||
EXPAND -> {
|
||||
println("EXPAND")
|
||||
expandPanel()
|
||||
}
|
||||
HIDE -> {
|
||||
ViewCompat.setElevation(slidingPanel, 0f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
println("HIDE")
|
||||
bottomNavigationView.translateXAnimate(0f)
|
||||
bottomSheetBehavior.isHideable = true
|
||||
bottomSheetBehavior.peekHeightAnimate(0)
|
||||
bottomNavigationView.translateXAnimate(0f)
|
||||
bottomSheetBehavior.state = STATE_COLLAPSED
|
||||
ViewCompat.setElevation(slidingPanel, 0f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
}
|
||||
COLLAPSED_WITH -> {
|
||||
println("COLLAPSED_WITH")
|
||||
val heightOfBar = bottomNavigationView.height
|
||||
val height = if (isQueueEmpty) 0 else (heightOfBar * 2) - 24
|
||||
ViewCompat.setElevation(bottomNavigationView, 20f)
|
||||
|
@ -343,6 +346,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
bottomNavigationView.translateXAnimate(0f)
|
||||
}
|
||||
COLLAPSED_WITHOUT -> {
|
||||
println("COLLAPSED_WITHOUT")
|
||||
val heightOfBar = bottomNavigationView.height
|
||||
val height = if (isQueueEmpty) 0 else heightOfBar - 24
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
|
@ -352,6 +356,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
bottomNavigationView.translateXAnimate(150f)
|
||||
}
|
||||
else -> {
|
||||
println("else")
|
||||
bottomSheetBehavior.isHideable = true
|
||||
bottomSheetBehavior.peekHeight = 0
|
||||
collapsePanel()
|
||||
|
|
|
@ -10,7 +10,6 @@ import androidx.core.text.HtmlCompat
|
|||
import androidx.core.view.ViewCompat
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.navigation.fragment.FragmentNavigatorExtras
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
|
@ -31,6 +30,7 @@ import code.name.monkey.retromusic.dialogs.AddToPlaylistDialog
|
|||
import code.name.monkey.retromusic.dialogs.DeleteSongsDialog
|
||||
import code.name.monkey.retromusic.extensions.applyColor
|
||||
import code.name.monkey.retromusic.extensions.applyOutlineColor
|
||||
import code.name.monkey.retromusic.extensions.findActivityNavController
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.glide.AlbumGlideRequest
|
||||
|
@ -106,11 +106,14 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
})
|
||||
|
||||
setupRecyclerView()
|
||||
artistImage.setOnClickListener {
|
||||
requireActivity().findNavController(R.id.fragment_container)
|
||||
artistImage.setOnClickListener { artistView ->
|
||||
ViewCompat.setTransitionName(artistView, "artist")
|
||||
findActivityNavController(R.id.fragment_container)
|
||||
.navigate(
|
||||
R.id.artistDetailsFragment,
|
||||
bundleOf(EXTRA_ARTIST_ID to album.artistId)
|
||||
bundleOf(EXTRA_ARTIST_ID to album.artistId),
|
||||
null,
|
||||
FragmentNavigatorExtras(artistView to "artist")
|
||||
)
|
||||
}
|
||||
playAction.setOnClickListener { MusicPlayerRemote.openQueue(album.songs, 0, true) }
|
||||
|
|
|
@ -10,17 +10,21 @@ import androidx.recyclerview.widget.GridLayoutManager
|
|||
import code.name.monkey.retromusic.EXTRA_ALBUM_ID
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.album.AlbumAdapter
|
||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||
import code.name.monkey.retromusic.fragments.ReloadType
|
||||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
|
||||
import code.name.monkey.retromusic.helper.SortOrder
|
||||
import code.name.monkey.retromusic.helper.SortOrder.AlbumSortOrder
|
||||
import code.name.monkey.retromusic.interfaces.IAlbumClickListener
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
|
||||
|
||||
class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridLayoutManager>(),
|
||||
IAlbumClickListener {
|
||||
IAlbumClickListener, ICabHolder {
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
|
@ -45,7 +49,7 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
|
|||
requireActivity(),
|
||||
dataSet,
|
||||
itemLayoutRes(),
|
||||
null,
|
||||
this,
|
||||
this
|
||||
)
|
||||
}
|
||||
|
@ -225,15 +229,14 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
|
|||
private fun handleSortOrderMenuItem(
|
||||
item: MenuItem
|
||||
): Boolean {
|
||||
var sortOrder: String? = null
|
||||
|
||||
when (item.itemId) {
|
||||
R.id.action_album_sort_order_asc -> sortOrder = AlbumSortOrder.ALBUM_A_Z
|
||||
R.id.action_album_sort_order_desc -> sortOrder = AlbumSortOrder.ALBUM_Z_A
|
||||
R.id.action_album_sort_order_artist -> sortOrder = AlbumSortOrder.ALBUM_ARTIST
|
||||
R.id.action_album_sort_order_year -> sortOrder = AlbumSortOrder.ALBUM_YEAR
|
||||
val sortOrder: String = when (item.itemId) {
|
||||
R.id.action_album_sort_order_asc -> AlbumSortOrder.ALBUM_A_Z
|
||||
R.id.action_album_sort_order_desc -> AlbumSortOrder.ALBUM_Z_A
|
||||
R.id.action_album_sort_order_artist -> AlbumSortOrder.ALBUM_ARTIST
|
||||
R.id.action_album_sort_order_year -> AlbumSortOrder.ALBUM_YEAR
|
||||
else -> PreferenceUtil.albumSortOrder
|
||||
}
|
||||
if (sortOrder != null) {
|
||||
if (sortOrder != PreferenceUtil.albumSortOrder) {
|
||||
item.isChecked = true
|
||||
setAndSaveSortOrder(sortOrder)
|
||||
return true
|
||||
|
@ -244,16 +247,16 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
|
|||
private fun handleLayoutResType(
|
||||
item: MenuItem
|
||||
): Boolean {
|
||||
var layoutRes = -1
|
||||
when (item.itemId) {
|
||||
R.id.action_layout_normal -> layoutRes = R.layout.item_grid
|
||||
R.id.action_layout_card -> layoutRes = R.layout.item_card
|
||||
R.id.action_layout_colored_card -> layoutRes = R.layout.item_card_color
|
||||
R.id.action_layout_circular -> layoutRes = R.layout.item_grid_circle
|
||||
R.id.action_layout_image -> layoutRes = R.layout.image
|
||||
R.id.action_layout_gradient_image -> layoutRes = R.layout.item_image_gradient
|
||||
val layoutRes = when (item.itemId) {
|
||||
R.id.action_layout_normal -> R.layout.item_grid
|
||||
R.id.action_layout_card -> R.layout.item_card
|
||||
R.id.action_layout_colored_card -> R.layout.item_card_color
|
||||
R.id.action_layout_circular -> R.layout.item_grid_circle
|
||||
R.id.action_layout_image -> R.layout.image
|
||||
R.id.action_layout_gradient_image -> R.layout.item_image_gradient
|
||||
else -> PreferenceUtil.albumGridStyle
|
||||
}
|
||||
if (layoutRes != -1) {
|
||||
if (layoutRes != PreferenceUtil.albumGridStyle) {
|
||||
item.isChecked = true
|
||||
setAndSaveLayoutRes(layoutRes)
|
||||
return true
|
||||
|
@ -264,16 +267,16 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
|
|||
private fun handleGridSizeMenuItem(
|
||||
item: MenuItem
|
||||
): Boolean {
|
||||
var gridSize = 0
|
||||
when (item.itemId) {
|
||||
R.id.action_grid_size_1 -> gridSize = 1
|
||||
R.id.action_grid_size_2 -> gridSize = 2
|
||||
R.id.action_grid_size_3 -> gridSize = 3
|
||||
R.id.action_grid_size_4 -> gridSize = 4
|
||||
R.id.action_grid_size_5 -> gridSize = 5
|
||||
R.id.action_grid_size_6 -> gridSize = 6
|
||||
R.id.action_grid_size_7 -> gridSize = 7
|
||||
R.id.action_grid_size_8 -> gridSize = 8
|
||||
val gridSize = when (item.itemId) {
|
||||
R.id.action_grid_size_1 -> 1
|
||||
R.id.action_grid_size_2 -> 2
|
||||
R.id.action_grid_size_3 -> 3
|
||||
R.id.action_grid_size_4 -> 4
|
||||
R.id.action_grid_size_5 -> 5
|
||||
R.id.action_grid_size_6 -> 6
|
||||
R.id.action_grid_size_7 -> 7
|
||||
R.id.action_grid_size_8 -> 8
|
||||
else -> 0
|
||||
}
|
||||
if (gridSize > 0) {
|
||||
item.isChecked = true
|
||||
|
@ -283,4 +286,30 @@ class AlbumsFragment : AbsRecyclerViewCustomGridSizeFragment<AlbumAdapter, GridL
|
|||
return false
|
||||
}
|
||||
|
||||
private var cab: MaterialCab? = null
|
||||
|
||||
fun handleBackPress(): Boolean {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
cab?.let {
|
||||
println("Cab")
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
}
|
||||
}
|
||||
cab = MaterialCab(mainActivity, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
.start(callback)
|
||||
return cab as MaterialCab
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,16 +10,20 @@ import androidx.recyclerview.widget.GridLayoutManager
|
|||
import code.name.monkey.retromusic.EXTRA_ARTIST_ID
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.artist.ArtistAdapter
|
||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||
import code.name.monkey.retromusic.fragments.ReloadType
|
||||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
|
||||
import code.name.monkey.retromusic.helper.SortOrder.ArtistSortOrder
|
||||
import code.name.monkey.retromusic.interfaces.IArtistClickListener
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
|
||||
|
||||
class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, GridLayoutManager>(),
|
||||
IArtistClickListener {
|
||||
IArtistClickListener, ICabHolder {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
libraryViewModel.getArtists().observe(viewLifecycleOwner, Observer {
|
||||
|
@ -47,7 +51,7 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
|
|||
requireActivity(),
|
||||
dataSet,
|
||||
itemLayoutRes(),
|
||||
null,
|
||||
this,
|
||||
this
|
||||
)
|
||||
}
|
||||
|
@ -205,13 +209,12 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
|
|||
private fun handleSortOrderMenuItem(
|
||||
item: MenuItem
|
||||
): Boolean {
|
||||
var sortOrder: String? = null
|
||||
|
||||
when (item.itemId) {
|
||||
R.id.action_artist_sort_order_asc -> sortOrder = ArtistSortOrder.ARTIST_A_Z
|
||||
R.id.action_artist_sort_order_desc -> sortOrder = ArtistSortOrder.ARTIST_Z_A
|
||||
val sortOrder: String = when (item.itemId) {
|
||||
R.id.action_artist_sort_order_asc -> ArtistSortOrder.ARTIST_A_Z
|
||||
R.id.action_artist_sort_order_desc -> ArtistSortOrder.ARTIST_Z_A
|
||||
else -> PreferenceUtil.artistSortOrder
|
||||
}
|
||||
if (sortOrder != null) {
|
||||
if (sortOrder != PreferenceUtil.artistSortOrder) {
|
||||
item.isChecked = true
|
||||
setAndSaveSortOrder(sortOrder)
|
||||
return true
|
||||
|
@ -222,16 +225,16 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
|
|||
private fun handleLayoutResType(
|
||||
item: MenuItem
|
||||
): Boolean {
|
||||
var layoutRes = -1
|
||||
when (item.itemId) {
|
||||
R.id.action_layout_normal -> layoutRes = R.layout.item_grid
|
||||
R.id.action_layout_card -> layoutRes = R.layout.item_card
|
||||
R.id.action_layout_colored_card -> layoutRes = R.layout.item_card_color
|
||||
R.id.action_layout_circular -> layoutRes = R.layout.item_grid_circle
|
||||
R.id.action_layout_image -> layoutRes = R.layout.image
|
||||
R.id.action_layout_gradient_image -> layoutRes = R.layout.item_image_gradient
|
||||
val layoutRes = when (item.itemId) {
|
||||
R.id.action_layout_normal -> R.layout.item_grid
|
||||
R.id.action_layout_card -> R.layout.item_card
|
||||
R.id.action_layout_colored_card -> R.layout.item_card_color
|
||||
R.id.action_layout_circular -> R.layout.item_grid_circle
|
||||
R.id.action_layout_image -> R.layout.image
|
||||
R.id.action_layout_gradient_image -> R.layout.item_image_gradient
|
||||
else -> PreferenceUtil.artistGridStyle
|
||||
}
|
||||
if (layoutRes != -1) {
|
||||
if (layoutRes != PreferenceUtil.artistGridStyle) {
|
||||
item.isChecked = true
|
||||
setAndSaveLayoutRes(layoutRes)
|
||||
return true
|
||||
|
@ -242,16 +245,16 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
|
|||
private fun handleGridSizeMenuItem(
|
||||
item: MenuItem
|
||||
): Boolean {
|
||||
var gridSize = 0
|
||||
when (item.itemId) {
|
||||
R.id.action_grid_size_1 -> gridSize = 1
|
||||
R.id.action_grid_size_2 -> gridSize = 2
|
||||
R.id.action_grid_size_3 -> gridSize = 3
|
||||
R.id.action_grid_size_4 -> gridSize = 4
|
||||
R.id.action_grid_size_5 -> gridSize = 5
|
||||
R.id.action_grid_size_6 -> gridSize = 6
|
||||
R.id.action_grid_size_7 -> gridSize = 7
|
||||
R.id.action_grid_size_8 -> gridSize = 8
|
||||
val gridSize = when (item.itemId) {
|
||||
R.id.action_grid_size_1 -> 1
|
||||
R.id.action_grid_size_2 -> 2
|
||||
R.id.action_grid_size_3 -> 3
|
||||
R.id.action_grid_size_4 -> 4
|
||||
R.id.action_grid_size_5 -> 5
|
||||
R.id.action_grid_size_6 -> 6
|
||||
R.id.action_grid_size_7 -> 7
|
||||
R.id.action_grid_size_8 -> 8
|
||||
else -> 0
|
||||
}
|
||||
if (gridSize > 0) {
|
||||
item.isChecked = true
|
||||
|
@ -260,4 +263,30 @@ class ArtistsFragment : AbsRecyclerViewCustomGridSizeFragment<ArtistAdapter, Gri
|
|||
}
|
||||
return false
|
||||
}
|
||||
private var cab: MaterialCab? = null
|
||||
|
||||
fun handleBackPress(): Boolean {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
cab?.let {
|
||||
println("Cab")
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
}
|
||||
}
|
||||
cab = MaterialCab(mainActivity, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
.start(callback)
|
||||
return cab as MaterialCab
|
||||
}
|
||||
}
|
|
@ -7,14 +7,19 @@ import androidx.lifecycle.Observer
|
|||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.song.SongAdapter
|
||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||
import code.name.monkey.retromusic.fragments.ReloadType
|
||||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewCustomGridSizeFragment
|
||||
import code.name.monkey.retromusic.helper.SortOrder.SongSortOrder
|
||||
import code.name.monkey.retromusic.interfaces.ICabHolder
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroColorUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import com.afollestad.materialcab.MaterialCab
|
||||
|
||||
|
||||
class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>() {
|
||||
class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLayoutManager>(),
|
||||
ICabHolder {
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
libraryViewModel.getSongs().observe(viewLifecycleOwner, Observer {
|
||||
|
@ -38,7 +43,7 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
|
|||
requireActivity(),
|
||||
dataSet,
|
||||
itemLayoutRes(),
|
||||
null
|
||||
this
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -227,20 +232,18 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
|
|||
private fun handleSortOrderMenuItem(
|
||||
item: MenuItem
|
||||
): Boolean {
|
||||
var sortOrder: String? = null
|
||||
|
||||
when (item.itemId) {
|
||||
R.id.action_song_sort_order_asc -> sortOrder = SongSortOrder.SONG_A_Z
|
||||
R.id.action_song_sort_order_desc -> sortOrder = SongSortOrder.SONG_Z_A
|
||||
R.id.action_song_sort_order_artist -> sortOrder = SongSortOrder.SONG_ARTIST
|
||||
R.id.action_song_sort_order_album -> sortOrder = SongSortOrder.SONG_ALBUM
|
||||
R.id.action_song_sort_order_year -> sortOrder = SongSortOrder.SONG_YEAR
|
||||
R.id.action_song_sort_order_date -> sortOrder = SongSortOrder.SONG_DATE
|
||||
R.id.action_song_sort_order_composer -> sortOrder = SongSortOrder.COMPOSER
|
||||
R.id.action_song_sort_order_date_modified -> sortOrder =
|
||||
SongSortOrder.SONG_DATE_MODIFIED
|
||||
val sortOrder: String = when (item.itemId) {
|
||||
R.id.action_song_sort_order_asc -> SongSortOrder.SONG_A_Z
|
||||
R.id.action_song_sort_order_desc -> SongSortOrder.SONG_Z_A
|
||||
R.id.action_song_sort_order_artist -> SongSortOrder.SONG_ARTIST
|
||||
R.id.action_song_sort_order_album -> SongSortOrder.SONG_ALBUM
|
||||
R.id.action_song_sort_order_year -> SongSortOrder.SONG_YEAR
|
||||
R.id.action_song_sort_order_date -> SongSortOrder.SONG_DATE
|
||||
R.id.action_song_sort_order_composer -> SongSortOrder.COMPOSER
|
||||
R.id.action_song_sort_order_date_modified -> SongSortOrder.SONG_DATE_MODIFIED
|
||||
else -> PreferenceUtil.songSortOrder
|
||||
}
|
||||
if (sortOrder != null) {
|
||||
if (sortOrder != PreferenceUtil.songSortOrder) {
|
||||
item.isChecked = true
|
||||
setAndSaveSortOrder(sortOrder)
|
||||
return true
|
||||
|
@ -251,16 +254,16 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
|
|||
private fun handleLayoutResType(
|
||||
item: MenuItem
|
||||
): Boolean {
|
||||
var layoutRes = -1
|
||||
when (item.itemId) {
|
||||
R.id.action_layout_normal -> layoutRes = R.layout.item_grid
|
||||
R.id.action_layout_card -> layoutRes = R.layout.item_card
|
||||
R.id.action_layout_colored_card -> layoutRes = R.layout.item_card_color
|
||||
R.id.action_layout_circular -> layoutRes = R.layout.item_grid_circle
|
||||
R.id.action_layout_image -> layoutRes = R.layout.image
|
||||
R.id.action_layout_gradient_image -> layoutRes = R.layout.item_image_gradient
|
||||
val layoutRes = when (item.itemId) {
|
||||
R.id.action_layout_normal -> R.layout.item_grid
|
||||
R.id.action_layout_card -> R.layout.item_card
|
||||
R.id.action_layout_colored_card -> R.layout.item_card_color
|
||||
R.id.action_layout_circular -> R.layout.item_grid_circle
|
||||
R.id.action_layout_image -> R.layout.image
|
||||
R.id.action_layout_gradient_image -> R.layout.item_image_gradient
|
||||
else -> PreferenceUtil.songGridStyle
|
||||
}
|
||||
if (layoutRes != -1) {
|
||||
if (layoutRes != PreferenceUtil.songGridStyle) {
|
||||
item.isChecked = true
|
||||
setAndSaveLayoutRes(layoutRes)
|
||||
return true
|
||||
|
@ -271,16 +274,16 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
|
|||
private fun handleGridSizeMenuItem(
|
||||
item: MenuItem
|
||||
): Boolean {
|
||||
var gridSize = 0
|
||||
when (item.itemId) {
|
||||
R.id.action_grid_size_1 -> gridSize = 1
|
||||
R.id.action_grid_size_2 -> gridSize = 2
|
||||
R.id.action_grid_size_3 -> gridSize = 3
|
||||
R.id.action_grid_size_4 -> gridSize = 4
|
||||
R.id.action_grid_size_5 -> gridSize = 5
|
||||
R.id.action_grid_size_6 -> gridSize = 6
|
||||
R.id.action_grid_size_7 -> gridSize = 7
|
||||
R.id.action_grid_size_8 -> gridSize = 8
|
||||
val gridSize = when (item.itemId) {
|
||||
R.id.action_grid_size_1 -> 1
|
||||
R.id.action_grid_size_2 -> 2
|
||||
R.id.action_grid_size_3 -> 3
|
||||
R.id.action_grid_size_4 -> 4
|
||||
R.id.action_grid_size_5 -> 5
|
||||
R.id.action_grid_size_6 -> 6
|
||||
R.id.action_grid_size_7 -> 7
|
||||
R.id.action_grid_size_8 -> 8
|
||||
else -> 0
|
||||
}
|
||||
if (gridSize > 0) {
|
||||
item.isChecked = true
|
||||
|
@ -299,4 +302,31 @@ class SongsFragment : AbsRecyclerViewCustomGridSizeFragment<SongAdapter, GridLay
|
|||
return SongsFragment()
|
||||
}
|
||||
}
|
||||
|
||||
private var cab: MaterialCab? = null
|
||||
|
||||
fun handleBackPress(): Boolean {
|
||||
cab?.let {
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
override fun openCab(menuRes: Int, callback: MaterialCab.Callback): MaterialCab {
|
||||
cab?.let {
|
||||
println("Cab")
|
||||
if (it.isActive) {
|
||||
it.finish()
|
||||
}
|
||||
}
|
||||
cab = MaterialCab(mainActivity, R.id.cab_stub)
|
||||
.setMenu(menuRes)
|
||||
.setCloseDrawableRes(R.drawable.ic_close)
|
||||
.setBackgroundColor(RetroColorUtil.shiftBackgroundColorForLightText(surfaceColor()))
|
||||
.start(callback)
|
||||
return cab as MaterialCab
|
||||
}
|
||||
}
|
||||
|
|
|
@ -426,7 +426,7 @@ object PreferenceUtil {
|
|||
val tabTitleMode: Int
|
||||
get() {
|
||||
return when (sharedPreferences.getStringOrDefault(
|
||||
TAB_TEXT_MODE, "1"
|
||||
TAB_TEXT_MODE, "0"
|
||||
).toInt()) {
|
||||
1 -> LabelVisibilityMode.LABEL_VISIBILITY_LABELED
|
||||
0 -> LabelVisibilityMode.LABEL_VISIBILITY_AUTO
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
|
@ -9,7 +10,6 @@
|
|||
android:transitionName="@string/transition_album_art"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/toolbarContainer"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -29,7 +29,6 @@
|
|||
android:layout_height="48dp" />
|
||||
</FrameLayout>
|
||||
|
||||
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
android:id="@+id/albumCoverContainer"
|
||||
android:layout_width="0dp"
|
||||
|
@ -38,9 +37,8 @@
|
|||
android:layout_marginTop="8dp"
|
||||
android:layout_marginEnd="16dp"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/container"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toStartOf="@+id/content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbarContainer">
|
||||
|
||||
|
@ -53,9 +51,8 @@
|
|||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/container"
|
||||
android:id="@+id/content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:descendantFocusability="beforeDescendants"
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="?attr/colorSurface"
|
||||
android:orientation="vertical"
|
||||
tools:ignore="UnusedAttribute">
|
||||
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/toolbarContainer"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -38,9 +38,8 @@
|
|||
android:layout_marginEnd="16dp"
|
||||
android:transitionName="@string/transition_artist_image"
|
||||
app:cardCornerRadius="24dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toStartOf="@+id/container"
|
||||
app:layout_constraintHorizontal_bias="0.5"
|
||||
app:layout_constraintDimensionRatio="1:1"
|
||||
app:layout_constraintEnd_toStartOf="@+id/content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/toolbarContainer">
|
||||
|
||||
|
@ -53,9 +52,8 @@
|
|||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/container"
|
||||
android:id="@+id/content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
|
|
Loading…
Reference in a new issue