mirror of
https://github.com/binwiederhier/ntfy-android.git
synced 2024-06-14 08:34:33 +12:00
clean
This commit is contained in:
parent
eb1c8300ab
commit
235f354089
|
@ -96,7 +96,7 @@ class ApiService {
|
||||||
val body = response.body?.string()?.trim()
|
val body = response.body?.string()?.trim()
|
||||||
if (body.isNullOrEmpty()) return emptyList()
|
if (body.isNullOrEmpty()) return emptyList()
|
||||||
val notifications = body.lines().mapNotNull { line ->
|
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")
|
Log.d(TAG, "Notifications: $notifications")
|
||||||
|
|
|
@ -17,7 +17,7 @@ class NotificationParser {
|
||||||
return gson.fromJson(s, Message::class.java)
|
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 message = parseMessage(s) ?: return null
|
||||||
val notificationWithTopic = parseNotificationWithTopic(message, subscriptionId = subscriptionId, notificationId = notificationId)
|
val notificationWithTopic = parseNotificationWithTopic(message, subscriptionId = subscriptionId, notificationId = notificationId)
|
||||||
return notificationWithTopic?.notification
|
return notificationWithTopic?.notification
|
||||||
|
|
|
@ -4,12 +4,10 @@ import io.heckel.ntfy.db.*
|
||||||
import io.heckel.ntfy.util.Log
|
import io.heckel.ntfy.util.Log
|
||||||
import io.heckel.ntfy.msg.ApiService
|
import io.heckel.ntfy.msg.ApiService
|
||||||
import io.heckel.ntfy.msg.Message
|
import io.heckel.ntfy.msg.Message
|
||||||
import io.heckel.ntfy.msg.NotificationParser
|
|
||||||
import io.heckel.ntfy.util.topicUrl
|
import io.heckel.ntfy.util.topicUrl
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import okhttp3.Call
|
import okhttp3.Call
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
import kotlin.random.Random
|
|
||||||
|
|
||||||
class JsonConnection(
|
class JsonConnection(
|
||||||
private val connectionId: ConnectionId,
|
private val connectionId: ConnectionId,
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.os.Build
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
import android.os.Looper
|
import android.os.Looper
|
||||||
import io.heckel.ntfy.db.*
|
import io.heckel.ntfy.db.*
|
||||||
import io.heckel.ntfy.msg.ApiService
|
|
||||||
import io.heckel.ntfy.msg.ApiService.Companion.requestBuilder
|
import io.heckel.ntfy.msg.ApiService.Companion.requestBuilder
|
||||||
import io.heckel.ntfy.msg.Message
|
import io.heckel.ntfy.msg.Message
|
||||||
import io.heckel.ntfy.msg.NotificationParser
|
import io.heckel.ntfy.msg.NotificationParser
|
||||||
|
@ -20,7 +19,6 @@ import java.util.*
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import java.util.concurrent.atomic.AtomicLong
|
import java.util.concurrent.atomic.AtomicLong
|
||||||
import java.util.concurrent.atomic.AtomicReference
|
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
|
* Connect to ntfy server via WebSockets. This connection represents a single connection to a server, with
|
||||||
|
|
Loading…
Reference in a new issue