2019-10-21 20:58:09 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
// This is example code for the 'Simplified Example' section of
|
|
|
|
// /docs/architecture-overview.md
|
|
|
|
class ContactsController(
|
|
|
|
private val store: ContactsStore,
|
2022-11-03 02:37:21 +00:00
|
|
|
private val navController: NavController,
|
2019-10-21 20:58:09 +00:00
|
|
|
) {
|
|
|
|
|
|
|
|
fun contactRenamed(contactId: Int, newName: String) {
|
|
|
|
store.dispatch(ContactsAction.ContactRenamed(contactId = contactId, newName = newName))
|
|
|
|
}
|
|
|
|
|
|
|
|
fun chatSelected(contactId: Int) {
|
|
|
|
// This is how we pass arguments between fragments using Google's navigation library.
|
|
|
|
// See https://developer.android.com/guide/navigation/navigation-getting-started
|
|
|
|
val directions = ContactsFragment.actionContactsFragmentToChatFragment(
|
2022-11-03 02:37:21 +00:00
|
|
|
contactId = contactId,
|
2019-10-21 20:58:09 +00:00
|
|
|
)
|
|
|
|
navController.nav(R.id.contactFragment, directions)
|
|
|
|
}
|
|
|
|
}
|