Update items after appearance change #452

This commit is contained in:
J-Jamet
2020-03-10 08:58:22 +01:00
parent 0d7c479c51
commit 2cb85e4346
3 changed files with 13 additions and 1 deletions

View File

@@ -208,7 +208,14 @@ class ListNodesFragment : StylishFragment(), SortDialogFragment.SortSelectionLis
fun rebuildList() { fun rebuildList() {
// Add elements to the list // Add elements to the list
mainGroup?.let { mainGroup -> mainGroup?.let { mainGroup ->
mAdapter?.rebuildList(mainGroup) mAdapter?.apply {
rebuildList(mainGroup)
// To visually change the elements
if (PreferencesUtil.APPEARANCE_CHANGED) {
notifyDataSetChanged()
PreferencesUtil.APPEARANCE_CHANGED = false
}
}
} }
} }

View File

@@ -276,6 +276,9 @@ class NestedAppSettingsFragment : NestedSettingsFragment() {
private fun onCreateAppearancePreferences(rootKey: String?) { private fun onCreateAppearancePreferences(rootKey: String?) {
setPreferencesFromResource(R.xml.preferences_appearance, rootKey) setPreferencesFromResource(R.xml.preferences_appearance, rootKey)
// To change list items appearance
PreferencesUtil.APPEARANCE_CHANGED = true
activity?.let { activity -> activity?.let { activity ->
findPreference<ListPreference>(getString(R.string.setting_style_key))?.setOnPreferenceChangeListener { _, newValue -> findPreference<ListPreference>(getString(R.string.setting_style_key))?.setOnPreferenceChangeListener { _, newValue ->
var styleEnabled = true var styleEnabled = true

View File

@@ -29,6 +29,8 @@ import java.util.*
object PreferencesUtil { object PreferencesUtil {
var APPEARANCE_CHANGED = false
private const val KEY_DEFAULT_DATABASE_PATH = "KEY_DEFAULT_DATABASE_PATH" private const val KEY_DEFAULT_DATABASE_PATH = "KEY_DEFAULT_DATABASE_PATH"
fun saveDefaultDatabasePath(context: Context, defaultDatabaseUri: Uri?) { fun saveDefaultDatabasePath(context: Context, defaultDatabaseUri: Uri?) {