本文整理汇总了Java中com.google.api.services.calendar.model.Events.getItems方法的典型用法代码示例。如果您正苦于以下问题:Java Events.getItems方法的具体用法?Java Events.getItems怎么用?Java Events.getItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.api.services.calendar.model.Events
的用法示例。
在下文中一共展示了Events.getItems方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDataFromApi
import com.google.api.services.calendar.model.Events; //导入方法依赖的package包/类
/**
* Fetch a list of the next 10 events from the primary calendar.
*
* @return List of Strings describing returned events.
* @throws IOException
*/
private List<String> getDataFromApi() throws IOException {
// List the next 10 events from the primary calendar.
DateTime now = new DateTime(System.currentTimeMillis());
List<String> eventStrings = new ArrayList<String>();
Events events = mService.events().list("primary")
.setMaxResults(10)
.setTimeMin(now)
.setOrderBy("startTime")
.setSingleEvents(true)
.execute();
List<Event> items = events.getItems();
for (Event event : items) {
DateTime start = event.getStart().getDateTime();
if (start == null) {
// All-day events don't have start times, so just use
// the start date.
start = event.getStart().getDate();
}
eventStrings.add(
String.format("%s (%s)", event.getSummary(), start));
}
return eventStrings;
}
示例2: execute
import com.google.api.services.calendar.model.Events; //导入方法依赖的package包/类
/**
* @{inheritDoc}
*/
@Override
protected void execute() {
Events myFeed = downloadEventFeed();
if (myFeed != null) {
List<Event> entries = myFeed.getItems();
if (entries.size() > 0) {
logger.debug("found {} calendar events to process", entries.size());
try {
if (scheduler.isShutdown()) {
logger.warn("Scheduler has been shut down - probably due to exceptions?");
}
cleanJobs();
processEntries(entries);
} catch (SchedulerException se) {
logger.error("scheduling jobs throws exception", se);
}
} else {
logger.debug("gcal feed contains no events ...");
}
}
}
示例3: getEvents
import com.google.api.services.calendar.model.Events; //导入方法依赖的package包/类
private List<Event> getEvents(GuildSettings gs, CalendarData cd, Calendar service, Announcement a) {
if (!allEvents.containsKey(gs.getGuildID())) {
try {
Events events = service.events().list(cd.getCalendarAddress())
.setMaxResults(15)
.setTimeMin(new DateTime(System.currentTimeMillis()))
.setOrderBy("startTime")
.setSingleEvents(true)
.setShowDeleted(false)
.execute();
List<Event> items = events.getItems();
allEvents.put(gs.getGuildID(), items);
} catch (IOException e) {
ExceptionHandler.sendException(null, "Failed to get events list! 00x2304 | Guild: " + gs.getGuildID() + " | Announcement: " + a.getAnnouncementId(), e, this.getClass());
allEvents.put(gs.getGuildID(), new VirtualFlow.ArrayLinkedList<>());
}
}
return allEvents.get(gs.getGuildID());
}
示例4: fetchEvent
import com.google.api.services.calendar.model.Events; //导入方法依赖的package包/类
public Event fetchEvent(String id, String summary) throws IOException{
Events ev = showEvents(id);
for(Event e : ev.getItems()){
if(e.getSummary().equalsIgnoreCase(summary)) return e;
}
return null;
}
示例5: clear
import com.google.api.services.calendar.model.Events; //导入方法依赖的package包/类
public GoogleCalendarSync clear(final LocalDate date) throws IOException {
final CalendarListEntry flats = getCalendar();
// Iterate over the events in the specified calendar
String pageToken = null;
int cnt = 0;
do {
final Events events;
if (date != null) {
events = client.events().list(flats.getId()).setTimeMin(new DateTime(new DateConverter().convert(date)))
.setPageToken(pageToken).execute();
} else {
events = client.events().list(flats.getId()).setPageToken(pageToken).execute();
}
final List<Event> items = events.getItems();
for (final Event event : items) {
if (event == null) {
if (logger.isWarnEnabled()) {
logger.warn("Skipping null event");
}
continue;
}
clearEvent(flats.getId(), event);
cnt++;
}
pageToken = events.getNextPageToken();
} while (pageToken != null);
if (logger.isDebugEnabled()) {
logger.debug("Processed " + cnt + " events");
}
return this;
}
示例6: getEvents
import com.google.api.services.calendar.model.Events; //导入方法依赖的package包/类
@Override
public List<CalendarEvent> getEvents(final ICalendarEventFilter[] filters) throws SynchronisationException {
log.info(UserMessage.get().MSG_READING_GOOGLE_EVENTS(getCalendar().getSummary()));
final List<CalendarEvent> events = new ArrayList<CalendarEvent>();
try {
final Calendar sdt = settings.getSyncStartDate();
final Calendar edt = settings.getSyncEndDate();
final DateTime startDateTime = new DateTime(sdt.getTime(), sdt.getTimeZone());
final DateTime endDateTime = new DateTime(edt.getTime(), edt.getTimeZone());
final Events googleEvents = service.events().list(getCalendar().getId())//
.setTimeMin(startDateTime).setTimeMax(endDateTime)//
.setMaxResults(new Integer(65535))//
.setOrderBy("starttime")// //$NON-NLS-1$
// handling recurrence is not necessary, since Lotus Notes recurrence is a pain in the a..
.setSingleEvents(Boolean.TRUE)//
.execute();
// if no entry is present in the Google calendar, the list is null
if (googleEvents.getItems() == null) {
return new ArrayList<CalendarEvent>();
}
for (final Event googleEvent : googleEvents.getItems()) {
events.add(convGoogleEvent(googleEvent));
}
} catch (final IOException e) {
throw new SynchronisationException(e);
}
return events;
}