Added playing queue fragment
This commit is contained in:
parent
6e081f30c0
commit
a83879dffb
5 changed files with 29 additions and 6 deletions
|
@ -27,7 +27,6 @@ import code.name.monkey.retromusic.activities.base.AbsCastActivity
|
|||
import code.name.monkey.retromusic.databinding.SlidingMusicPanelLayoutBinding
|
||||
import code.name.monkey.retromusic.extensions.extra
|
||||
import code.name.monkey.retromusic.extensions.findNavController
|
||||
import code.name.monkey.retromusic.extensions.surfaceColor
|
||||
import code.name.monkey.retromusic.fragments.base.AbsRecyclerViewFragment
|
||||
import code.name.monkey.retromusic.fragments.home.HomeFragment
|
||||
import code.name.monkey.retromusic.helper.MusicPlayerRemote
|
||||
|
@ -38,7 +37,6 @@ import code.name.monkey.retromusic.repository.PlaylistSongsLoader
|
|||
import code.name.monkey.retromusic.service.MusicService
|
||||
import code.name.monkey.retromusic.util.AppRater
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import code.name.monkey.retromusic.util.RetroUtil
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.launch
|
||||
import org.koin.android.ext.android.get
|
||||
|
@ -90,7 +88,9 @@ class MainActivity : AbsCastActivity(), OnSharedPreferenceChangeListener {
|
|||
getBottomNavigationView().setupWithNavController(navController)
|
||||
// Scroll Fragment to top
|
||||
getBottomNavigationView().setOnItemReselectedListener {
|
||||
supportFragmentManager.findFragmentById(R.id.fragment_container)?.childFragmentManager?.fragments?.get(0)
|
||||
supportFragmentManager.findFragmentById(R.id.fragment_container)?.childFragmentManager?.fragments?.get(
|
||||
0
|
||||
)
|
||||
.also {
|
||||
if (it is AbsRecyclerViewFragment<*, *>) {
|
||||
it.scrollToTop()
|
||||
|
@ -110,6 +110,10 @@ class MainActivity : AbsCastActivity(), OnSharedPreferenceChangeListener {
|
|||
// Show Bottom Navigation Bar
|
||||
setBottomBarVisibility(true)
|
||||
}
|
||||
R.id.playing_queue_fragment -> {
|
||||
setBottomBarVisibility(false)
|
||||
hideBottomBar(true)
|
||||
}
|
||||
else -> setBottomBarVisibility(false) // Hide Bottom Navigation Bar
|
||||
}
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ abstract class AbsSlidingMusicPanelActivity : AbsMusicServiceActivity() {
|
|||
hideBottomBar(MusicPlayerRemote.playingQueue.isEmpty())
|
||||
}
|
||||
|
||||
private fun hideBottomBar(hide: Boolean) {
|
||||
fun hideBottomBar(hide: Boolean) {
|
||||
val heightOfBar = RetroUtil.getNavigationBarHeight() +
|
||||
if (MusicPlayerRemote.isCasting) dip(R.dimen.cast_mini_player_height) else dip(R.dimen.mini_player_height)
|
||||
val heightOfBarWithTabs = RetroUtil.getNavigationBarHeight() +
|
||||
|
|
|
@ -144,7 +144,10 @@ abstract class AbsPlayerFragment(@LayoutRes layout: Int) : AbsMainActivityFragme
|
|||
return true
|
||||
}
|
||||
R.id.now_playing -> {
|
||||
NavigationUtil.goToPlayingQueue(requireActivity())
|
||||
requireActivity().findNavController(R.id.fragment_container).navigate(
|
||||
R.id.playing_queue_fragment,
|
||||
null
|
||||
)
|
||||
return true
|
||||
}
|
||||
R.id.action_show_lyrics -> {
|
||||
|
|
|
@ -17,6 +17,7 @@ package code.name.monkey.retromusic.fragments.queue
|
|||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.navigation.findNavController
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import code.name.monkey.retromusic.R
|
||||
|
@ -46,6 +47,16 @@ class PlayingQueueFragment : AbsRecyclerViewFragment<PlayingQueueAdapter, Linear
|
|||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
setupRecyclerView()
|
||||
setupToolbar()
|
||||
}
|
||||
|
||||
private fun setupToolbar() {
|
||||
toolbar().apply {
|
||||
setOnClickListener {
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
setNavigationIcon(R.drawable.ic_keyboard_backspace_black)
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupRecyclerView() {
|
||||
|
@ -90,10 +101,12 @@ class PlayingQueueFragment : AbsRecyclerViewFragment<PlayingQueueAdapter, Linear
|
|||
override fun onQueueChanged() {
|
||||
super.onQueueChanged()
|
||||
updateQueue()
|
||||
mainActivity.hideBottomBar(true)
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
updateQueuePosition()
|
||||
mainActivity.hideBottomBar(true)
|
||||
}
|
||||
|
||||
private fun updateQueuePosition() {
|
||||
|
|
|
@ -86,7 +86,6 @@
|
|||
android:label="PermissionFragment"
|
||||
tools:layout="@layout/activity_permission" />
|
||||
|
||||
|
||||
<fragment
|
||||
android:id="@+id/action_album"
|
||||
android:name="code.name.monkey.retromusic.fragments.albums.AlbumsFragment"
|
||||
|
@ -126,4 +125,8 @@
|
|||
<fragment
|
||||
android:id="@+id/user_info_fragment"
|
||||
android:name="code.name.monkey.retromusic.fragments.UserInfoFragment" />
|
||||
|
||||
<fragment
|
||||
android:id="@+id/playing_queue_fragment"
|
||||
android:name="code.name.monkey.retromusic.fragments.queue.PlayingQueueFragment" />
|
||||
</navigation>
|
Loading…
Reference in a new issue