added handler for non-existent products
This commit is contained in:
parent
4cad738f0e
commit
6dd48d0a8d
|
@ -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
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -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 {
|
||||||
|
|
Loading…
Reference in New Issue