View.display(feed);
}
private static void addCalendarsUsingBatch() throws IOException {
View.header("Add Calendars using Batch");
BatchRequest batch = client.batch();
// Create the callback.
JsonBatchCallback<Calendar> callback = new JsonBatchCallback<Calendar>() {
@Override
public void onSuccess(Calendar calendar, HttpHeaders responseHeaders) {
View.display(calendar);
addedCalendarsUsingBatch.add(calendar);
}
@Override
public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
System.out.println("Error Message: " + e.getMessage());
}
};
// Create 2 Calendar Entries to insert.
Calendar entry1 = new Calendar().setSummary("Calendar for Testing 1");
client.calendars().insert(entry1).queue(batch, callback);
Calendar entry2 = new Calendar().setSummary("Calendar for Testing 2");
client.calendars().insert(entry2).queue(batch, callback);
batch.execute();
}