update the colors in fragments in onResume
This commit is contained in:
parent
12b0f80f29
commit
46d68c5797
7 changed files with 35 additions and 16 deletions
|
@ -82,9 +82,14 @@ class MainActivity : SimpleActivity() {
|
|||
sleep_timer_stop.applyColorFilter(config.textColor)
|
||||
updateCurrentTrackBar()
|
||||
|
||||
val adjustedPrimaryColor = getAdjustedPrimaryColor()
|
||||
main_tabs_holder.apply {
|
||||
setTabTextColors(config.textColor, getAdjustedPrimaryColor())
|
||||
setSelectedTabIndicatorColor(getAdjustedPrimaryColor())
|
||||
setTabTextColors(config.textColor, adjustedPrimaryColor)
|
||||
setSelectedTabIndicatorColor(adjustedPrimaryColor)
|
||||
}
|
||||
|
||||
getAllFragments().forEach {
|
||||
it?.setupColors(config.textColor, adjustedPrimaryColor)
|
||||
}
|
||||
|
||||
// equalizer can sometimes reset on app start/resume, no idea why. Lets just wait a bit and reenable it
|
||||
|
|
|
@ -3,8 +3,10 @@ package com.simplemobiletools.musicplayer.adapters
|
|||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
import com.simplemobiletools.commons.extensions.getAdjustedPrimaryColor
|
||||
import com.simplemobiletools.musicplayer.R
|
||||
import com.simplemobiletools.musicplayer.activities.SimpleActivity
|
||||
import com.simplemobiletools.musicplayer.extensions.config
|
||||
import com.simplemobiletools.musicplayer.fragments.MyViewPagerFragment
|
||||
|
||||
class ViewPagerAdapter(val activity: SimpleActivity) : PagerAdapter() {
|
||||
|
@ -15,6 +17,7 @@ class ViewPagerAdapter(val activity: SimpleActivity) : PagerAdapter() {
|
|||
|
||||
(view as MyViewPagerFragment).apply {
|
||||
setupFragment(activity)
|
||||
setupColors(activity.config.textColor, activity.getAdjustedPrimaryColor())
|
||||
}
|
||||
|
||||
return view
|
||||
|
|
|
@ -53,9 +53,6 @@ class AlbumsFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
albums_fastscroller.updatePrimaryColor()
|
||||
albums_fastscroller.updateBubbleColors()
|
||||
}
|
||||
|
||||
override fun finishActMode() {
|
||||
|
@ -86,4 +83,9 @@ class AlbumsFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
adapter.updateItems(albums, forceUpdate = true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
|
||||
albums_fastscroller.updatePrimaryColor()
|
||||
albums_fastscroller.updateBubbleColors()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,9 +44,6 @@ class ArtistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
artists_fastscroller.updatePrimaryColor()
|
||||
artists_fastscroller.updateBubbleColors()
|
||||
}
|
||||
|
||||
override fun finishActMode() {
|
||||
|
@ -77,4 +74,9 @@ class ArtistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
adapter.updateItems(artists, forceUpdate = true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
|
||||
artists_fastscroller.updatePrimaryColor()
|
||||
artists_fastscroller.updateBubbleColors()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,4 +17,6 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
|
|||
abstract fun onSearchClosed()
|
||||
|
||||
abstract fun onSortOpen(activity: SimpleActivity)
|
||||
|
||||
abstract fun setupColors(textColor: Int, adjustedPrimaryColor: Int)
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ class PlaylistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||
private var playlistsIgnoringSearch = ArrayList<Playlist>()
|
||||
|
||||
override fun setupFragment(activity: SimpleActivity) {
|
||||
playlists_placeholder.setTextColor(activity.config.textColor)
|
||||
playlists_placeholder_2.setTextColor(activity.getAdjustedPrimaryColor())
|
||||
playlists_placeholder_2.underlineText()
|
||||
playlists_placeholder_2.setOnClickListener {
|
||||
NewPlaylistDialog(activity) {
|
||||
|
@ -65,9 +63,6 @@ class PlaylistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
playlists_fastscroller.updatePrimaryColor()
|
||||
playlists_fastscroller.updateBubbleColors()
|
||||
}
|
||||
|
||||
override fun finishActMode() {
|
||||
|
@ -100,4 +95,12 @@ class PlaylistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
|
|||
adapter.updateItems(playlists, forceUpdate = true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
|
||||
playlists_placeholder.setTextColor(textColor)
|
||||
playlists_placeholder_2.setTextColor(adjustedPrimaryColor)
|
||||
|
||||
playlists_fastscroller.updatePrimaryColor()
|
||||
playlists_fastscroller.updateBubbleColors()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,9 +75,6 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
context.config.wereInitialTracksFetched = true
|
||||
}
|
||||
}
|
||||
|
||||
tracks_fastscroller.updatePrimaryColor()
|
||||
tracks_fastscroller.updateBubbleColors()
|
||||
}
|
||||
|
||||
override fun finishActMode() {
|
||||
|
@ -108,4 +105,9 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
|
|||
adapter.updateItems(tracks, forceUpdate = true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
|
||||
tracks_fastscroller.updatePrimaryColor()
|
||||
tracks_fastscroller.updateBubbleColors()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue