properly refresh contacts when thumbnail visibility changes

This commit is contained in:
tibbi 2018-01-29 16:44:36 +01:00
parent fac521babd
commit 7bf74e9e70
2 changed files with 14 additions and 5 deletions

View File

@ -77,14 +77,15 @@ class MainActivity : SimpleActivity(), RefreshContactsListener {
return
}
if (storedShowContactThumbnails != config.showContactThumbnails) {
if (storedShowPhoneNumbers != config.showPhoneNumbers) {
restartActivity()
return
}
if (storedShowPhoneNumbers != config.showPhoneNumbers) {
restartActivity()
return
val configShowContactThumbnails = config.showContactThumbnails
if (storedShowContactThumbnails != configShowContactThumbnails) {
contacts_fragment.showContactThumbnailsChanged(configShowContactThumbnails)
favorites_fragment.showContactThumbnailsChanged(configShowContactThumbnails)
}
val configTextColor = config.textColor

View File

@ -24,7 +24,7 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
protected var activity: MainActivity? = null
private var lastHashCode = 0
private var contactsIgnoringSearch = ArrayList<Contact>()
lateinit private var config: Config
private lateinit var config: Config
var forceListRedraw = false
@ -144,11 +144,19 @@ abstract class MyViewPagerFragment(context: Context, attributeSet: AttributeSet)
(currAdapter as ContactsAdapter).apply {
startNameWithSurname = config.startNameWithSurname
showPhoneNumbers = config.showPhoneNumbers
showContactThumbnails = config.showContactThumbnails
updateItems(contacts)
}
}
}
fun showContactThumbnailsChanged(showThumbnails: Boolean) {
(fragment_list.adapter as? ContactsAdapter)?.apply {
showContactThumbnails = showThumbnails
notifyDataSetChanged()
}
}
fun onActivityResume() {
updateViewStuff()
}