From 9004a81eedc5a241294cee060f5afdfbe2497171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Lenclud?= Date: Fri, 13 Oct 2023 19:12:48 +0200 Subject: [PATCH] Remove silly ping pong --- .../browser/lightning/browser/TabsManager.kt | 10 ---------- .../browser/activity/BrowserActivity.kt | 19 +++++++++++-------- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/acr/browser/lightning/browser/TabsManager.kt b/app/src/main/java/acr/browser/lightning/browser/TabsManager.kt index b78e3441c..5ae24f9d6 100644 --- a/app/src/main/java/acr/browser/lightning/browser/TabsManager.kt +++ b/app/src/main/java/acr/browser/lightning/browser/TabsManager.kt @@ -975,16 +975,6 @@ class TabsManager @Inject constructor( //logger.log(TAG,"After from main") } - /** - * Notify the presenter that a change occurred to the current tab. Currently doesn't do anything - * other than tell the view to notify the adapter about the change. - * - * @param tab the tab that changed, may be null. - */ - fun tabChangeOccurred(tab: WebPageTab?) = tab?.let { - iBrowserView.notifyTabViewChanged(tabsModel.indexOfTab(it)) - } - /** * Called when the foreground is changing. * diff --git a/app/src/main/java/acr/browser/lightning/browser/activity/BrowserActivity.kt b/app/src/main/java/acr/browser/lightning/browser/activity/BrowserActivity.kt index 3ebe55517..2a47d5d5c 100644 --- a/app/src/main/java/acr/browser/lightning/browser/activity/BrowserActivity.kt +++ b/app/src/main/java/acr/browser/lightning/browser/activity/BrowserActivity.kt @@ -2574,8 +2574,7 @@ abstract class BrowserActivity : ThemedBrowserActivity(), BrowserView, UIControl } // SL: Is this being called way too many times? - // TODO: This is completely silly all it does is calling [notifyTabViewChanged] - tabsManager.tabChangeOccurred(aTab) + doTabUpdate(aTab) // SL: Putting this here to update toolbar background color was a bad idea // That somehow freezes the WebView after switching between a few tabs on F(x)tec Pro1 at least (Android 9) //initializePreferences() @@ -2604,8 +2603,7 @@ abstract class BrowserActivity : ThemedBrowserActivity(), BrowserView, UIControl } // SL: Is this being called way too many times? - // TODO: This is completely silly all it does is calling [notifyTabViewChanged] - tabsManager.tabChangeOccurred(aTab) + doTabUpdate(aTab) // SL: Putting this here to update toolbar background color was a bad idea // That somehow freezes the WebView after switching between a few tabs on F(x)tec Pro1 at least (Android 9) //initializePreferences() @@ -2620,8 +2618,7 @@ abstract class BrowserActivity : ThemedBrowserActivity(), BrowserView, UIControl } // TODO: optimize for icon only update - // TODO: This is completely silly all it does is calling [notifyTabViewChanged] - tabsManager.tabChangeOccurred(aTab) + doTabUpdate(aTab) } /** @@ -2633,9 +2630,15 @@ abstract class BrowserActivity : ThemedBrowserActivity(), BrowserView, UIControl } // TODO: optimize for title only update - // TODO: This is completely silly all it does is calling [notifyTabViewChanged] - tabsManager.tabChangeOccurred(aTab) + doTabUpdate(aTab) + } + + /** + * + */ + private fun doTabUpdate(aTab: WebPageTab) { + notifyTabViewChanged(tabsManager.indexOfTab(aTab)) }