/** Clean up process method for the post execute block in the async task */ private void wrapUpCall(String result) throws JSONException, UnsupportedEncodingException { QueryHandler queryHandler; JSONArray jsonArray = null; DataBundler bundler = null; jsonArray = new JSONArray(result); bundler = new DataBundler(jsonArray); queryHandler = new QueryHandler(bundler); // create new queryHandler if (queryHandler.update() == 1) { requestRequests(BookshelfConstants.CONNECTION_URI); } else if (queryHandler.insert() == 0) { Toast.makeText( getActivity(), bundler.getOuterObject().getString(BookshelfConstants.RESULT_KEY_ERROR), Toast.LENGTH_LONG) .show(); } if (queryHandler.select() == 1) { borrowedBooks = parse(bundler.getInnerArray()); updateDisplay(); } else if (queryHandler.select() == 0) { borrowedBooks = new ArrayList<>(); updateDisplay(); Toast.makeText( getActivity(), bundler.getOuterObject().getString(BookshelfConstants.RESULT_KEY_ERROR), Toast.LENGTH_LONG) .show(); } }
@Override protected void onPostExecute(String result) { pb.setVisibility(View.INVISIBLE); // Set progressbar visibility if (result == null) { Toast.makeText( getActivity(), getString(R.string.connection_denied_error), Toast.LENGTH_LONG) .show(); } else { try { wrapUpCall(result); } catch (JSONException e) { e.printStackTrace(); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } } }