From 1c4f948a8413e134035b7a46b189e48f9fa6a609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Font=C3=A1n?= Date: Sat, 18 Nov 2023 00:33:11 +0100 Subject: [PATCH] fix: Removed client functions that made it being closed --- .../java/pl/lambada/songsync/data/remote/github/GithubAPI.kt | 1 - .../songsync/data/remote/lyrics_providers/others/LRCLibAPI.kt | 2 -- .../songsync/data/remote/lyrics_providers/others/NeteaseAPI.kt | 2 -- .../songsync/data/remote/lyrics_providers/spotify/SpotifyAPI.kt | 2 -- .../data/remote/lyrics_providers/spotify/SpotifyLyricsAPI.kt | 1 - 5 files changed, 8 deletions(-) diff --git a/app/src/main/java/pl/lambada/songsync/data/remote/github/GithubAPI.kt b/app/src/main/java/pl/lambada/songsync/data/remote/github/GithubAPI.kt index 4e6ac44..2c30150 100644 --- a/app/src/main/java/pl/lambada/songsync/data/remote/github/GithubAPI.kt +++ b/app/src/main/java/pl/lambada/songsync/data/remote/github/GithubAPI.kt @@ -17,7 +17,6 @@ object GithubAPI { suspend fun getLatestRelease(): Release { val response = client.get(BASE_URL + "repos/Lambada10/SongSync/releases/latest") val responseBody = response.bodyAsText(Charsets.UTF_8) - client.close() return json.decodeFromString(responseBody) } diff --git a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/LRCLibAPI.kt b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/LRCLibAPI.kt index a27232a..9ed18ec 100644 --- a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/LRCLibAPI.kt +++ b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/LRCLibAPI.kt @@ -35,7 +35,6 @@ class LRCLibAPI { baseURL + "search?q=$search" ) val responseBody = response.bodyAsText(Charsets.UTF_8) - client.close() if (responseBody == "[]" || response.status.value !in 200..299) return null @@ -59,7 +58,6 @@ class LRCLibAPI { baseURL + "get/$id" ) val responseBody = response.bodyAsText(Charsets.UTF_8) - client.close() if (response.status.value !in 200..299 || responseBody == "[]") return null diff --git a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/NeteaseAPI.kt b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/NeteaseAPI.kt index 6a429f5..edb99ad 100644 --- a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/NeteaseAPI.kt +++ b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/others/NeteaseAPI.kt @@ -65,7 +65,6 @@ class NeteaseAPI { parameter("s", search) } val responseBody = response.bodyAsText(Charsets.UTF_8) - client.close() if (responseBody == "[]" || response.status.value !in 200..299) return null @@ -102,7 +101,6 @@ class NeteaseAPI { parameter("lv", 1) } val responseBody = response.bodyAsText(Charsets.UTF_8) - client.close() if (response.status.value !in 200..299 || responseBody == "[]") return null diff --git a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/spotify/SpotifyAPI.kt b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/spotify/SpotifyAPI.kt index 03e3233..8ffbb8c 100644 --- a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/spotify/SpotifyAPI.kt +++ b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/spotify/SpotifyAPI.kt @@ -36,7 +36,6 @@ class SpotifyAPI { ) } val responseBody = response.bodyAsText(Charsets.UTF_8) - client.close() val json = json.decodeFromString(responseBody) @@ -71,7 +70,6 @@ class SpotifyAPI { headers.append("Authorization", "Bearer $spotifyToken") } val responseBody = response.bodyAsText(Charsets.UTF_8) - client.close() val json = json.decodeFromString(responseBody) if (json.tracks.items.isEmpty()) diff --git a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/spotify/SpotifyLyricsAPI.kt b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/spotify/SpotifyLyricsAPI.kt index 81dfc6a..6d2cbef 100644 --- a/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/spotify/SpotifyLyricsAPI.kt +++ b/app/src/main/java/pl/lambada/songsync/data/remote/lyrics_providers/spotify/SpotifyLyricsAPI.kt @@ -17,7 +17,6 @@ class SpotifyLyricsAPI { suspend fun getSyncedLyrics(songLink: String): String? { val response = client.get("$baseURL?url=$songLink&format=lrc") val responseBody = response.bodyAsText(Charsets.UTF_8) - client.close() if (response.status.value !in 200..299) return null