Skip to content

Commit a2103dc

Browse files
committed
Properly update colors on theme change
1 parent 4cfc6a6 commit a2103dc

File tree

8 files changed

+20
-5
lines changed

8 files changed

+20
-5
lines changed

app/src/main/kotlin/com/simplemobiletools/musicplayer/adapters/BaseMusicAdapter.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import com.bumptech.glide.load.resource.bitmap.RoundedCorners
1010
import com.bumptech.glide.request.RequestOptions
1111
import com.simplemobiletools.commons.activities.BaseSimpleActivity
1212
import com.simplemobiletools.commons.adapters.MyRecyclerViewAdapter
13+
import com.simplemobiletools.commons.extensions.getProperPrimaryColor
1314
import com.simplemobiletools.commons.helpers.ensureBackgroundThread
1415
import com.simplemobiletools.commons.views.MyRecyclerView
1516
import com.simplemobiletools.musicplayer.activities.SimpleControllerActivity
@@ -159,6 +160,14 @@ abstract class BaseMusicAdapter<Type>(
159160
}
160161
}
161162

163+
fun updateColors(newTextColor: Int) {
164+
if (textColor != newTextColor || properPrimaryColor != context.getProperPrimaryColor()) {
165+
updateTextColor(newTextColor)
166+
updatePrimaryColor()
167+
notifyDataChanged()
168+
}
169+
}
170+
162171
@SuppressLint("NotifyDataSetChanged")
163172
fun notifyDataChanged() = if (itemCount == 0) {
164173
notifyDataSetChanged()

app/src/main/kotlin/com/simplemobiletools/musicplayer/extensions/LottieAnimationView.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ fun LottieAnimationView.updatePlayPauseIcon(isPlaying: Boolean, color: Int) {
1717
playAnimation()
1818
}
1919

20-
addValueCallback(
21-
KeyPath("**"),
22-
LottieProperty.COLOR_FILTER,
23-
{ PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN) }
24-
)
2520
tag = isPlaying
2621
}
22+
23+
addValueCallback(
24+
KeyPath("**"),
25+
LottieProperty.COLOR_FILTER
26+
) { PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN) }
2727
}

app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/AlbumsFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ class AlbumsFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
101101
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
102102
binding.albumsPlaceholder.setTextColor(textColor)
103103
binding.albumsFastscroller.updateColors(adjustedPrimaryColor)
104+
getAdapter()?.updateColors(textColor)
104105
}
105106

106107
private fun getAdapter() = binding.albumsList.adapter as? AlbumsAdapter

app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/ArtistsFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class ArtistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
100100
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
101101
binding.artistsPlaceholder.setTextColor(textColor)
102102
binding.artistsFastscroller.updateColors(adjustedPrimaryColor)
103+
getAdapter()?.updateColors(textColor)
103104
}
104105

105106
private fun getAdapter() = binding.artistsList.adapter as? ArtistsAdapter

app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/FoldersFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class FoldersFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
9797
binding.foldersPlaceholder.setTextColor(textColor)
9898
binding.foldersFastscroller.updateColors(adjustedPrimaryColor)
9999
binding.foldersPlaceholder2.setTextColor(adjustedPrimaryColor)
100+
getAdapter()?.updateColors(textColor)
100101
}
101102

102103
private fun getAdapter() = binding.foldersList.adapter as? FoldersAdapter

app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/GenresFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ class GenresFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
100100
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
101101
binding.genresPlaceholder.setTextColor(textColor)
102102
binding.genresFastscroller.updateColors(adjustedPrimaryColor)
103+
getAdapter()?.updateColors(textColor)
103104
}
104105

105106
private fun getAdapter() = binding.genresList.adapter as? GenresAdapter

app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/PlaylistsFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class PlaylistsFragment(context: Context, attributeSet: AttributeSet) : MyViewPa
107107
binding.playlistsPlaceholder.setTextColor(textColor)
108108
binding.playlistsPlaceholder2.setTextColor(adjustedPrimaryColor)
109109
binding.playlistsFastscroller.updateColors(adjustedPrimaryColor)
110+
getAdapter()?.updateColors(textColor)
110111
}
111112

112113
private fun getAdapter() = binding.playlistsList.adapter as? PlaylistsAdapter

app/src/main/kotlin/com/simplemobiletools/musicplayer/fragments/TracksFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class TracksFragment(context: Context, attributeSet: AttributeSet) : MyViewPager
107107
override fun setupColors(textColor: Int, adjustedPrimaryColor: Int) {
108108
binding.tracksPlaceholder.setTextColor(textColor)
109109
binding.tracksFastscroller.updateColors(adjustedPrimaryColor)
110+
getAdapter()?.updateColors(textColor)
110111
}
111112

112113
private fun getAdapter() = binding.tracksList.adapter as? TracksAdapter

0 commit comments

Comments
 (0)