Code Conventions
This commit is contained in:
parent
a423d4a037
commit
70124761bf
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user