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