From 235f354089d3455d1873fa5604c96d782f1b3647 Mon Sep 17 00:00:00 2001 From: Karmanyaah Malhotra Date: Sat, 16 Dec 2023 22:53:17 -0600 Subject: [PATCH] clean --- app/src/main/java/io/heckel/ntfy/msg/ApiService.kt | 2 +- app/src/main/java/io/heckel/ntfy/msg/NotificationParser.kt | 2 +- app/src/main/java/io/heckel/ntfy/service/JsonConnection.kt | 2 -- app/src/main/java/io/heckel/ntfy/service/WsConnection.kt | 2 -- 4 files changed, 2 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt b/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt index 25385d6..31765c8 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/ApiService.kt @@ -96,7 +96,7 @@ class ApiService { val body = response.body?.string()?.trim() if (body.isNullOrEmpty()) return emptyList() val notifications = body.lines().mapNotNull { line -> - parser.parseNotification(line, subscriptionId = subscriptionId, notificationId = 0) // No notification when we poll + parser.parse(line, subscriptionId = subscriptionId, notificationId = 0) // No notification when we poll } Log.d(TAG, "Notifications: $notifications") diff --git a/app/src/main/java/io/heckel/ntfy/msg/NotificationParser.kt b/app/src/main/java/io/heckel/ntfy/msg/NotificationParser.kt index 84a4097..9368878 100644 --- a/app/src/main/java/io/heckel/ntfy/msg/NotificationParser.kt +++ b/app/src/main/java/io/heckel/ntfy/msg/NotificationParser.kt @@ -17,7 +17,7 @@ class NotificationParser { return gson.fromJson(s, Message::class.java) } - fun parseNotification(s: String, subscriptionId: Long = 0, notificationId: Int = 0): Notification? { + fun parse(s: String, subscriptionId: Long = 0, notificationId: Int = 0): Notification? { val message = parseMessage(s) ?: return null val notificationWithTopic = parseNotificationWithTopic(message, subscriptionId = subscriptionId, notificationId = notificationId) return notificationWithTopic?.notification diff --git a/app/src/main/java/io/heckel/ntfy/service/JsonConnection.kt b/app/src/main/java/io/heckel/ntfy/service/JsonConnection.kt index 4d3a951..6a7806e 100644 --- a/app/src/main/java/io/heckel/ntfy/service/JsonConnection.kt +++ b/app/src/main/java/io/heckel/ntfy/service/JsonConnection.kt @@ -4,12 +4,10 @@ import io.heckel.ntfy.db.* import io.heckel.ntfy.util.Log import io.heckel.ntfy.msg.ApiService import io.heckel.ntfy.msg.Message -import io.heckel.ntfy.msg.NotificationParser import io.heckel.ntfy.util.topicUrl import kotlinx.coroutines.* import okhttp3.Call import java.util.concurrent.atomic.AtomicBoolean -import kotlin.random.Random class JsonConnection( private val connectionId: ConnectionId, diff --git a/app/src/main/java/io/heckel/ntfy/service/WsConnection.kt b/app/src/main/java/io/heckel/ntfy/service/WsConnection.kt index 9827c6c..fac744d 100644 --- a/app/src/main/java/io/heckel/ntfy/service/WsConnection.kt +++ b/app/src/main/java/io/heckel/ntfy/service/WsConnection.kt @@ -5,7 +5,6 @@ import android.os.Build import android.os.Handler import android.os.Looper import io.heckel.ntfy.db.* -import io.heckel.ntfy.msg.ApiService import io.heckel.ntfy.msg.ApiService.Companion.requestBuilder import io.heckel.ntfy.msg.Message import io.heckel.ntfy.msg.NotificationParser @@ -20,7 +19,6 @@ import java.util.* import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicLong import java.util.concurrent.atomic.AtomicReference -import kotlin.random.Random /** * Connect to ntfy server via WebSockets. This connection represents a single connection to a server, with