xml error will now trigger red toast

This commit is contained in:
paul-loedige 2021-01-04 13:33:47 +01:00
parent 34ef339069
commit a8e4d29c5b

View File

@ -21,6 +21,7 @@ import com.example.aped.MainActivity;
import com.example.aped.R; import com.example.aped.R;
import com.example.aped.utils.ExternalStorageHandler; import com.example.aped.utils.ExternalStorageHandler;
import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.File; import java.io.File;
@ -112,7 +113,16 @@ public class Communicator {
Request.Method.POST, Request.Method.POST,
url, url,
xmlFile, xmlFile,
response -> System.out.println(response.toString()), response -> {
try {
JSONObject jsonObject = new JSONObject(response.toString());
if (!jsonObject.getString("error").equals("")) {
makeToast(jsonObject.getString("error"));
}
} catch (JSONException e) {
Log.e("Communicator","JSON error on response during UPLOAD: " + e.getMessage());
}
},
error -> handleError(error, "UPLOAD XML") error -> handleError(error, "UPLOAD XML")
); );
requestQueue.add(request); requestQueue.add(request);