Skip to content

Commit

Permalink
Better Failed dialogs
Browse files Browse the repository at this point in the history
Just say track not found instead of JSON errors
  • Loading branch information
Lambada10 committed Jun 23, 2023
1 parent e774b97 commit 7e4fc12
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 35 deletions.
21 changes: 3 additions & 18 deletions app/src/main/java/pl/lambada/songsync/ui/screens/BrowseScreen.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package pl.lambada.songsync.ui.screens

import android.os.Environment
import android.util.Log
import android.widget.Toast
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
Expand Down Expand Up @@ -249,33 +248,19 @@ fun BrowseScreen(viewModel: MainViewModel) {
}

"Failed" -> {
var showSpotifyResponse by rememberSaveable { mutableStateOf(false) }
AlertDialog(
onDismissRequest = { queryStatus = "Not submitted" },
confirmButton = {
Button(onClick = { queryStatus = "Not submitted" }) {
Text(text = "OK")
}
},
dismissButton = {
if(!failReason.contains("FileNotFoundException")) {
if (showSpotifyResponse)
OutlinedButton(onClick = { showSpotifyResponse = false }) {
Text(text = "Hide response")
}
else
OutlinedButton(onClick = { showSpotifyResponse = true }) {
Text(text = "Show response")
}
}
},
title = { Text(text = "Error") },
text = {
val response by rememberSaveable { mutableStateOf(viewModel.spotifyResponse) }
if(!showSpotifyResponse)
Text(text = failReason)
if (failReason.contains("NotFound") || failReason.contains("JSON"))
Text(text = "No results")
else
Text(text = response)
Text(text = "An error occurred: $failReason")
}
)
}
Expand Down
20 changes: 3 additions & 17 deletions app/src/main/java/pl/lambada/songsync/ui/screens/HomeScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -424,33 +424,19 @@ fun SongItem(song: Song, viewModel: MainViewModel) {
)
}
"Failed" -> {
var showSpotifyResponse by rememberSaveable { mutableStateOf(false) }
AlertDialog(
onDismissRequest = { queryStatus = "Cancelled" },
confirmButton = {
Button(onClick = { queryStatus = "Cancelled" }) {
Text(text = "OK")
}
},
dismissButton = {
if(!failReason.contains("FileNotFoundException")) {
if (showSpotifyResponse)
OutlinedButton(onClick = { showSpotifyResponse = false }) {
Text(text = "Hide response")
}
else
OutlinedButton(onClick = { showSpotifyResponse = true }) {
Text(text = "Show response")
}
}
},
title = { Text(text = "Error") },
text = {
val response by rememberSaveable { mutableStateOf(viewModel.spotifyResponse) }
if(!showSpotifyResponse)
Text(text = failReason)
if (failReason.contains("NotFound") || failReason.contains("JSON"))
Text(text = "No results")
else
Text(text = response)
Text(text = "An error occurred: $failReason")
}
)
}
Expand Down

0 comments on commit 7e4fc12

Please sign in to comment.