Fix restart service function
by cancelling the source with apiDestroy
This commit is contained in:
parent
e6002a04b8
commit
1aa727b6ef
|
@ -29,10 +29,13 @@ val delQueue = emptyList<String>().toMutableList()
|
||||||
private lateinit var mApi: ProviderApi
|
private lateinit var mApi: ProviderApi
|
||||||
private lateinit var nextcloudAPI: NextcloudAPI
|
private lateinit var nextcloudAPI: NextcloudAPI
|
||||||
private lateinit var factory: EventSource.Factory
|
private lateinit var factory: EventSource.Factory
|
||||||
|
private lateinit var source: EventSource
|
||||||
|
|
||||||
fun apiDestroy() {
|
fun apiDestroy() {
|
||||||
if (::nextcloudAPI.isInitialized)
|
if (::nextcloudAPI.isInitialized)
|
||||||
nextcloudAPI.stop()
|
nextcloudAPI.stop()
|
||||||
|
if (::source.isInitialized)
|
||||||
|
source.cancel()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun cApi(context: Context, callback: ()->Unit) {
|
private fun cApi(context: Context, callback: ()->Unit) {
|
||||||
|
@ -111,7 +114,7 @@ private fun cSync(context: Context, deviceId: String) {
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
factory = EventSources.createFactory(client)
|
factory = EventSources.createFactory(client)
|
||||||
factory.newEventSource(request, SSEListener(context))
|
source = factory.newEventSource(request, SSEListener(context))
|
||||||
Log.d(TAG, "cSync done.")
|
Log.d(TAG, "cSync done.")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue