Given the below snippet:
Super Class implementation:
@Override
public void onDone(String taskName, JSONObject receivedData, @Nullable HashMap<String, String> sentData) {
//checks the status for all done process decides to call the presenter failed or success
try {
boolean success = receivedData.getString("status").equals("success");
if(!success){
this.presenter.error(receivedData.getString("reason"));
}
}catch (JSONException ex){
ex.printStackTrace();
this.presenter.error("An error occurred");
}
}
Base Class Implementation::
@Override
public void onDone(@NonNull String taskName, @NonNull JSONObject receivedData,
@Nullable HashMap<String, String> sentData) {
super.onDone(taskName, receivedData, sentData);
//the expected data has been received we should act upon it
//this DAO should know all the type of taskName it can handle and if it finds any that doesn't
//matches any of its command let it exit
Log.e(TAG, "Response : "+receivedData);
Toast.makeText(this.presenter.getContext(), "Done with task", Toast.LENGTH_LONG).show();
if(sentData!=null){
sentData.clear();
sentData = null;
}
}
What i want is that as soon as the super.onDone method detects an error, the process should end there and shouldn't bother running the body of the base method, is that possible in JAVA?
Aucun commentaire:
Enregistrer un commentaire