From 70124761bf7c92680da3b0b647cb504403cd39de Mon Sep 17 00:00:00 2001 From: m_broelemann Date: Wed, 6 Jan 2021 08:52:43 +0100 Subject: [PATCH] Code Conventions --- .../aped/communication/Communicator.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/APED/app/src/main/java/com/example/aped/communication/Communicator.java b/APED/app/src/main/java/com/example/aped/communication/Communicator.java index c642647..59634e2 100644 --- a/APED/app/src/main/java/com/example/aped/communication/Communicator.java +++ b/APED/app/src/main/java/com/example/aped/communication/Communicator.java @@ -113,12 +113,14 @@ public class Communicator { xmlFile, response -> { try { - JSONObject jsonObject = new JSONObject(response.toString()); + 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()); + Log.e("Communicator", "JSON error on response" + + " during UPLOAD: " + e.getMessage()); } }, error -> handleError(error, "UPLOAD XML") @@ -155,26 +157,30 @@ public class Communicator { + e.getMessage()); } }, - error -> handleError(error,"XML DOWNLOAD") + error -> handleError(error, "XML DOWNLOAD") ); requestQueue.add(request); } - private void handleError(VolleyError error, String method){ - if (error instanceof ServerError){ - Log.e("Communicator","server error during " + method + ": " + error.getMessage()); + private void handleError(final VolleyError error, final String method) { + if (error instanceof ServerError) { + Log.e("Communicator", "server error during " + method + + ": " + error.getMessage()); } else if (error instanceof NoConnectionError) { makeToast("NO CONNECTION"); } else if (error instanceof TimeoutError) { makeToast("CONNECTION TIMEOUT"); } else { - Log.e("Communicator","error during " + method + ": " + error.getMessage()); + Log.e("Communicator", "error during " + method + ": " + + error.getMessage()); } } - private void makeToast(String message){ + private void makeToast(final String message) { Toast toast = new Toast(mainActivity); - View toastView = mainActivity.getLayoutInflater().inflate(R.layout.volley_toast, (ViewGroup) mainActivity.findViewById(R.id.volleyToastContainer)); + View toastView = mainActivity.getLayoutInflater().inflate(R.layout. + volley_toast, (ViewGroup) mainActivity.findViewById(R.id. + volleyToastContainer)); TextView textView = toastView.findViewById(R.id.text); textView.setText(message); toast.setDuration(Toast.LENGTH_LONG);