properly update some stuff if the primary color changes
This commit is contained in:
parent
1c96f5ced7
commit
87b722bac3
4 changed files with 37 additions and 9 deletions
|
@ -195,7 +195,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
|
|||
|
||||
private fun checkIfColorChanged() {
|
||||
if (getRecyclerAdapter().foregroundColor != config.primaryColor) {
|
||||
getRecyclerAdapter().foregroundColor = config.primaryColor
|
||||
getRecyclerAdapter().updatePrimaryColor(config.primaryColor)
|
||||
directories_fastscroller.updateHandleColor()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,11 +100,19 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
|
|||
title = if (mShowAll) resources.getString(R.string.all_folders) else dirName
|
||||
getMedia()
|
||||
handleZooming()
|
||||
checkIfColorChanged()
|
||||
} else {
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkIfColorChanged() {
|
||||
if (getRecyclerAdapter().foregroundColor != config.primaryColor) {
|
||||
getRecyclerAdapter().updatePrimaryColor(config.primaryColor)
|
||||
media_fastscroller.updateHandleColor()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initializeGallery() {
|
||||
if (isDirEmpty())
|
||||
return
|
||||
|
|
|
@ -68,16 +68,26 @@ class DirectoryAdapter(val activity: SimpleActivity, val dirs: MutableList<Direc
|
|||
actMode?.title = "$cnt / ${dirs.size}"
|
||||
}
|
||||
|
||||
fun updatePrimaryColor(color: Int) {
|
||||
foregroundColor = color
|
||||
(0..itemViews.size() - 1).mapNotNull { itemViews[it] }
|
||||
.forEach { setupItemViewForeground(it) }
|
||||
}
|
||||
|
||||
private fun setupItemViewForeground(itemView: View) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
(getProperView(itemView) as FrameLayout).foreground = foregroundColor.createSelector()
|
||||
else
|
||||
getProperView(itemView).foreground = foregroundColor.createSelector()
|
||||
}
|
||||
|
||||
val adapterListener = object : MyAdapterListener {
|
||||
override fun toggleItemSelectionAdapter(select: Boolean, position: Int) {
|
||||
toggleItemSelection(select, position)
|
||||
}
|
||||
|
||||
override fun setupItemForeground(itemView: View) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
(getProperView(itemView) as FrameLayout).foreground = foregroundColor.createSelector()
|
||||
else
|
||||
getProperView(itemView).foreground = foregroundColor.createSelector()
|
||||
setupItemViewForeground(itemView)
|
||||
}
|
||||
|
||||
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
||||
|
|
|
@ -64,16 +64,26 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
|
|||
actMode?.title = "$cnt / ${media.size}"
|
||||
}
|
||||
|
||||
fun updatePrimaryColor(color: Int) {
|
||||
foregroundColor = color
|
||||
(0..itemViews.size() - 1).mapNotNull { itemViews[it] }
|
||||
.forEach { setupItemViewForeground(it) }
|
||||
}
|
||||
|
||||
private fun setupItemViewForeground(itemView: View) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
(getProperView(itemView) as FrameLayout).foreground = foregroundColor.createSelector()
|
||||
else
|
||||
getProperView(itemView).foreground = foregroundColor.createSelector()
|
||||
}
|
||||
|
||||
val adapterListener = object : MyAdapterListener {
|
||||
override fun toggleItemSelectionAdapter(select: Boolean, position: Int) {
|
||||
toggleItemSelection(select, position)
|
||||
}
|
||||
|
||||
override fun setupItemForeground(itemView: View) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
|
||||
(getProperView(itemView) as FrameLayout).foreground = foregroundColor.createSelector()
|
||||
else
|
||||
getProperView(itemView).foreground = foregroundColor.createSelector()
|
||||
setupItemViewForeground(itemView)
|
||||
}
|
||||
|
||||
override fun getSelectedPositions(): HashSet<Int> = selectedPositions
|
||||
|
|
Loading…
Reference in a new issue