From f0aa34774e0b4fa35e0949472bfd97edd0926ab2 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 9 Dec 2019 21:31:04 +0100 Subject: [PATCH] Create RecyclerView extensions and cleanup all the recycler views --- .../features/debug/sas/DebugSasEmojiActivity.kt | 6 +++--- .../vector/riotx/core/extensions/RecyclerView.kt | 16 +++++++++++++--- .../settings/KeysBackupSettingsFragment.kt | 5 ++--- .../CreateDirectRoomDirectoryUsersFragment.kt | 11 ++--------- .../CreateDirectRoomKnownUsersFragment.kt | 10 ++-------- .../features/home/group/GroupListFragment.kt | 8 +++----- .../home/room/breadcrumbs/BreadcrumbsFragment.kt | 7 ++----- .../DisplayReadReceiptsBottomSheet.kt | 5 ++--- .../detail/timeline/TimelineEventController.kt | 1 - .../timeline/action/MessageActionsBottomSheet.kt | 8 ++++---- .../edithistory/ViewEditHistoryBottomSheet.kt | 12 +++++------- .../helper/ContentUploadStateTrackerBinder.kt | 1 - .../reactions/ViewReactionsBottomSheet.kt | 5 ++--- .../actions/RoomListQuickActionsBottomSheet.kt | 5 ++--- .../features/login/terms/LoginTermsFragment.kt | 6 ++---- .../reactions/EmojiSearchResultFragment.kt | 9 ++------- .../roomdirectory/PublicRoomsFragment.kt | 5 ++--- .../createroom/CreateRoomFragment.kt | 6 ++---- .../picker/RoomDirectoryPickerFragment.kt | 6 ++---- .../VectorSettingsIgnoredUsersFragment.kt | 5 ++--- .../settings/push/PushGatewaysFragment.kt | 11 +++-------- .../features/settings/push/PushRulesFragment.kt | 10 ++-------- .../src/main/res/layout/fragment_breadcrumbs.xml | 2 +- 23 files changed, 60 insertions(+), 100 deletions(-) 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 89c31474b3..acca04d09f 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 @@ -18,10 +18,10 @@ package im.vector.riotx.features.debug.sas import android.os.Bundle 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 im.vector.riotx.core.extensions.configureWith import kotlinx.android.synthetic.main.fragment_generic_recycler.* class DebugSasEmojiActivity : AppCompatActivity() { @@ -29,9 +29,9 @@ class DebugSasEmojiActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.fragment_generic_recycler) + // TODO Inject val controller = SasEmojiController() - recyclerView.adapter = controller.adapter - recyclerView.layoutManager = LinearLayoutManager(this) + recyclerView.configureWith(controller) controller.setData(SasState(getAllVerificationEmojis())) } 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 index f844bf6c9a..b34edc0e89 100644 --- a/vector/src/main/java/im/vector/riotx/core/extensions/RecyclerView.kt +++ b/vector/src/main/java/im/vector/riotx/core/extensions/RecyclerView.kt @@ -16,12 +16,22 @@ package im.vector.riotx.core.extensions -import android.content.Context +import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.airbnb.epoxy.EpoxyController -fun RecyclerView.configureWith(context: Context, controller: EpoxyController) { - +/** + * Apply a Vertical LinearLayout Manager to the recyclerView and set the adapter from the epoxy controller + */ +fun RecyclerView.configureWith(epoxyController: EpoxyController, + itemAnimator: RecyclerView.ItemAnimator? = null, + itemDecoration: RecyclerView.ItemDecoration? = null, + hasFixedSize: Boolean = true) { + layoutManager = LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) + itemAnimator?.let { this.itemAnimator = it } + itemDecoration?.let { addItemDecoration(it) } + setHasFixedSize(hasFixedSize) + adapter = epoxyController.adapter } /** 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 7091bead4e..f0997de372 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 @@ -18,11 +18,11 @@ package im.vector.riotx.features.crypto.keysbackup.settings import android.os.Bundle import android.view.View import androidx.appcompat.app.AlertDialog -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.extensions.configureWith 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 @@ -39,8 +39,7 @@ class KeysBackupSettingsFragment @Inject constructor(private val keysBackupSetti override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - keysBackupSettingsRecyclerView.layoutManager = LinearLayoutManager(requireContext()) - keysBackupSettingsRecyclerView.adapter = keysBackupSettingsRecyclerViewController.adapter + keysBackupSettingsRecyclerView.configureWith(keysBackupSettingsRecyclerViewController) keysBackupSettingsRecyclerViewController.listener = this } 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 ac2230eae3..4230ea030d 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 @@ -18,17 +18,12 @@ package im.vector.riotx.features.home.createdirect import android.os.Bundle import android.view.View -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView import com.airbnb.mvrx.activityViewModel 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 +import im.vector.riotx.core.extensions.* import im.vector.riotx.core.platform.VectorBaseFragment import kotlinx.android.synthetic.main.fragment_create_direct_room_directory_users.* import javax.inject.Inject @@ -58,10 +53,8 @@ class CreateDirectRoomDirectoryUsersFragment @Inject constructor( } private fun setupRecyclerView() { - recyclerView.setHasFixedSize(true) directRoomController.callback = this - recyclerView.layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false) - recyclerView.adapter = directRoomController.adapter + recyclerView.configureWith(directRoomController) } private fun setupSearchByMatrixIdView() { 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 c333b6e09e..8108e9705c 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 @@ -24,7 +24,6 @@ import android.view.MenuItem import android.view.View import android.widget.ScrollView import androidx.core.view.size -import androidx.recyclerview.widget.LinearLayoutManager import com.airbnb.mvrx.activityViewModel import com.airbnb.mvrx.withState import com.google.android.material.chip.Chip @@ -32,10 +31,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 +import im.vector.riotx.core.extensions.* import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.utils.DimensionConverter import kotlinx.android.synthetic.main.fragment_create_direct_room.* @@ -102,12 +98,10 @@ class CreateDirectRoomKnownUsersFragment @Inject constructor( } private fun setupRecyclerView() { - recyclerView.setHasFixedSize(true) // Don't activate animation as we might have way to much item animation when filtering recyclerView.itemAnimator = null knownUsersController.callback = this - recyclerView.layoutManager = LinearLayoutManager(requireContext()) - recyclerView.adapter = knownUsersController.adapter + recyclerView.configureWith(knownUsersController) } private fun setupFilterView() { 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 312a66d1db..254571f8cf 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 @@ -18,19 +18,18 @@ package im.vector.riotx.features.home.group import android.os.Bundle import android.view.View -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView import com.airbnb.mvrx.Incomplete 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.configureWith import im.vector.riotx.core.extensions.observeEvent import im.vector.riotx.core.platform.StateView import im.vector.riotx.core.platform.VectorBaseFragment -import im.vector.riotx.features.home.HomeSharedActionViewModel import im.vector.riotx.features.home.HomeActivitySharedAction +import im.vector.riotx.features.home.HomeSharedActionViewModel import kotlinx.android.synthetic.main.fragment_group_list.* import javax.inject.Inject @@ -49,8 +48,7 @@ class GroupListFragment @Inject constructor( sharedActionViewModel = activityViewModelProvider.get(HomeSharedActionViewModel::class.java) groupController.callback = this stateView.contentView = groupListView - groupListView.layoutManager = LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false) - groupListView.adapter = groupController.adapter + groupListView.configureWith(groupController) viewModel.subscribe { renderState(it) } viewModel.openGroupLiveData.observeEvent(this) { sharedActionViewModel.post(HomeActivitySharedAction.OpenGroup) 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 713b69d454..b8e2cf7987 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 @@ -18,10 +18,10 @@ package im.vector.riotx.features.home.room.breadcrumbs import android.os.Bundle 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.extensions.configureWith 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 @@ -52,11 +52,8 @@ class BreadcrumbsFragment @Inject constructor( } private fun setupRecyclerView() { - val layoutManager = LinearLayoutManager(context) - breadcrumbsRecyclerView.layoutManager = layoutManager - breadcrumbsRecyclerView.itemAnimator = BreadcrumbsAnimator() + breadcrumbsRecyclerView.configureWith(breadcrumbsController, BreadcrumbsAnimator(), hasFixedSize = false) breadcrumbsController.listener = this - breadcrumbsRecyclerView.setController(breadcrumbsController) } private fun renderState(state: BreadcrumbsViewState) { 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 b098ce2638..f943556bcd 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 @@ -21,7 +21,6 @@ import android.os.Parcelable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import butterknife.BindView import butterknife.ButterKnife @@ -30,6 +29,7 @@ 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.extensions.configureWith import im.vector.riotx.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.riotx.features.home.room.detail.timeline.item.ReadReceiptData import kotlinx.android.parcel.Parcelize @@ -65,8 +65,7 @@ class DisplayReadReceiptsBottomSheet : VectorBaseBottomSheetDialogFragment() { override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) - recyclerView.layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false) - recyclerView.adapter = epoxyController.adapter + recyclerView.configureWith(epoxyController, hasFixedSize = false) bottomSheetTitle.text = getString(R.string.seen_by) epoxyController.setData(displayReadReceiptArgs.readReceipts) } diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/TimelineEventController.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/TimelineEventController.kt index 83f9163496..576b9fa0ba 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/TimelineEventController.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/TimelineEventController.kt @@ -25,7 +25,6 @@ import androidx.recyclerview.widget.RecyclerView import com.airbnb.epoxy.EpoxyController import com.airbnb.epoxy.EpoxyModel import com.airbnb.epoxy.VisibilityState -import im.vector.matrix.android.api.session.Session import im.vector.matrix.android.api.session.room.model.message.* import im.vector.matrix.android.api.session.room.timeline.Timeline import im.vector.matrix.android.api.session.room.timeline.TimelineEvent 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 8046b996fc..23729734cb 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 @@ -19,7 +19,6 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import butterknife.BindView import butterknife.ButterKnife @@ -28,8 +27,10 @@ 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.extensions.configureWith import im.vector.riotx.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.riotx.features.home.room.detail.timeline.item.MessageInformationData +import kotlinx.android.synthetic.main.activity_image_media_viewer.* import javax.inject.Inject /** @@ -62,8 +63,7 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) sharedActionViewModel = activityViewModelProvider.get(MessageSharedActionViewModel::class.java) - recyclerView.layoutManager = LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false) - recyclerView.adapter = messageActionsEpoxyController.adapter + recyclerView.configureWith(messageActionsEpoxyController, hasFixedSize = false) // Disable item animation recyclerView.itemAnimator = null messageActionsEpoxyController.listener = this @@ -88,7 +88,7 @@ class MessageActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), Message override fun didSelectMenuAction(eventAction: EventSharedAction) { if (eventAction is EventSharedAction.ReportContent) { - // Toggle report menu + // Toggle report menu // TODO Reanable item animation? viewModel.handle(MessageActionsAction.ToggleReportMenu) } else { sharedActionViewModel.post(eventAction) 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 e28f42c078..e8ee6ce10e 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 @@ -19,9 +19,7 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import android.widget.LinearLayout import androidx.recyclerview.widget.DividerItemDecoration -import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import butterknife.BindView import butterknife.ButterKnife @@ -31,6 +29,7 @@ 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.extensions.configureWith 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 @@ -67,10 +66,10 @@ class ViewEditHistoryBottomSheet : VectorBaseBottomSheetDialogFragment() { override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) - recyclerView.adapter = epoxyController.adapter - recyclerView.layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false) - val dividerItemDecoration = DividerItemDecoration(requireContext(), LinearLayout.VERTICAL) - recyclerView.addItemDecoration(dividerItemDecoration) + recyclerView.configureWith( + epoxyController, + itemDecoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL), + hasFixedSize = false) bottomSheetTitle.text = context?.getString(R.string.message_edits) } @@ -79,7 +78,6 @@ class ViewEditHistoryBottomSheet : VectorBaseBottomSheetDialogFragment() { 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/helper/ContentUploadStateTrackerBinder.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/ContentUploadStateTrackerBinder.kt index bbc3474e1e..d80c625e8f 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/ContentUploadStateTrackerBinder.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/helper/ContentUploadStateTrackerBinder.kt @@ -64,7 +64,6 @@ class ContentUploadStateTrackerBinder @Inject constructor(private val activeSess it.contentUploadProgressTracker().clear() } } - } private class ContentMediaProgressUpdater(private val progressLayout: ViewGroup, 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 d570a56242..9ece3e2bbd 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 @@ -20,7 +20,6 @@ import android.os.Bundle import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import butterknife.BindView import butterknife.ButterKnife @@ -30,6 +29,7 @@ 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.extensions.configureWith 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 @@ -62,8 +62,7 @@ class ViewReactionsBottomSheet : VectorBaseBottomSheetDialogFragment() { override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) - recyclerView.layoutManager = LinearLayoutManager(context, RecyclerView.VERTICAL, false) - recyclerView.adapter = epoxyController.adapter + recyclerView.configureWith(epoxyController, hasFixedSize = false) bottomSheetTitle.text = context?.getString(R.string.reactions) } 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 8dab44b7a8..28656e1d6e 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 @@ -21,7 +21,6 @@ import android.os.Parcelable import android.view.LayoutInflater import android.view.View import android.view.ViewGroup -import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import butterknife.BindView import butterknife.ButterKnife @@ -30,6 +29,7 @@ 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.extensions.configureWith import im.vector.riotx.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.riotx.features.navigation.Navigator import kotlinx.android.parcel.Parcelize @@ -70,8 +70,7 @@ class RoomListQuickActionsBottomSheet : VectorBaseBottomSheetDialogFragment(), R override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState) sharedActionViewModel = activityViewModelProvider.get(RoomListQuickActionsSharedActionViewModel::class.java) - recyclerView.layoutManager = LinearLayoutManager(requireContext(), RecyclerView.VERTICAL, false) - recyclerView.adapter = roomListActionsEpoxyController.adapter + recyclerView.configureWith(roomListActionsEpoxyController, hasFixedSize = false) // Disable item animation recyclerView.itemAnimator = null roomListActionsEpoxyController.listener = this 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 1e0d80de24..83d68f5f31 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 @@ -20,12 +20,12 @@ import android.os.Bundle import android.os.Parcelable import android.view.View import androidx.appcompat.app.AlertDialog -import androidx.recyclerview.widget.LinearLayoutManager 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.extensions.configureWith import im.vector.riotx.core.utils.openUrlInExternalBrowser import im.vector.riotx.features.login.AbstractLoginFragment import im.vector.riotx.features.login.LoginAction @@ -57,9 +57,7 @@ class LoginTermsFragment @Inject constructor( override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - loginTermsPolicyList.setHasFixedSize(true) - loginTermsPolicyList.layoutManager = LinearLayoutManager(requireContext()) - loginTermsPolicyList.adapter = policyController.adapter + loginTermsPolicyList.configureWith(policyController) policyController.listener = this val list = ArrayList() 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 cf5b6aa211..976d5e984e 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 @@ -18,12 +18,11 @@ package im.vector.riotx.features.reactions import android.os.Bundle import android.view.View import androidx.recyclerview.widget.DividerItemDecoration -import androidx.recyclerview.widget.LinearLayoutManager -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.extensions.configureWith import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.utils.LiveEvent import kotlinx.android.synthetic.main.fragment_generic_recycler.* @@ -50,11 +49,7 @@ class EmojiSearchResultFragment @Inject constructor( } } - val lmgr = LinearLayoutManager(context, RecyclerView.VERTICAL, false) - recyclerView.layoutManager = lmgr - val dividerItemDecoration = DividerItemDecoration(recyclerView.context, lmgr.orientation) - recyclerView.addItemDecoration(dividerItemDecoration) - recyclerView.adapter = epoxyController.adapter + recyclerView.configureWith(epoxyController, itemDecoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL)) } override fun 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 f8d99d4b1c..1d8ed48b08 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 @@ -19,7 +19,6 @@ package im.vector.riotx.features.roomdirectory import android.os.Bundle import android.view.MenuItem import android.view.View -import androidx.recyclerview.widget.LinearLayoutManager import com.airbnb.epoxy.EpoxyVisibilityTracker import com.airbnb.mvrx.activityViewModel import com.airbnb.mvrx.withState @@ -29,6 +28,7 @@ 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.configureWith import im.vector.riotx.core.extensions.observeEvent import im.vector.riotx.core.platform.VectorBaseFragment import io.reactivex.rxkotlin.subscribeBy @@ -103,9 +103,8 @@ class PublicRoomsFragment @Inject constructor( private fun setupRecyclerView() { val epoxyVisibilityTracker = EpoxyVisibilityTracker() epoxyVisibilityTracker.attach(publicRoomsList) - publicRoomsList.layoutManager = LinearLayoutManager(context) + publicRoomsList.configureWith(publicRoomsController) publicRoomsController.callback = this - publicRoomsList.adapter = publicRoomsController.adapter } override fun onPublicRoomClicked(publicRoom: PublicRoom, joinState: JoinState) { 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 507dd7c71d..aacc21916a 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 @@ -19,12 +19,12 @@ package im.vector.riotx.features.roomdirectory.createroom import android.os.Bundle import android.view.MenuItem import android.view.View -import androidx.recyclerview.widget.LinearLayoutManager 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.extensions.configureWith import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.features.roomdirectory.RoomDirectorySharedAction import im.vector.riotx.features.roomdirectory.RoomDirectorySharedActionViewModel @@ -69,10 +69,8 @@ class CreateRoomFragment @Inject constructor(private val createRoomController: C } private fun setupRecyclerView() { - val layoutManager = LinearLayoutManager(context) - createRoomForm.layoutManager = layoutManager + createRoomForm.configureWith(createRoomController) createRoomController.listener = this - createRoomForm.adapter = createRoomController.adapter } override fun onNameChange(newName: String) { 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 f1ca8a25cd..1299919d2b 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 @@ -19,13 +19,13 @@ package im.vector.riotx.features.roomdirectory.picker import android.os.Bundle import android.view.MenuItem import android.view.View -import androidx.recyclerview.widget.LinearLayoutManager import com.airbnb.mvrx.activityViewModel 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.extensions.configureWith import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.features.roomdirectory.RoomDirectoryAction import im.vector.riotx.features.roomdirectory.RoomDirectorySharedAction @@ -80,10 +80,8 @@ class RoomDirectoryPickerFragment @Inject constructor(val roomDirectoryPickerVie } private fun setupRecyclerView() { - val layoutManager = LinearLayoutManager(context) - roomDirectoryPickerList.layoutManager = layoutManager + roomDirectoryPickerList.configureWith(roomDirectoryPickerController) roomDirectoryPickerController.callback = this - roomDirectoryPickerList.adapter = roomDirectoryPickerController.adapter } override fun onRoomDirectoryClicked(roomDirectoryData: RoomDirectoryData) { 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 3c48336620..a6b8a5414f 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 @@ -20,7 +20,6 @@ import android.os.Bundle import android.view.View import androidx.appcompat.app.AlertDialog import androidx.core.view.isVisible -import androidx.recyclerview.widget.LinearLayoutManager import com.airbnb.mvrx.Async import com.airbnb.mvrx.Loading import com.airbnb.mvrx.fragmentViewModel @@ -28,6 +27,7 @@ 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.configureWith import im.vector.riotx.core.extensions.observeEvent import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.platform.VectorBaseFragment @@ -51,8 +51,7 @@ class VectorSettingsIgnoredUsersFragment @Inject constructor( waiting_view_status_text.setText(R.string.please_wait) waiting_view_status_text.isVisible = true ignoredUsersController.callback = this - recyclerView.layoutManager = LinearLayoutManager(requireContext()) - recyclerView.adapter = ignoredUsersController.adapter + recyclerView.configureWith(ignoredUsersController) ignoredUsersViewModel.requestErrorLiveData.observeEvent(this) { displayErrorDialog(it) } 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 e76b7cbc85..816e76c4c4 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 @@ -19,13 +19,12 @@ package im.vector.riotx.features.settings.push import android.os.Bundle import android.view.View import androidx.recyclerview.widget.DividerItemDecoration -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView 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.extensions.configureWith import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.resources.StringProvider @@ -50,12 +49,7 @@ class PushGatewaysFragment @Inject constructor( override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - val lmgr = LinearLayoutManager(context, RecyclerView.VERTICAL, false) - recyclerView.layoutManager = lmgr - val dividerItemDecoration = DividerItemDecoration(recyclerView.context, - lmgr.orientation) - recyclerView.addItemDecoration(dividerItemDecoration) - recyclerView.adapter = epoxyController.adapter + recyclerView.configureWith(epoxyController, itemDecoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL)) } override fun onDestroyView() { @@ -67,6 +61,7 @@ class PushGatewaysFragment @Inject constructor( epoxyController.setData(state) } + // TODO Move to a proper file class PushGateWayController(private val stringProvider: StringProvider) : TypedEpoxyController() { override fun buildModels(data: PushGatewayViewState?) { data?.pushGateways?.invoke()?.let { pushers -> 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 7d5dd74a80..62ac49e738 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 @@ -18,13 +18,12 @@ package im.vector.riotx.features.settings.push import android.os.Bundle import android.view.View import androidx.recyclerview.widget.DividerItemDecoration -import androidx.recyclerview.widget.LinearLayoutManager -import androidx.recyclerview.widget.RecyclerView 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.extensions.configureWith import im.vector.riotx.core.platform.VectorBaseActivity import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.resources.StringProvider @@ -47,12 +46,7 @@ class PushRulesFragment : VectorBaseFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - val lmgr = LinearLayoutManager(context, RecyclerView.VERTICAL, false) - recyclerView.layoutManager = lmgr - val dividerItemDecoration = DividerItemDecoration(recyclerView.context, - lmgr.orientation) - recyclerView.addItemDecoration(dividerItemDecoration) - recyclerView.adapter = epoxyController.adapter + recyclerView.configureWith(epoxyController, itemDecoration = DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL)) } override fun onDestroyView() { diff --git a/vector/src/main/res/layout/fragment_breadcrumbs.xml b/vector/src/main/res/layout/fragment_breadcrumbs.xml index 22cceadc03..5cdd2e964a 100644 --- a/vector/src/main/res/layout/fragment_breadcrumbs.xml +++ b/vector/src/main/res/layout/fragment_breadcrumbs.xml @@ -1,5 +1,5 @@ -