diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 3d35f08..679f142 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -34,7 +34,7 @@
-
+
diff --git a/app/src/main/java/io/heckel/ntfy/MainActivity.kt b/app/src/main/java/io/heckel/ntfy/MainActivity.kt
index 4cfd7e8..de64c3d 100644
--- a/app/src/main/java/io/heckel/ntfy/MainActivity.kt
+++ b/app/src/main/java/io/heckel/ntfy/MainActivity.kt
@@ -34,12 +34,11 @@ import com.google.gson.GsonBuilder
import com.google.gson.JsonObject
import com.google.gson.JsonSyntaxException
import io.heckel.ntfy.add.AddTopicActivity
-import io.heckel.ntfy.add.TOPIC_URL
import io.heckel.ntfy.data.Topic
-import io.heckel.ntfy.detail.TopicDetailActivity
+import io.heckel.ntfy.detail.DetailActivity
import io.heckel.ntfy.list.TopicsAdapter
-import io.heckel.ntfy.list.TopicsViewModelFactory
import io.heckel.ntfy.list.TopicsViewModel
+import io.heckel.ntfy.list.TopicsViewModelFactory
import kotlinx.coroutines.*
import java.io.IOException
import java.net.HttpURLConnection
@@ -47,6 +46,7 @@ import java.net.URL
import kotlin.random.Random
const val TOPIC_ID = "topic id"
+const val TOPIC_URL = "url"
class MainActivity : AppCompatActivity() {
private val gson = GsonBuilder().create()
@@ -80,7 +80,7 @@ class MainActivity : AppCompatActivity() {
/* Opens TopicDetailActivity when RecyclerView item is clicked. */
private fun adapterOnClick(topic: Topic) {
- val intent = Intent(this, TopicDetailActivity()::class.java)
+ val intent = Intent(this, DetailActivity()::class.java)
intent.putExtra(TOPIC_ID, topic.id)
startActivity(intent)
}
@@ -124,9 +124,10 @@ class MainActivity : AppCompatActivity() {
try {
val input = conn.inputStream.bufferedReader()
while (scope.isActive) {
- val line = input.readLine() ?: break // Break if null!
+ val line = input.readLine() ?: break // Exit if null
try {
- displayNotification(gson.fromJson(line, JsonObject::class.java))
+ val json = gson.fromJson(line, JsonObject::class.java) ?: break // Exit if null
+ displayNotification(json)
} catch (e: JsonSyntaxException) {
// Ignore invalid JSON
}
diff --git a/app/src/main/java/io/heckel/ntfy/add/AddTopicActivity.kt b/app/src/main/java/io/heckel/ntfy/add/AddActivity.kt
similarity index 98%
rename from app/src/main/java/io/heckel/ntfy/add/AddTopicActivity.kt
rename to app/src/main/java/io/heckel/ntfy/add/AddActivity.kt
index 6fe39c4..69c6459 100644
--- a/app/src/main/java/io/heckel/ntfy/add/AddTopicActivity.kt
+++ b/app/src/main/java/io/heckel/ntfy/add/AddActivity.kt
@@ -23,8 +23,7 @@ import android.widget.Button
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.textfield.TextInputEditText
import io.heckel.ntfy.R
-
-const val TOPIC_URL = "url"
+import io.heckel.ntfy.TOPIC_URL
class AddTopicActivity : AppCompatActivity() {
private lateinit var addTopicUrl: TextInputEditText
diff --git a/app/src/main/java/io/heckel/ntfy/detail/TopicDetailActivity.kt b/app/src/main/java/io/heckel/ntfy/detail/DetailActivity.kt
similarity index 97%
rename from app/src/main/java/io/heckel/ntfy/detail/TopicDetailActivity.kt
rename to app/src/main/java/io/heckel/ntfy/detail/DetailActivity.kt
index 59f748d..a2df000 100644
--- a/app/src/main/java/io/heckel/ntfy/detail/TopicDetailActivity.kt
+++ b/app/src/main/java/io/heckel/ntfy/detail/DetailActivity.kt
@@ -26,7 +26,7 @@ import io.heckel.ntfy.TOPIC_ID
import io.heckel.ntfy.list.TopicsViewModel
import io.heckel.ntfy.list.TopicsViewModelFactory
-class TopicDetailActivity : AppCompatActivity() {
+class DetailActivity : AppCompatActivity() {
private val topicDetailViewModel by viewModels {
TopicsViewModelFactory(this)
}