Fix NetworkService connection issue.

- The NetworkServiceManager expects a call to onActivityResumed after it has been configured to start the connection with the NetworkManager. But because we are using a single activity architecture, the call to onActivityResumed the first time the app starts is called before configuring the NetworkServiceManager thus leaving the NetworkService disconnected until another onResume activity lifecycle event is received. A fake call to onActivityResumed in NetworkServiceManager was added right after it has been configured in BitsyApplication to address this issue.
master
Severiano Jaramillo 2019-08-26 11:44:08 -05:00
parent 765ed13a6a
commit 7603546424
1 changed files with 5 additions and 1 deletions

View File

@ -58,12 +58,16 @@ class BitsyApplication : Application() {
.setAutoConnect(autoConnect)
.setNodeLatencyVerification(true)
.build(this)
/*
* Registering this class as a listener to all activity's callback cycle events, in order to
* better estimate when the user has left the app and it is safe to disconnect the websocket connection
*/
registerActivityLifecycleCallbacks(networkManager)
// Fake call to onActivityResumed, because BiTSy is using a single activity and at the moment
// onActivityResumed is called the first time the app starts, the NetworkServiceManager has not
// been configured yet, thus causing the NetworkService to never connect.
networkManager.onActivityResumed(null)
}
override fun onTerminate() {