commit
e9c1559c57
8 changed files with 183 additions and 70 deletions
|
@ -9,7 +9,7 @@ import android.widget.FrameLayout
|
|||
import androidx.annotation.LayoutRes
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.transition.TransitionManager
|
||||
import code.name.monkey.appthemehelper.util.ATHUtil
|
||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -22,6 +22,7 @@ import code.name.monkey.retromusic.fragments.NowPlayingScreen
|
|||
import code.name.monkey.retromusic.fragments.NowPlayingScreen.*
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.model.CategoryInfo
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState.*
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.views.BottomNavigationBarTinted
|
||||
import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
|
@ -75,13 +76,11 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
setupSlidingUpPanel()
|
||||
|
||||
setupBottomSheet()
|
||||
|
||||
libraryViewModel.paletteColorLiveData.observe(this, Observer {
|
||||
this.paletteColor = it
|
||||
onPaletteColorChanged()
|
||||
})
|
||||
updatePanelState()
|
||||
updateColor()
|
||||
}
|
||||
|
||||
|
||||
fun getBottomSheetBehavior() = behavior
|
||||
|
||||
private fun setupBottomSheet() {
|
||||
|
@ -201,7 +200,11 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
ViewTreeObserver.OnGlobalLayoutListener {
|
||||
override fun onGlobalLayout() {
|
||||
slidingPanel.viewTreeObserver.removeOnGlobalLayoutListener(this)
|
||||
hideBottomBar(false)
|
||||
if (bottomNavigationView.isVisible) {
|
||||
libraryViewModel.setPanelState(COLLAPSED_WITH)
|
||||
} else {
|
||||
libraryViewModel.setPanelState(COLLAPSED_WITHOUT)
|
||||
}
|
||||
}
|
||||
})
|
||||
} // don't call hideBottomBar(true) here as it causes a bug with the SlidingUpPanelLayout
|
||||
|
@ -209,7 +212,16 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
|
||||
override fun onQueueChanged() {
|
||||
super.onQueueChanged()
|
||||
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
||||
val isEmpty = MusicPlayerRemote.playingQueue.isEmpty()
|
||||
if (isEmpty) {
|
||||
libraryViewModel.setPanelState(HIDE)
|
||||
} else {
|
||||
if (bottomNavigationView.isVisible) {
|
||||
libraryViewModel.setPanelState(EXPAND)
|
||||
} else {
|
||||
libraryViewModel.setPanelState(COLLAPSED_WITHOUT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
@ -308,4 +320,59 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
bottomNavigationView.hide()
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateColor() {
|
||||
libraryViewModel.paletteColor.observe(this, { color ->
|
||||
this.paletteColor = color
|
||||
onPaletteColorChanged()
|
||||
})
|
||||
}
|
||||
|
||||
private fun updatePanelState() {
|
||||
libraryViewModel.panelState.observe(this, { state ->
|
||||
when (state) {
|
||||
EXPAND -> {
|
||||
println("EXPAND")
|
||||
expandPanel()
|
||||
}
|
||||
HIDE -> {
|
||||
println("HIDE")
|
||||
behavior.isHideable = true
|
||||
behavior.peekHeight = 0
|
||||
collapsePanel()
|
||||
ViewCompat.setElevation(slidingPanel, 0f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
}
|
||||
COLLAPSED_WITH -> {
|
||||
println("COLLAPSED_WITH")
|
||||
TransitionManager.beginDelayedTransition(mainContent)
|
||||
bottomNavigationView.isVisible = true
|
||||
val heightOfBar = bottomNavigationView.height
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
ViewCompat.setElevation(slidingPanel, 10f)
|
||||
behavior.isHideable = false
|
||||
behavior.peekHeight = (heightOfBar * 2) - 24
|
||||
}
|
||||
COLLAPSED_WITHOUT -> {
|
||||
println("COLLAPSED_WITHOUT")
|
||||
TransitionManager.beginDelayedTransition(mainContent)
|
||||
TransitionManager.beginDelayedTransition(slidingPanel)
|
||||
val heightOfBar = bottomNavigationView.height
|
||||
bottomNavigationView.isVisible = false
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
ViewCompat.setElevation(slidingPanel, 10f)
|
||||
behavior.isHideable = false
|
||||
behavior.peekHeight = heightOfBar - 24
|
||||
}
|
||||
else -> {
|
||||
println("ELSE")
|
||||
behavior.isHideable = true
|
||||
behavior.peekHeight = 0
|
||||
collapsePanel()
|
||||
ViewCompat.setElevation(slidingPanel, 0f)
|
||||
ViewCompat.setElevation(bottomNavigationView, 10f)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
|
@ -5,7 +5,6 @@ import android.view.View
|
|||
import android.widget.ImageView
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.lifecycle.Observer
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.FragmentNavigatorExtras
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.navigation.fragment.navArgs
|
||||
|
@ -21,23 +20,19 @@ import code.name.monkey.retromusic.fragments.artists.ArtistClickListener
|
|||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.model.Album
|
||||
import code.name.monkey.retromusic.model.Artist
|
||||
import code.name.monkey.retromusic.repository.RealRepository
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import kotlinx.android.synthetic.main.fragment_playlist_detail.*
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.koin.android.ext.android.inject
|
||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||
|
||||
class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_detail),
|
||||
ArtistClickListener, AlbumClickListener {
|
||||
private val args by navArgs<DetailListFragmentArgs>()
|
||||
private val repository by inject<RealRepository>()
|
||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
mainActivity.hideBottomBarVisibility(false)
|
||||
progressIndicator.hide()
|
||||
when (args.type) {
|
||||
TOP_ARTISTS -> {
|
||||
|
@ -70,10 +65,9 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
|||
adapter = songAdapter
|
||||
layoutManager = linearLayoutManager()
|
||||
}
|
||||
lifecycleScope.launch(IO) {
|
||||
val songs = repository.recentSongs()
|
||||
withContext(Main) { songAdapter.swapDataSet(songs) }
|
||||
}
|
||||
libraryViewModel.recentSongs().observe(viewLifecycleOwner, Observer { songs ->
|
||||
songAdapter.swapDataSet(songs)
|
||||
})
|
||||
}
|
||||
|
||||
private fun topPlayed() {
|
||||
|
@ -87,12 +81,10 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
|||
adapter = songAdapter
|
||||
layoutManager = linearLayoutManager()
|
||||
}
|
||||
lifecycleScope.launch(IO) {
|
||||
val songs = repository.playCountSongs().map {
|
||||
it.toSong()
|
||||
}
|
||||
withContext(Main) { songAdapter.swapDataSet(songs) }
|
||||
}
|
||||
libraryViewModel.playCountSongs().observe(viewLifecycleOwner, Observer { songs ->
|
||||
songAdapter.swapDataSet(songs)
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
private fun loadHistory() {
|
||||
|
@ -107,7 +99,7 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
|||
adapter = songAdapter
|
||||
layoutManager = linearLayoutManager()
|
||||
}
|
||||
repository.observableHistorySongs().observe(viewLifecycleOwner, Observer {
|
||||
libraryViewModel.observableHistorySongs().observe(viewLifecycleOwner, Observer {
|
||||
val songs = it.map { historyEntity -> historyEntity.toSong() }
|
||||
songAdapter.swapDataSet(songs)
|
||||
})
|
||||
|
@ -124,8 +116,7 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
|||
adapter = songAdapter
|
||||
layoutManager = linearLayoutManager()
|
||||
}
|
||||
repository.favorites().observe(viewLifecycleOwner, Observer {
|
||||
println(it.size)
|
||||
libraryViewModel.favorites().observe(viewLifecycleOwner, {
|
||||
val songs = it.map { songEntity -> songEntity.toSong() }
|
||||
songAdapter.swapDataSet(songs)
|
||||
})
|
||||
|
@ -133,31 +124,22 @@ class DetailListFragment : AbsMainActivityFragment(R.layout.fragment_playlist_de
|
|||
|
||||
private fun loadArtists(title: Int, type: Int) {
|
||||
toolbar.setTitle(title)
|
||||
lifecycleScope.launch(IO) {
|
||||
val artists =
|
||||
if (type == TOP_ARTISTS) repository.topArtists() else repository.recentArtists()
|
||||
withContext(Main) {
|
||||
recyclerView.apply {
|
||||
adapter = artistAdapter(artists)
|
||||
layoutManager = gridLayoutManager()
|
||||
}
|
||||
libraryViewModel.artists(type).observe(viewLifecycleOwner, { artists ->
|
||||
recyclerView.apply {
|
||||
adapter = artistAdapter(artists)
|
||||
layoutManager = gridLayoutManager()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun loadAlbums(title: Int, type: Int) {
|
||||
toolbar.setTitle(title)
|
||||
lifecycleScope.launch(IO) {
|
||||
val albums =
|
||||
if (type == TOP_ALBUMS) repository.topAlbums() else repository.recentAlbums()
|
||||
withContext(Main) {
|
||||
recyclerView.apply {
|
||||
adapter = albumAdapter(albums)
|
||||
layoutManager = gridLayoutManager()
|
||||
|
||||
}
|
||||
libraryViewModel.albums(type).observe(viewLifecycleOwner, { albums ->
|
||||
recyclerView.apply {
|
||||
adapter = albumAdapter(albums)
|
||||
layoutManager = gridLayoutManager()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun artistAdapter(artists: List<Artist>): ArtistAdapter = ArtistAdapter(
|
||||
|
|
|
@ -1,19 +1,21 @@
|
|||
package code.name.monkey.retromusic.fragments
|
||||
|
||||
import androidx.lifecycle.LiveData
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import code.name.monkey.retromusic.db.PlaylistEntity
|
||||
import code.name.monkey.retromusic.db.PlaylistWithSongs
|
||||
import code.name.monkey.retromusic.db.SongEntity
|
||||
import code.name.monkey.retromusic.db.toSongEntity
|
||||
import androidx.lifecycle.*
|
||||
import code.name.monkey.retromusic.RECENT_ALBUMS
|
||||
import code.name.monkey.retromusic.RECENT_ARTISTS
|
||||
import code.name.monkey.retromusic.TOP_ALBUMS
|
||||
import code.name.monkey.retromusic.TOP_ARTISTS
|
||||
import code.name.monkey.retromusic.db.*
|
||||
import code.name.monkey.retromusic.fragments.ReloadType.*
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
import code.name.monkey.retromusic.interfaces.MusicServiceEventListener
|
||||
import code.name.monkey.retromusic.model.*
|
||||
import code.name.monkey.retromusic.repository.RealRepository
|
||||
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
@ -21,7 +23,7 @@ class LibraryViewModel(
|
|||
private val repository: RealRepository
|
||||
) : ViewModel(), MusicServiceEventListener {
|
||||
|
||||
private val paletteColor = MutableLiveData<Int>()
|
||||
private val _paletteColor = MutableLiveData<Int>()
|
||||
private val albums = MutableLiveData<List<Album>>()
|
||||
private val songs = MutableLiveData<List<Song>>()
|
||||
private val artists = MutableLiveData<List<Artist>>()
|
||||
|
@ -30,12 +32,17 @@ class LibraryViewModel(
|
|||
private val genres = MutableLiveData<List<Genre>>()
|
||||
private val home = MutableLiveData<List<Home>>()
|
||||
|
||||
val paletteColorLiveData: LiveData<Int> = paletteColor
|
||||
val paletteColor: LiveData<Int> = _paletteColor
|
||||
val panelState: MutableLiveData<NowPlayingPanelState> = MutableLiveData<NowPlayingPanelState>()
|
||||
|
||||
init {
|
||||
fetchHomeSections()
|
||||
}
|
||||
|
||||
fun setPanelState(state: NowPlayingPanelState) {
|
||||
panelState.postValue(state)
|
||||
}
|
||||
|
||||
private fun loadLibraryContent() = viewModelScope.launch(IO) {
|
||||
fetchHomeSections()
|
||||
fetchSongs()
|
||||
|
@ -139,7 +146,7 @@ class LibraryViewModel(
|
|||
}
|
||||
|
||||
fun updateColor(newColor: Int) {
|
||||
paletteColor.postValue(newColor)
|
||||
_paletteColor.postValue(newColor)
|
||||
}
|
||||
|
||||
override fun onMediaStoreChanged() {
|
||||
|
@ -239,6 +246,38 @@ class LibraryViewModel(
|
|||
fetchPlaylists()
|
||||
loadLibraryContent()
|
||||
}
|
||||
|
||||
fun recentSongs(): LiveData<List<Song>> = liveData {
|
||||
emit(repository.recentSongs())
|
||||
}
|
||||
|
||||
fun playCountSongs(): LiveData<List<Song>> = liveData {
|
||||
emit(repository.playCountSongs().map {
|
||||
it.toSong()
|
||||
})
|
||||
}
|
||||
|
||||
fun observableHistorySongs() = repository.observableHistorySongs()
|
||||
|
||||
fun favorites() = repository.favorites()
|
||||
|
||||
fun artists(type: Int): LiveData<List<Artist>> = liveData {
|
||||
when (type) {
|
||||
TOP_ARTISTS -> emit(repository.topArtists())
|
||||
RECENT_ARTISTS -> {
|
||||
emit(repository.recentArtists())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun albums(type: Int): LiveData<List<Album>> = liveData {
|
||||
when (type) {
|
||||
TOP_ALBUMS -> emit(repository.topAlbums())
|
||||
RECENT_ALBUMS -> {
|
||||
emit(repository.recentAlbums())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
enum class ReloadType {
|
||||
|
|
|
@ -30,6 +30,7 @@ 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.show
|
||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.glide.AlbumGlideRequest
|
||||
import code.name.monkey.retromusic.glide.ArtistGlideRequest
|
||||
|
@ -42,6 +43,7 @@ import code.name.monkey.retromusic.model.Artist
|
|||
import code.name.monkey.retromusic.network.Result
|
||||
import code.name.monkey.retromusic.network.model.LastFmAlbum
|
||||
import code.name.monkey.retromusic.repository.RealRepository
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
|
@ -55,6 +57,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.koin.android.ext.android.get
|
||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import java.util.*
|
||||
|
@ -66,6 +69,7 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
private val detailsViewModel by viewModel<AlbumDetailsViewModel> {
|
||||
parametersOf(arguments.extraAlbumId)
|
||||
}
|
||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||
|
||||
private lateinit var simpleSongAdapter: SimpleSongAdapter
|
||||
private lateinit var album: Album
|
||||
|
@ -73,6 +77,11 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
private val savedSortOrder: String
|
||||
get() = PreferenceUtil.albumDetailSongSortOrder
|
||||
|
||||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
sharedElementEnterTransition = MaterialContainerTransform().apply {
|
||||
|
@ -84,7 +93,6 @@ class AlbumDetailsFragment : AbsMainActivityFragment(R.layout.fragment_album_det
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
mainActivity.hideBottomBarVisibility(false)
|
||||
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
toolbar.title = " "
|
||||
|
|
|
@ -26,6 +26,7 @@ import code.name.monkey.retromusic.extensions.applyColor
|
|||
import code.name.monkey.retromusic.extensions.applyOutlineColor
|
||||
import code.name.monkey.retromusic.extensions.show
|
||||
import code.name.monkey.retromusic.extensions.showToast
|
||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||
import code.name.monkey.retromusic.fragments.albums.AlbumClickListener
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.glide.ArtistGlideRequest
|
||||
|
@ -35,6 +36,7 @@ import code.name.monkey.retromusic.model.Artist
|
|||
import code.name.monkey.retromusic.network.Result
|
||||
import code.name.monkey.retromusic.network.model.LastFmArtist
|
||||
import code.name.monkey.retromusic.repository.RealRepository
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import code.name.monkey.retromusic.util.CustomArtistImageUtil
|
||||
import code.name.monkey.retromusic.util.MusicUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
|
@ -45,6 +47,7 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.koin.android.ext.android.get
|
||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import java.util.*
|
||||
|
@ -56,7 +59,7 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d
|
|||
private val detailsViewModel: ArtistDetailsViewModel by viewModel {
|
||||
parametersOf(arguments.extraArtistId)
|
||||
}
|
||||
|
||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||
private lateinit var artist: Artist
|
||||
private lateinit var songAdapter: SimpleSongAdapter
|
||||
private lateinit var albumAdapter: HorizontalAlbumAdapter
|
||||
|
@ -68,17 +71,17 @@ class ArtistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_artist_d
|
|||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
mainActivity.hideBottomBarVisibility(false)
|
||||
|
||||
toolbar.title = null
|
||||
setupRecyclerView()
|
||||
|
||||
postponeEnterTransition()
|
||||
detailsViewModel.getArtist().observe(viewLifecycleOwner, Observer {
|
||||
showArtist(it)
|
||||
startPostponedEnterTransition()
|
||||
showArtist(it)
|
||||
})
|
||||
|
||||
|
||||
playAction.apply {
|
||||
setOnClickListener { MusicPlayerRemote.openQueue(artist.songs, 0, true) }
|
||||
}
|
||||
|
|
|
@ -12,11 +12,14 @@ import androidx.recyclerview.widget.RecyclerView
|
|||
import code.name.monkey.retromusic.R
|
||||
import code.name.monkey.retromusic.adapter.song.SongAdapter
|
||||
import code.name.monkey.retromusic.extensions.dipToPix
|
||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.helper.menu.GenreMenuHelper
|
||||
import code.name.monkey.retromusic.model.Genre
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import kotlinx.android.synthetic.main.fragment_playlist_detail.*
|
||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
import java.util.*
|
||||
|
@ -26,7 +29,7 @@ class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_
|
|||
private val detailsViewModel: GenreDetailsViewModel by viewModel {
|
||||
parametersOf(arguments.extraGenre)
|
||||
}
|
||||
|
||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||
private lateinit var genre: Genre
|
||||
private lateinit var songAdapter: SongAdapter
|
||||
|
||||
|
@ -35,7 +38,7 @@ class GenreDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playlist_
|
|||
setHasOptionsMenu(true)
|
||||
mainActivity.addMusicServiceEventListener(detailsViewModel)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
mainActivity.hideBottomBarVisibility(false)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
progressIndicator.hide()
|
||||
setupRecyclerView()
|
||||
detailsViewModel.getSongs().observe(viewLifecycleOwner, androidx.lifecycle.Observer {
|
||||
|
|
|
@ -14,14 +14,17 @@ import code.name.monkey.retromusic.adapter.song.SongAdapter
|
|||
import code.name.monkey.retromusic.db.PlaylistWithSongs
|
||||
import code.name.monkey.retromusic.db.toSongs
|
||||
import code.name.monkey.retromusic.extensions.dipToPix
|
||||
import code.name.monkey.retromusic.fragments.LibraryViewModel
|
||||
import code.name.monkey.retromusic.fragments.base.AbsMainActivityFragment
|
||||
import code.name.monkey.retromusic.helper.menu.PlaylistMenuHelper
|
||||
import code.name.monkey.retromusic.model.Song
|
||||
import code.name.monkey.retromusic.state.NowPlayingPanelState
|
||||
import code.name.monkey.retromusic.util.PlaylistsUtil
|
||||
import com.h6ah4i.android.widget.advrecyclerview.animator.RefactoredDefaultItemAnimator
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager
|
||||
import com.h6ah4i.android.widget.advrecyclerview.utils.WrapperAdapterUtils
|
||||
import kotlinx.android.synthetic.main.fragment_playlist_detail.*
|
||||
import org.koin.androidx.viewmodel.ext.android.sharedViewModel
|
||||
import org.koin.androidx.viewmodel.ext.android.viewModel
|
||||
import org.koin.core.parameter.parametersOf
|
||||
|
||||
|
@ -30,7 +33,7 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
|
|||
private val viewModel: PlaylistDetailsViewModel by viewModel {
|
||||
parametersOf(arguments.extraPlaylist)
|
||||
}
|
||||
|
||||
private val libraryViewModel by sharedViewModel<LibraryViewModel>()
|
||||
private lateinit var playlist: PlaylistWithSongs
|
||||
private lateinit var adapter: SongAdapter
|
||||
|
||||
|
@ -40,9 +43,9 @@ class PlaylistDetailsFragment : AbsMainActivityFragment(R.layout.fragment_playli
|
|||
override fun onActivityCreated(savedInstanceState: Bundle?) {
|
||||
super.onActivityCreated(savedInstanceState)
|
||||
setHasOptionsMenu(true)
|
||||
libraryViewModel.setPanelState(NowPlayingPanelState.COLLAPSED_WITHOUT)
|
||||
mainActivity.addMusicServiceEventListener(viewModel)
|
||||
mainActivity.setSupportActionBar(toolbar)
|
||||
mainActivity.hideBottomBarVisibility(false)
|
||||
|
||||
playlist = arguments.extraPlaylist
|
||||
toolbar.title = playlist.playlistEntity.playlistName
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package code.name.monkey.retromusic.state
|
||||
|
||||
enum class NowPlayingPanelState {
|
||||
EXPAND,
|
||||
COLLAPSED_WITH,
|
||||
COLLAPSED_WITHOUT,
|
||||
HIDE,
|
||||
}
|
Loading…
Reference in a new issue