diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/Requester.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/Requester.kt index b207fa5..1acace2 100644 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/Requester.kt +++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/Requester.kt @@ -15,7 +15,12 @@ class Requester constructor(var siteName: String, var endpoint: String) { val stringRequest = object: StringRequest( Method.POST, url, { resp -> run { - response = resp + response = + if (resp == "") { + "Not found 404" + } else { + resp + } } }, { diff --git a/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AddAbstractProductActivity.kt b/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AddAbstractProductActivity.kt index fee5ecc..2aea5ed 100644 --- a/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AddAbstractProductActivity.kt +++ b/app/src/main/java/org/foxarmy/barcodescannerforemployees/activities/AddAbstractProductActivity.kt @@ -128,6 +128,12 @@ class AddAbstractProductActivity : AppCompatActivity() { thread { // Я сам в ахуях какой это костыль, пока хз как фиксить, потом придумаю :)) 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) requester.response = "" runOnUiThread {