From 95270c0e4420d3d098488e9900fb990c2dbc4338 Mon Sep 17 00:00:00 2001 From: sim Date: Thu, 31 Aug 2023 21:42:46 +0200 Subject: [PATCH] Lint --- .../distributor/nextpush/AppCompanion.kt | 2 +- .../distributor/nextpush/api/SSEListener.kt | 2 +- .../distributor/nextpush/services/FailureHandler.kt | 1 + .../nextpush/services/RestartNetworkCallback.kt | 13 ++++++++----- .../distributor/nextpush/utils/Notifications.kt | 10 +++++----- 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/AppCompanion.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/AppCompanion.kt index 5435ec1..793fce8 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/AppCompanion.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/AppCompanion.kt @@ -12,4 +12,4 @@ object AppCompanion { val bufferedResponseChecked = AtomicBoolean(false) val keepalive = AtomicInteger(900) var lastEventDate: Calendar? = null -} \ No newline at end of file +} diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/api/SSEListener.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/api/SSEListener.kt index f2631bc..2012197 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/api/SSEListener.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/api/SSEListener.kt @@ -31,7 +31,7 @@ class SSEListener(val context: Context) : EventSourceListener() { val timer: TimerTask? = if ( !AppCompanion.bufferedResponseChecked.get() && !AppCompanion.booting.getAndSet(false) - ) { + ) { Timer().schedule(45_000L /* 45secs */) { if (FailureHandler.newFail(context, eventSource)) { StartService.stopService() diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/services/FailureHandler.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/services/FailureHandler.kt index 5302181..d8f4c0e 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/services/FailureHandler.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/services/FailureHandler.kt @@ -15,6 +15,7 @@ object FailureHandler { private val ttlFails = AtomicInteger(0) private val nFails = AtomicInteger(0) private val nFailsBeforePing = AtomicInteger(0) + // This is the last eventSource opened private val eventSource: AtomicReference = AtomicReference(null) diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartNetworkCallback.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartNetworkCallback.kt index 295294b..dce33c2 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartNetworkCallback.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/services/RestartNetworkCallback.kt @@ -50,11 +50,14 @@ class RestartNetworkCallback(val context: Context) : ConnectivityManager.Network } ?: run { Log.d(TAG, "Registering new ConnectivityManager") try { - connectivityManager.set(( - context.getSystemService(Service.CONNECTIVITY_SERVICE) as ConnectivityManager - ).apply { - registerDefaultNetworkCallback(this@RestartNetworkCallback) - }) + connectivityManager.set( + ( + context.getSystemService(Service.CONNECTIVITY_SERVICE) + as ConnectivityManager + ).apply { + registerDefaultNetworkCallback(this@RestartNetworkCallback) + } + ) } catch (e: Exception) { e.printStackTrace() } diff --git a/app/src/main/java/org/unifiedpush/distributor/nextpush/utils/Notifications.kt b/app/src/main/java/org/unifiedpush/distributor/nextpush/utils/Notifications.kt index 2bc1d67..b5d8f7e 100644 --- a/app/src/main/java/org/unifiedpush/distributor/nextpush/utils/Notifications.kt +++ b/app/src/main/java/org/unifiedpush/distributor/nextpush/utils/Notifications.kt @@ -41,7 +41,7 @@ open class AppNotification( private val context: Context, private val notificationId: Int, private val notificationData: NotificationData, - private val channelData: ChannelData, + private val channelData: ChannelData ) { private fun createNotificationChannel() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { @@ -149,10 +149,10 @@ open class AppNotification( private val Context.warningChannelData: ChannelData get() = ChannelData( - "${this.getString(R.string.app_name)}.Warning", - "Warning", - NotificationManager.IMPORTANCE_HIGH, - this.getString(R.string.warning_notif_description) + "${this.getString(R.string.app_name)}.Warning", + "Warning", + NotificationManager.IMPORTANCE_HIGH, + this.getString(R.string.warning_notif_description) ) class DisconnectedNotification(context: Context) : AppNotification(