added handler for non-existent products

This commit is contained in:
leca 2024-10-12 04:43:12 +03:00
parent 4cad738f0e
commit 6dd48d0a8d
2 changed files with 12 additions and 1 deletions

View File

@ -15,7 +15,12 @@ class Requester constructor(var siteName: String, var endpoint: String) {
val stringRequest = object: StringRequest( val stringRequest = object: StringRequest(
Method.POST, url, { resp -> Method.POST, url, { resp ->
run { run {
response = resp response =
if (resp == "") {
"Not found 404"
} else {
resp
}
} }
}, },
{ {

View File

@ -128,6 +128,12 @@ class AddAbstractProductActivity : AppCompatActivity() {
thread { thread {
// Я сам в ахуях какой это костыль, пока хз как фиксить, потом придумаю :)) // Я сам в ахуях какой это костыль, пока хз как фиксить, потом придумаю :))
while (requester.response == "") { } while (requester.response == "") { }
if (requester.response == "Not found 404") {
runOnUiThread {
Toast.makeText(this, "Product not found. Please, try again or type manually", Toast.LENGTH_LONG).show()
}
return@thread
}
abstractProduct = Parser().parse(requester.response) abstractProduct = Parser().parse(requester.response)
requester.response = "" requester.response = ""
runOnUiThread { runOnUiThread {