mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-19 10:45:13 +01:00
Improve loading on rotation
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
e88b49b506
commit
d74bc116ba
@ -67,7 +67,6 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
|
|||||||
setHasOptionsMenu(true)
|
setHasOptionsMenu(true)
|
||||||
|
|
||||||
viewModel = viewModelProvider(factory).get(ContactsViewModel::class.java)
|
viewModel = viewModelProvider(factory).get(ContactsViewModel::class.java)
|
||||||
viewModel.conversationToken = bundle?.getString(BundleKeys.KEY_CONVERSATION_TOKEN)
|
|
||||||
val view = super.onCreateView(inflater, container)
|
val view = super.onCreateView(inflater, container)
|
||||||
|
|
||||||
// todo - change empty state magic
|
// todo - change empty state magic
|
||||||
@ -137,7 +136,7 @@ class ContactsView<T : Any>(private val bundle: Bundle? = null) : BaseView() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
viewModel.loadContacts()
|
viewModel.initialize(bundle?.getString(BundleKeys.KEY_CONVERSATION_TOKEN))
|
||||||
|
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,15 @@ class ContactsViewModel constructor(
|
|||||||
val contactsLiveData: MutableLiveData<List<Participant>> = MutableLiveData()
|
val contactsLiveData: MutableLiveData<List<Participant>> = MutableLiveData()
|
||||||
|
|
||||||
private var searchQuery: String? = null
|
private var searchQuery: String? = null
|
||||||
var conversationToken: String? = null
|
private var conversationToken: String? = null
|
||||||
|
private var initialized = false
|
||||||
|
|
||||||
|
fun initialize(conversationToken: String?) {
|
||||||
|
if (!initialized || conversationToken != this.conversationToken) {
|
||||||
|
this.conversationToken = conversationToken
|
||||||
|
loadContacts()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun setSearchQuery(query: String?) {
|
fun setSearchQuery(query: String?) {
|
||||||
searchQuery = query
|
searchQuery = query
|
||||||
@ -77,6 +85,13 @@ class ContactsViewModel constructor(
|
|||||||
it.displayName.toLowerCase()
|
it.displayName.toLowerCase()
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
val selectedUserIds = selectedParticipants.map { it.userId }
|
||||||
|
for (participant in sortedList) {
|
||||||
|
if (participant.userId in selectedUserIds) {
|
||||||
|
participant.selected = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
contactsLiveData.postValue(sortedList)
|
contactsLiveData.postValue(sortedList)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user