From 742136abe82ea7beb1ff6829633a6e494698aa1b Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 9 Dec 2019 18:01:58 +0100 Subject: [PATCH] Create RecyclerView extensions and cleanup all the recycler views --- .../debug/sas/DebugSasEmojiActivity.kt | 3 +- .../riotx/core/extensions/RecyclerView.kt | 32 +++++++++++++++++++ .../settings/KeysBackupSettingsFragment.kt | 3 +- .../CreateDirectRoomDirectoryUsersFragment.kt | 3 +- .../CreateDirectRoomKnownUsersFragment.kt | 3 +- .../features/home/group/GroupListFragment.kt | 3 +- .../room/breadcrumbs/BreadcrumbsFragment.kt | 3 +- .../home/room/detail/RoomDetailFragment.kt | 7 ++-- .../DisplayReadReceiptsBottomSheet.kt | 6 ++++ .../action/MessageActionsBottomSheet.kt | 6 ++++ .../edithistory/ViewEditHistoryBottomSheet.kt | 7 ++++ .../reactions/ViewReactionsBottomSheet.kt | 6 ++++ .../home/room/list/RoomListFragment.kt | 3 +- .../RoomListQuickActionsBottomSheet.kt | 6 ++++ .../login/terms/LoginTermsFragment.kt | 3 +- .../reactions/EmojiChooserFragment.kt | 6 ++++ .../reactions/EmojiChooserViewModel.kt | 1 + .../reactions/EmojiSearchResultFragment.kt | 3 +- .../roomdirectory/PublicRoomsFragment.kt | 3 +- .../createroom/CreateRoomFragment.kt | 3 +- .../picker/RoomDirectoryPickerFragment.kt | 3 +- ...ttingsNotificationsTroubleshootFragment.kt | 6 ++++ .../VectorSettingsIgnoredUsersFragment.kt | 3 +- .../settings/push/PushGatewaysFragment.kt | 3 +- .../settings/push/PushRulesFragment.kt | 3 +- 25 files changed, 108 insertions(+), 20 deletions(-) create mode 100644 vector/src/main/java/im/vector/riotx/core/extensions/RecyclerView.kt diff --git a/vector/src/debug/java/im/vector/riotx/features/debug/sas/DebugSasEmojiActivity.kt b/vector/src/debug/java/im/vector/riotx/features/debug/sas/DebugSasEmojiActivity.kt index 17a78f1c6a..89c31474b3 100644 --- a/vector/src/debug/java/im/vector/riotx/features/debug/sas/DebugSasEmojiActivity.kt +++ b/vector/src/debug/java/im/vector/riotx/features/debug/sas/DebugSasEmojiActivity.kt @@ -21,6 +21,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.recyclerview.widget.LinearLayoutManager import im.vector.matrix.android.api.crypto.getAllVerificationEmojis import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import kotlinx.android.synthetic.main.fragment_generic_recycler.* class DebugSasEmojiActivity : AppCompatActivity() { @@ -35,7 +36,7 @@ class DebugSasEmojiActivity : AppCompatActivity() { } override fun onDestroy() { - recyclerView.adapter = null + recyclerView.cleanup() super.onDestroy() } } diff --git a/vector/src/main/java/im/vector/riotx/core/extensions/RecyclerView.kt b/vector/src/main/java/im/vector/riotx/core/extensions/RecyclerView.kt new file mode 100644 index 0000000000..f844bf6c9a --- /dev/null +++ b/vector/src/main/java/im/vector/riotx/core/extensions/RecyclerView.kt @@ -0,0 +1,32 @@ +/* + * Copyright 2019 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package im.vector.riotx.core.extensions + +import android.content.Context +import androidx.recyclerview.widget.RecyclerView +import com.airbnb.epoxy.EpoxyController + +fun RecyclerView.configureWith(context: Context, controller: EpoxyController) { + +} + +/** + * To call from Fragment.onDestroyView() + */ +fun RecyclerView.cleanup() { + adapter = null +} diff --git a/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsFragment.kt b/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsFragment.kt index a00f71e5f8..7091bead4e 100644 --- a/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/crypto/keysbackup/settings/KeysBackupSettingsFragment.kt @@ -22,6 +22,7 @@ import androidx.recyclerview.widget.LinearLayoutManager import com.airbnb.mvrx.activityViewModel import com.airbnb.mvrx.withState import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.features.crypto.keysbackup.restore.KeysBackupRestoreActivity import im.vector.riotx.features.crypto.keysbackup.setup.KeysBackupSetupActivity @@ -45,7 +46,7 @@ class KeysBackupSettingsFragment @Inject constructor(private val keysBackupSetti override fun onDestroyView() { keysBackupSettingsRecyclerViewController.listener = null - keysBackupSettingsRecyclerView.adapter = null + keysBackupSettingsRecyclerView.cleanup() super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomDirectoryUsersFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomDirectoryUsersFragment.kt index 575940a376..ac2230eae3 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomDirectoryUsersFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomDirectoryUsersFragment.kt @@ -25,6 +25,7 @@ import com.airbnb.mvrx.withState import com.jakewharton.rxbinding3.widget.textChanges import im.vector.matrix.android.api.session.user.model.User import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.extensions.hideKeyboard import im.vector.riotx.core.extensions.setupAsSearch import im.vector.riotx.core.extensions.showKeyboard @@ -51,7 +52,7 @@ class CreateDirectRoomDirectoryUsersFragment @Inject constructor( } override fun onDestroyView() { - recyclerView.adapter = null + recyclerView.cleanup() directRoomController.callback = null super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomKnownUsersFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomKnownUsersFragment.kt index bad322292b..c333b6e09e 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomKnownUsersFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/createdirect/CreateDirectRoomKnownUsersFragment.kt @@ -32,6 +32,7 @@ import com.google.android.material.chip.ChipGroup import com.jakewharton.rxbinding3.widget.textChanges import im.vector.matrix.android.api.session.user.model.User import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.extensions.hideKeyboard import im.vector.riotx.core.extensions.observeEvent import im.vector.riotx.core.extensions.setupAsSearch @@ -70,7 +71,7 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor( override fun onDestroyView() { knownUsersController.callback = null - recyclerView.adapter = null + recyclerView.cleanup() super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/home/group/GroupListFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/group/GroupListFragment.kt index 5bc0c0f61d..312a66d1db 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/group/GroupListFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/group/GroupListFragment.kt @@ -25,6 +25,7 @@ import com.airbnb.mvrx.Success import com.airbnb.mvrx.fragmentViewModel import im.vector.matrix.android.api.session.group.model.GroupSummary import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.extensions.observeEvent import im.vector.riotx.core.platform.StateView import im.vector.riotx.core.platform.VectorBaseFragment @@ -58,7 +59,7 @@ class GroupListFragment @Inject constructor( override fun onDestroyView() { groupController.callback = null - groupListView.adapter = null + groupListView.cleanup() super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsFragment.kt index e57a2ddac4..713b69d454 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/breadcrumbs/BreadcrumbsFragment.kt @@ -21,6 +21,7 @@ import android.view.View import androidx.recyclerview.widget.LinearLayoutManager import com.airbnb.mvrx.fragmentViewModel import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.features.home.room.detail.RoomDetailSharedAction import im.vector.riotx.features.home.room.detail.RoomDetailSharedActionViewModel @@ -46,8 +47,8 @@ class BreadcrumbsFragment @Inject constructor( } override fun onDestroyView() { + breadcrumbsRecyclerView.cleanup() super.onDestroyView() - breadcrumbsRecyclerView.adapter = null } private fun setupRecyclerView() { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt index 0d869048fb..e1bb24eb8f 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomDetailFragment.kt @@ -70,10 +70,7 @@ import im.vector.riotx.R import im.vector.riotx.core.dialogs.withColoredButton import im.vector.riotx.core.epoxy.LayoutManagerStateRestorer import im.vector.riotx.core.error.ErrorFormatter -import im.vector.riotx.core.extensions.hideKeyboard -import im.vector.riotx.core.extensions.observeEvent -import im.vector.riotx.core.extensions.setTextOrHide -import im.vector.riotx.core.extensions.showKeyboard +import im.vector.riotx.core.extensions.* import im.vector.riotx.core.files.addEntryToDownloadManager import im.vector.riotx.core.glide.GlideApp import im.vector.riotx.core.platform.VectorBaseFragment @@ -293,7 +290,7 @@ class RoomDetailFragment @Inject constructor( timelineEventController.removeModelBuildListener(modelBuildListener) modelBuildListener = null debouncer.cancelAll() - recyclerView.adapter = null + recyclerView.cleanup() super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt index f220570e69..b098ce2638 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/readreceipts/DisplayReadReceiptsBottomSheet.kt @@ -29,6 +29,7 @@ import com.airbnb.mvrx.MvRx import com.airbnb.mvrx.args import im.vector.riotx.R import im.vector.riotx.core.di.ScreenComponent +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.riotx.features.home.room.detail.timeline.item.ReadReceiptData import kotlinx.android.parcel.Parcelize @@ -70,6 +71,11 @@ class DisplayReadReceiptsBottomSheet : VectorBaseBottomSheetDialogFragment() { epoxyController.setData(displayReadReceiptArgs.readReceipts) } + override fun onDestroyView() { + recyclerView.cleanup() + super.onDestroyView() + } + // we are not using state for this one as it's static, so no need to override invalidate() companion object { diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsBottomSheet.kt index a5bf6f8558..8046b996fc 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/action/MessageActionsBottomSheet.kt @@ -27,6 +27,7 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import im.vector.riotx.R import im.vector.riotx.core.di.ScreenComponent +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData import javax.inject.Inject @@ -68,6 +69,11 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message messageActionsEpoxyController.listener = this } + override fun onDestroyView() { + recyclerView.cleanup() + super.onDestroyView() + } + override fun onUrlClicked(url: String): Boolean { sharedActionViewModel.post(EventSharedAction.OnUrlClicked(url)) // Always consume diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/edithistory/ViewEditHistoryBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/edithistory/ViewEditHistoryBottomSheet.kt index 709bcb53c7..e28f42c078 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/edithistory/ViewEditHistoryBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/edithistory/ViewEditHistoryBottomSheet.kt @@ -30,6 +30,7 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import im.vector.riotx.R import im.vector.riotx.core.di.ScreenComponent +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.riotx.features.home.room.detail.timeline.action.TimelineEventFragmentArgs import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData @@ -73,6 +74,12 @@ class ViewEditHistoryBottomSheet : VectorBaseBottomSheetDialogFragment() { bottomSheetTitle.text = context?.getString(R.string.message_edits) } + override fun onDestroyView() { + recyclerView.cleanup() + super.onDestroyView() + } + + override fun invalidate() = withState(viewModel) { epoxyController.setData(it) super.invalidate() diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt index d5df8f7b40..d570a56242 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/reactions/ViewReactionsBottomSheet.kt @@ -29,6 +29,7 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import im.vector.riotx.R import im.vector.riotx.core.di.ScreenComponent +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.riotx.features.home.room.detail.timeline.action.TimelineEventFragmentArgs import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData @@ -66,6 +67,11 @@ class ViewReactionsBottomSheet : VectorBaseBottomSheetDialogFragment() { bottomSheetTitle.text = context?.getString(R.string.reactions) } + override fun onDestroyView() { + recyclerView.cleanup() + super.onDestroyView() + } + override fun invalidate() = withState(viewModel) { epoxyController.setData(it) super.invalidate() diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListFragment.kt b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListFragment.kt index 334f8b3417..00d964b28c 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/list/RoomListFragment.kt @@ -36,6 +36,7 @@ import im.vector.matrix.android.api.session.room.notification.RoomNotificationSt import im.vector.riotx.R import im.vector.riotx.core.epoxy.LayoutManagerStateRestorer import im.vector.riotx.core.error.ErrorFormatter +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.OnBackPressed import im.vector.riotx.core.platform.StateView import im.vector.riotx.core.platform.VectorBaseFragment @@ -121,7 +122,7 @@ class RoomListFragment @Inject constructor( override fun onDestroyView() { roomController.removeModelBuildListener(modelBuildListener) modelBuildListener = null - roomListView.adapter = null + roomListView.cleanup() roomController.listener = null createChatFabMenu.listener = null super.onDestroyView() diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt b/vector/src/main/java/im/vector/riotx/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt index 3a85cf26fa..8dab44b7a8 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/list/actions/RoomListQuickActionsBottomSheet.kt @@ -29,6 +29,7 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import im.vector.riotx.R import im.vector.riotx.core.di.ScreenComponent +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.riotx.features.navigation.Navigator import kotlinx.android.parcel.Parcelize @@ -76,6 +77,11 @@ class RoomListQuickActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), R roomListActionsEpoxyController.listener = this } + override fun onDestroyView() { + recyclerView.cleanup() + super.onDestroyView() + } + override fun invalidate() = withState(viewModel) { roomListActionsEpoxyController.setData(it) super.invalidate() diff --git a/vector/src/main/java/im/vector/riotx/features/login/terms/LoginTermsFragment.kt b/vector/src/main/java/im/vector/riotx/features/login/terms/LoginTermsFragment.kt index b50e7cfdcd..1e0d80de24 100755 --- a/vector/src/main/java/im/vector/riotx/features/login/terms/LoginTermsFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/login/terms/LoginTermsFragment.kt @@ -25,6 +25,7 @@ import butterknife.OnClick import com.airbnb.mvrx.args import im.vector.riotx.R import im.vector.riotx.core.error.ErrorFormatter +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.utils.openUrlInExternalBrowser import im.vector.riotx.features.login.AbstractLoginFragment import im.vector.riotx.features.login.LoginAction @@ -72,7 +73,7 @@ class LoginTermsFragment @Inject constructor( } override fun onDestroyView() { - loginTermsPolicyList.adapter = null + loginTermsPolicyList.cleanup() policyController.listener = null super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiChooserFragment.kt b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiChooserFragment.kt index 5e705a70c2..c49bdcbf92 100644 --- a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiChooserFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiChooserFragment.kt @@ -19,6 +19,7 @@ import android.os.Bundle import android.view.View import androidx.recyclerview.widget.RecyclerView import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseFragment import javax.inject.Inject @@ -37,4 +38,9 @@ class EmojiChooserFragment @Inject constructor() : VectorBaseFragment() { it.adapter?.notifyDataSetChanged() } } + + override fun onDestroyView() { + (view as? RecyclerView)?.cleanup() + super.onDestroyView() + } } diff --git a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiChooserViewModel.kt b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiChooserViewModel.kt index bbde2ac54c..1979b02bfd 100644 --- a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiChooserViewModel.kt +++ b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiChooserViewModel.kt @@ -23,6 +23,7 @@ import javax.inject.Inject class EmojiChooserViewModel @Inject constructor() : ViewModel() { + // TODO Move the adapter out of the ViewModel var adapter: EmojiRecyclerAdapter? = null val emojiSourceLiveData: MutableLiveData = MutableLiveData() diff --git a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultFragment.kt b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultFragment.kt index bef8a65542..cf5b6aa211 100644 --- a/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/reactions/EmojiSearchResultFragment.kt @@ -23,6 +23,7 @@ import androidx.recyclerview.widget.RecyclerView import com.airbnb.mvrx.activityViewModel import com.airbnb.mvrx.withState import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.utils.LiveEvent import kotlinx.android.synthetic.main.fragment_generic_recycler.* @@ -58,7 +59,7 @@ class EmojiSearchResultFragment @Inject constructor( override fun onDestroyView() { epoxyController.listener = null - recyclerView.adapter = null + recyclerView.cleanup() super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt b/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt index 109364194d..f8d99d4b1c 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomdirectory/PublicRoomsFragment.kt @@ -28,6 +28,7 @@ import com.jakewharton.rxbinding3.appcompat.queryTextChanges import im.vector.matrix.android.api.session.room.model.roomdirectory.PublicRoom import im.vector.riotx.R import im.vector.riotx.core.error.ErrorFormatter +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.extensions.observeEvent import im.vector.riotx.core.platform.VectorBaseFragment import io.reactivex.rxkotlin.subscribeBy @@ -84,7 +85,7 @@ class PublicRoomsFragment @Inject constructor( override fun onDestroyView() { publicRoomsController.callback = null - publicRoomsList.adapter = null + publicRoomsList.cleanup() super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/roomdirectory/createroom/CreateRoomFragment.kt b/vector/src/main/java/im/vector/riotx/features/roomdirectory/createroom/CreateRoomFragment.kt index 95d9c198ee..507dd7c71d 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomdirectory/createroom/CreateRoomFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomdirectory/createroom/CreateRoomFragment.kt @@ -24,6 +24,7 @@ import com.airbnb.mvrx.Success import com.airbnb.mvrx.activityViewModel import com.airbnb.mvrx.withState import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.features.roomdirectory.RoomDirectorySharedAction import im.vector.riotx.features.roomdirectory.RoomDirectorySharedActionViewModel @@ -51,7 +52,7 @@ class CreateRoomFragment @Inject constructor(private val createRoomController: C } override fun onDestroyView() { - createRoomForm.adapter = null + createRoomForm.cleanup() createRoomController.listener = null super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/roomdirectory/picker/RoomDirectoryPickerFragment.kt b/vector/src/main/java/im/vector/riotx/features/roomdirectory/picker/RoomDirectoryPickerFragment.kt index cc56de7cd7..f1ca8a25cd 100644 --- a/vector/src/main/java/im/vector/riotx/features/roomdirectory/picker/RoomDirectoryPickerFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/roomdirectory/picker/RoomDirectoryPickerFragment.kt @@ -25,6 +25,7 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import im.vector.matrix.android.api.session.room.model.thirdparty.RoomDirectoryData import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.features.roomdirectory.RoomDirectoryAction import im.vector.riotx.features.roomdirectory.RoomDirectorySharedAction @@ -61,7 +62,7 @@ class RoomDirectoryPickerFragment @Inject constructor(val roomDirectoryPickerVie } override fun onDestroyView() { - roomDirectoryPickerList.adapter = null + roomDirectoryPickerList.cleanup() roomDirectoryPickerController.callback = null super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationsTroubleshootFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationsTroubleshootFragment.kt index 6f43114eb4..3f69b5880e 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationsTroubleshootFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/VectorSettingsNotificationsTroubleshootFragment.kt @@ -29,6 +29,7 @@ import androidx.recyclerview.widget.RecyclerView import androidx.transition.TransitionManager import butterknife.BindView import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.features.rageshake.BugReporter @@ -136,6 +137,11 @@ class VectorSettingsNotificationsTroubleshootFragment @Inject constructor( testManager?.runDiagnostic() } + override fun onDestroyView() { + mRecyclerView.cleanup() + super.onDestroyView() + } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { if (resultCode == Activity.RESULT_OK && requestCode == NotificationTroubleshootTestManager.REQ_CODE_FIX) { testManager?.retry() diff --git a/vector/src/main/java/im/vector/riotx/features/settings/ignored/VectorSettingsIgnoredUsersFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/ignored/VectorSettingsIgnoredUsersFragment.kt index de267047b9..3c48336620 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/ignored/VectorSettingsIgnoredUsersFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/ignored/VectorSettingsIgnoredUsersFragment.kt @@ -27,6 +27,7 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import im.vector.riotx.R import im.vector.riotx.core.error.ErrorFormatter +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.extensions.observeEvent import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.platform.VectorBaseFragment @@ -59,7 +60,7 @@ class VectorSettingsIgnoredUsersFragment @Inject constructor( override fun onDestroyView() { ignoredUsersController.callback = null - recyclerView.adapter = null + recyclerView.cleanup() super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/push/PushGatewaysFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/push/PushGatewaysFragment.kt index e35ec6b5ff..e76b7cbc85 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/push/PushGatewaysFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/push/PushGatewaysFragment.kt @@ -25,6 +25,7 @@ import com.airbnb.epoxy.TypedEpoxyController import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.resources.StringProvider @@ -58,7 +59,7 @@ class PushGatewaysFragment @Inject constructor( } override fun onDestroyView() { - recyclerView.adapter = null + recyclerView.cleanup() super.onDestroyView() } diff --git a/vector/src/main/java/im/vector/riotx/features/settings/push/PushRulesFragment.kt b/vector/src/main/java/im/vector/riotx/features/settings/push/PushRulesFragment.kt index 52a5928e5d..7d5dd74a80 100644 --- a/vector/src/main/java/im/vector/riotx/features/settings/push/PushRulesFragment.kt +++ b/vector/src/main/java/im/vector/riotx/features/settings/push/PushRulesFragment.kt @@ -24,6 +24,7 @@ import com.airbnb.epoxy.TypedEpoxyController import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import im.vector.riotx.R +import im.vector.riotx.core.extensions.cleanup import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.resources.StringProvider @@ -55,7 +56,7 @@ class PushRulesFragment : VectorBaseFragment() { } override fun onDestroyView() { - recyclerView.adapter = null + recyclerView.cleanup() super.onDestroyView() }