@Override protected final void onPostExecute(Boolean success) { super.onPostExecute(success); birthday.getEventId().clear(); if (update) { if (birthday.getIsLunar()) { fragment.createLunarEvent(birthday, false); } else { fragment.createEvent(birthday, false); } } else { BirthdayLab.get(fragment.getActivity()).deleteBirthday(birthday); ((BirthdayAdapter) (fragment.getListAdapter())).notifyDataSetChanged(); fragment.getDeleteBirthdays().remove(birthday); } }
@Override protected void doInBackground() throws IOException { Log.d(TAG, "delete the event" + ": " + birthday); BatchRequest batch = client.batch(); try { for (String eventId : birthday.getEventId()) { client .events() .delete(calendar_id, eventId) .queue( batch, new JsonBatchCallback<Void>() { @Override public void onFailure(GoogleJsonError err, HttpHeaders headers) throws IOException { if (fragment.isCancelAyncTasks()) return; Utils.logAndShowError(fragment, TAG, err.getMessage()); } public void onSuccess(Void arg0, HttpHeaders arg1) throws IOException { Log.d(TAG, "delete one event"); // TODO Auto-generated method stub } }); } // if(fragment.isCancelAyncTasks()) { // cancel(true); // return; // } batch.execute(); } catch (GoogleJsonResponseException e) { if (e.getStatusCode() != 404) { throw e; } } }