From 63e2bd3f9e4dd83c6403e8a160358d5b6807b8cb Mon Sep 17 00:00:00 2001 From: Codrut Topliceanu <60002907+codrut-topliceanu@users.noreply.github.com> Date: Thu, 12 Nov 2020 17:58:02 +0200 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/11376 - Reverse tabs list order (https://github.com/mozilla-mobile/fenix/pull/16245) --- .../org/mozilla/fenix/tabtray/TabTrayView.kt | 21 ++++--------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt index b55ae1fa73..f54055aaf2 100644 --- a/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt +++ b/app/src/main/java/org/mozilla/fenix/tabtray/TabTrayView.kt @@ -193,13 +193,11 @@ class TabTrayView( tabsAdapter.tabTrayInteractor = interactor tabsAdapter.onTabsUpdated = { if (view.context.settings().gridTabView) { - concatAdapter.addAdapter(collectionsButtonAdapter) concatAdapter.addAdapter(syncedTabsController.adapter) + concatAdapter.addAdapter(collectionsButtonAdapter) } else { - // Put the 'Add to collections' button after the tabs have loaded. - concatAdapter.addAdapter(0, collectionsButtonAdapter) - // Put the Synced Tabs adapter at the end. concatAdapter.addAdapter(syncedTabsController.adapter) + concatAdapter.addAdapter(collectionsButtonAdapter) } if (hasAccessibilityEnabled) { @@ -442,10 +440,7 @@ class TabTrayView( private fun setupListTabView() { view.tabsTray.apply { - layoutManager = LinearLayoutManager(container.context).apply { - reverseLayout = true - stackFromEnd = true - } + layoutManager = LinearLayoutManager(container.context) } } @@ -730,19 +725,11 @@ class TabTrayView( view.context.components.core.store.state.normalTabs } - val selectedBrowserTabIndex = if (sessionId != null) { + return if (sessionId != null) { tabs.indexOfFirst { it.id == sessionId } } else { tabs.indexOfFirst { it.id == view.context.components.core.store.state.selectedTabId } } - - // We offset the tab index by the number of items in the other adapters. - // We add the offset, because the layoutManager is initialized with `reverseLayout`. - return if (view.context.settings().listTabView) { - selectedBrowserTabIndex + collectionsButtonAdapter.itemCount + syncedTabsController.adapter.itemCount - } else { - selectedBrowserTabIndex - } } companion object {