properly update text color at list view, if it changes

This commit is contained in:
tibbi 2017-09-30 20:32:58 +02:00
parent 73bcad0f68
commit 3d674c65ba
4 changed files with 30 additions and 6 deletions

View file

@ -57,6 +57,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
private var mStoredAnimateGifs = true
private var mStoredCropThumbnails = true
private var mStoredScrollHorizontally = true
private var mStoredTextColor = 0
private var mLoadedInitialPhotos = false
private var mLatestMediaId = 0L
private var mLastMediaHandler = Handler()
@ -82,6 +83,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mStoredAnimateGifs = config.animateGifs
mStoredCropThumbnails = config.cropThumbnails
mStoredScrollHorizontally = config.scrollHorizontally
mStoredTextColor = config.textColor
storeStoragePaths()
checkWhatsNewDialog()
@ -134,13 +136,17 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
}
if (mStoredScrollHorizontally != config.scrollHorizontally) {
directories_grid.adapter?.let {
(it as DirectoryAdapter).scrollVertically = config.viewTypeFolders == VIEW_TYPE_LIST || !config.scrollHorizontally
it.notifyDataSetChanged()
(directories_grid.adapter as? DirectoryAdapter)?.apply {
scrollVertically = config.viewTypeFolders == VIEW_TYPE_LIST || !config.scrollHorizontally
notifyDataSetChanged()
}
setupScrollDirection()
}
if (mStoredTextColor != config.textColor) {
(directories_grid.adapter as? DirectoryAdapter)?.updateTextColor(config.textColor)
}
tryloadGallery()
invalidateOptionsMenu()
directories_empty_text_label.setTextColor(config.textColor)
@ -155,6 +161,7 @@ class MainActivity : SimpleActivity(), DirectoryAdapter.DirOperationsListener {
mStoredAnimateGifs = config.animateGifs
mStoredCropThumbnails = config.cropThumbnails
mStoredScrollHorizontally = config.scrollHorizontally
mStoredTextColor = config.textColor
directories_grid.listener = null
mLastMediaHandler.removeCallbacksAndMessages(null)
}

View file

@ -51,6 +51,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
private var mStoredAnimateGifs = true
private var mStoredCropThumbnails = true
private var mStoredScrollHorizontally = true
private var mStoredTextColor = 0
private var mLastDrawnHashCode = 0
private var mLatestMediaId = 0L
private var mLastMediaHandler = Handler()
@ -73,6 +74,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
mStoredAnimateGifs = config.animateGifs
mStoredCropThumbnails = config.cropThumbnails
mStoredScrollHorizontally = config.scrollHorizontally
mStoredTextColor = config.textColor
mShowAll = config.showAll
if (mShowAll)
supportActionBar?.setDisplayHomeAsUpEnabled(false)
@ -93,13 +95,17 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
}
if (mStoredScrollHorizontally != config.scrollHorizontally) {
media_grid.adapter?.let {
(it as MediaAdapter).scrollVertically = config.viewTypeFiles == VIEW_TYPE_LIST || !config.scrollHorizontally
it.notifyDataSetChanged()
(media_grid.adapter as? MediaAdapter)?.apply {
scrollVertically = config.viewTypeFiles == VIEW_TYPE_LIST || !config.scrollHorizontally
notifyDataSetChanged()
}
setupScrollDirection()
}
if (mStoredTextColor != config.textColor) {
(media_grid.adapter as? MediaAdapter)?.updateTextColor(config.textColor)
}
tryloadGallery()
invalidateOptionsMenu()
media_empty_text_label.setTextColor(config.textColor)
@ -113,6 +119,7 @@ class MediaActivity : SimpleActivity(), MediaAdapter.MediaOperationsListener {
mStoredAnimateGifs = config.animateGifs
mStoredCropThumbnails = config.cropThumbnails
mStoredScrollHorizontally = config.scrollHorizontally
mStoredTextColor = config.textColor
media_grid.listener = null
mLastMediaHandler.removeCallbacksAndMessages(null)
}

View file

@ -353,6 +353,11 @@ class DirectoryAdapter(val activity: SimpleActivity, var dirs: MutableList<Direc
notifyDataSetChanged()
}
fun updateTextColor(textColor: Int) {
this.textColor = textColor
notifyDataSetChanged()
}
fun selectItem(pos: Int) {
toggleItemSelection(true, pos)
}

View file

@ -273,6 +273,11 @@ class MediaAdapter(val activity: SimpleActivity, var media: MutableList<Medium>,
notifyDataSetChanged()
}
fun updateTextColor(textColor: Int) {
this.textColor = textColor
notifyDataSetChanged()
}
fun selectItem(pos: Int) {
toggleItemSelection(true, pos)
}