diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/activities/MainActivity.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/activities/MainActivity.kt index c9a1940..e134584 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/activities/MainActivity.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/activities/MainActivity.kt @@ -178,9 +178,10 @@ class MainActivity : AppCompatActivity() { .edit() .remove("PREF_CURRENT_ACCOUNT_STRING") .apply() - deleteDevice(this) - StartService.stopService() - FailureHandler.clearFails() + deleteDevice(this) { + StartService.stopService() + FailureHandler.clearFails() + } showStart() finish() startActivity(intent) diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/api/Api.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/api/Api.kt index d02e65a..7f4f78a 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/api/Api.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/api/Api.kt @@ -106,7 +106,7 @@ object Api { Log.d(TAG, "cSync done.") } - fun Context.apiDeleteDevice() { + fun Context.apiDeleteDevice(block: () -> Unit = {}) { val deviceId = getDeviceId(this) ?: return withApiProvider { apiProvider -> @@ -132,6 +132,7 @@ object Api { override fun onComplete() { removeUrl(this@apiDeleteDevice) + block() } }) removeDeviceId(this) diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/distributor/Distributor.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/distributor/Distributor.kt index 165baad..30ffe93 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/distributor/Distributor.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/distributor/Distributor.kt @@ -108,13 +108,13 @@ object Distributor { return TOKEN_NOK } - fun deleteDevice(context: Context) { + fun deleteDevice(context: Context, block: () -> Unit = {}) { val db = getDb(context) db.listTokens().forEach { sendUnregistered(context, it) db.unregisterApp(it) } - context.apiDeleteDevice() + context.apiDeleteDevice(block) } fun createApp(context: Context, appName: String, connectorToken: String, block: () -> Unit) {