Skip to content

Commit 62024d7

Browse files
committed
Don't wait for connection if a fragment is displayed
1 parent 37a9030 commit 62024d7

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

app/src/main/kotlin/io/homeassistant/companion/android/webview/WebViewActivity.kt

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1705,18 +1705,22 @@ class WebViewActivity :
17051705
}
17061706

17071707
private fun waitForConnection() {
1708-
Handler(Looper.getMainLooper()).postDelayed(
1709-
{
1710-
if (
1711-
!isConnected &&
1712-
!loadedUrl.toHttpUrl().pathSegments.first().contains("api") &&
1713-
!loadedUrl.toHttpUrl().pathSegments.first().contains("local")
1714-
) {
1715-
showError(errorType = ErrorType.TIMEOUT_EXTERNAL_BUS)
1716-
}
1717-
},
1718-
CONNECTION_DELAY,
1719-
)
1708+
if (supportFragmentManager.backStackEntryCount > 0) {
1709+
Timber.i("Fragments ${supportFragmentManager.fragments} displayed, skipping connection wait")
1710+
} else {
1711+
Handler(Looper.getMainLooper()).postDelayed(
1712+
{
1713+
if (
1714+
!isConnected &&
1715+
!loadedUrl.toHttpUrl().pathSegments.first().contains("api") &&
1716+
!loadedUrl.toHttpUrl().pathSegments.first().contains("local")
1717+
) {
1718+
showError(errorType = ErrorType.TIMEOUT_EXTERNAL_BUS)
1719+
}
1720+
},
1721+
CONNECTION_DELAY,
1722+
)
1723+
}
17201724
}
17211725

17221726
override fun sendExternalBusMessage(message: ExternalBusMessage) {

0 commit comments

Comments
 (0)