Fixed a rare crash because of notifyDataSetChanged in Now playing ViewPager
This commit is contained in:
parent
88b0299ef9
commit
dba4edd8ef
3 changed files with 8 additions and 7 deletions
|
@ -49,7 +49,6 @@ import code.name.monkey.retromusic.util.LyricUtil
|
||||||
import code.name.monkey.retromusic.util.CoverLyricsType
|
import code.name.monkey.retromusic.util.CoverLyricsType
|
||||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||||
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
|
||||||
import code.name.monkey.retromusic.util.logD
|
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
|
@ -250,8 +249,7 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(R.layout.fragment_playe
|
||||||
|
|
||||||
private fun updatePlayingQueue() {
|
private fun updatePlayingQueue() {
|
||||||
binding.viewPager.apply {
|
binding.viewPager.apply {
|
||||||
adapter = AlbumCoverPagerAdapter(childFragmentManager, MusicPlayerRemote.playingQueue)
|
adapter = AlbumCoverPagerAdapter(parentFragmentManager, MusicPlayerRemote.playingQueue)
|
||||||
adapter?.notifyDataSetChanged()
|
|
||||||
setCurrentItem(MusicPlayerRemote.position, true)
|
setCurrentItem(MusicPlayerRemote.position, true)
|
||||||
onPageSelected(MusicPlayerRemote.position)
|
onPageSelected(MusicPlayerRemote.position)
|
||||||
}
|
}
|
||||||
|
@ -260,7 +258,6 @@ class PlayerAlbumCoverFragment : AbsMusicServiceFragment(R.layout.fragment_playe
|
||||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {}
|
||||||
|
|
||||||
override fun onPageSelected(position: Int) {
|
override fun onPageSelected(position: Int) {
|
||||||
logD("Page Selected $position")
|
|
||||||
currentPosition = position
|
currentPosition = position
|
||||||
if (binding.viewPager.adapter != null) {
|
if (binding.viewPager.adapter != null) {
|
||||||
(binding.viewPager.adapter as AlbumCoverPagerAdapter).receiveColor(
|
(binding.viewPager.adapter as AlbumCoverPagerAdapter).receiveColor(
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?colorSurface">
|
android:background="?colorSurface"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
<include layout="@layout/shadow_statusbar_toolbar" />
|
<include layout="@layout/shadow_statusbar_toolbar" />
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="?colorSurface">
|
android:background="?colorSurface"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true">
|
||||||
|
|
||||||
<include layout="@layout/shadow_statusbar_toolbar" />
|
<include layout="@layout/shadow_statusbar_toolbar" />
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue