Skip to content
Snippets Groups Projects
Verified Commit b29179f8 authored by Janne Mareike Koschinski's avatar Janne Mareike Koschinski
Browse files

Attempt at fixing lifecycle issues

parent c3fe67f4
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -37,13 +37,10 @@ class BackendServiceConnection : ServiceConnection { ...@@ -37,13 +37,10 @@ class BackendServiceConnection : ServiceConnection {
private var bound: Boolean = false private var bound: Boolean = false
private var binding: Boolean = false
override fun onServiceDisconnected(component: ComponentName?) { override fun onServiceDisconnected(component: ComponentName?) {
when (component) { when (component) {
ComponentName(context, QuasselService::class.java) -> { ComponentName(context, QuasselService::class.java) -> {
bound = false bound = false
binding = false
backend.onNext(Optional.empty()) backend.onNext(Optional.empty())
} }
} }
...@@ -54,7 +51,6 @@ class BackendServiceConnection : ServiceConnection { ...@@ -54,7 +51,6 @@ class BackendServiceConnection : ServiceConnection {
ComponentName(context, QuasselService::class.java) -> ComponentName(context, QuasselService::class.java) ->
if (binder is QuasselBinder) { if (binder is QuasselBinder) {
bound = true bound = true
binding = false
backend.onNext(Optional.of(binder.backend)) backend.onNext(Optional.of(binder.backend))
} }
} }
...@@ -66,11 +62,8 @@ class BackendServiceConnection : ServiceConnection { ...@@ -66,11 +62,8 @@ class BackendServiceConnection : ServiceConnection {
@Synchronized @Synchronized
fun bind(intent: Intent = QuasselService.intent(context!!), flags: Int = 0) { fun bind(intent: Intent = QuasselService.intent(context!!), flags: Int = 0) {
if (!this.bound && !this.binding) {
this.binding = true
context?.bindService(intent, this, flags) context?.bindService(intent, this, flags)
} }
}
fun stop(intent: Intent = QuasselService.intent(context!!)) { fun stop(intent: Intent = QuasselService.intent(context!!)) {
context?.stopService(intent) context?.stopService(intent)
...@@ -78,9 +71,6 @@ class BackendServiceConnection : ServiceConnection { ...@@ -78,9 +71,6 @@ class BackendServiceConnection : ServiceConnection {
@Synchronized @Synchronized
fun unbind() { fun unbind() {
if (this.bound && !this.binding) { if (bound) context?.unbindService(this)
this.binding = true
context?.unbindService(this)
}
} }
} }
...@@ -124,9 +124,7 @@ abstract class ServiceBoundActivity : ThemedActivity(), ...@@ -124,9 +124,7 @@ abstract class ServiceBoundActivity : ThemedActivity(),
getBoolean(Keys.Status.reconnect, false) getBoolean(Keys.Status.reconnect, false)
} }
val accountIdValid = accountId != -1L val accountIdValid = accountId != -1L
if (!reconnect || !accountIdValid) { if (!reconnect || !accountIdValid) {
if (!startedSelection) { if (!startedSelection) {
startActivityForResult(AccountSelectionActivity.intent(this), REQUEST_SELECT_ACCOUNT) startActivityForResult(AccountSelectionActivity.intent(this), REQUEST_SELECT_ACCOUNT)
startedSelection = true startedSelection = true
...@@ -145,8 +143,6 @@ abstract class ServiceBoundActivity : ThemedActivity(), ...@@ -145,8 +143,6 @@ abstract class ServiceBoundActivity : ThemedActivity(),
if (resultCode == Activity.RESULT_CANCELED) { if (resultCode == Activity.RESULT_CANCELED) {
finish() finish()
} else {
checkConnection()
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment