Better code

This commit is contained in:
Benoit Marty 2020-02-17 14:38:56 +01:00
parent 31d5578063
commit ca0cd9e97d
4 changed files with 6 additions and 3 deletions

View file

@ -263,6 +263,9 @@ abstract class VectorBaseFragment : BaseMvRxFragment(), HasScreenInjector {
} }
} }
// This should be provided by the framework
protected fun invalidateOptionsMenu() = requireActivity().invalidateOptionsMenu()
/* ========================================================================================== /* ==========================================================================================
* Common Dialogs * Common Dialogs
* ========================================================================================== */ * ========================================================================================== */

View file

@ -127,7 +127,7 @@ class AttachmentsPreviewFragment @Inject constructor(
} }
override fun invalidate() = withState(viewModel) { state -> override fun invalidate() = withState(viewModel) { state ->
requireActivity().invalidateOptionsMenu() invalidateOptionsMenu()
if (state.attachments.isEmpty()) { if (state.attachments.isEmpty()) {
requireActivity().setResult(RESULT_CANCELED) requireActivity().setResult(RESULT_CANCELED)
requireActivity().finish() requireActivity().finish()

View file

@ -149,7 +149,7 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor(
} }
private fun renderSelectedUsers(selectedUsers: Set<User>) { private fun renderSelectedUsers(selectedUsers: Set<User>) {
vectorBaseActivity.invalidateOptionsMenu() invalidateOptionsMenu()
if (selectedUsers.isNotEmpty() && chipGroup.size == 0) { if (selectedUsers.isNotEmpty() && chipGroup.size == 0) {
selectedUsers.forEach { addChipToGroup(it, chipGroup) } selectedUsers.forEach { addChipToGroup(it, chipGroup) }
} }

View file

@ -257,7 +257,7 @@ class RoomListFragment @Inject constructor(
val newValue = state.hasUnread val newValue = state.hasUnread
if (hasUnreadRooms != newValue) { if (hasUnreadRooms != newValue) {
hasUnreadRooms = newValue hasUnreadRooms = newValue
requireActivity().invalidateOptionsMenu() invalidateOptionsMenu()
} }
} }
else -> Unit else -> Unit