本文整理汇总了Java中com.google.api.services.calendar.model.Events类的典型用法代码示例。如果您正苦于以下问题:Java Events类的具体用法?Java Events怎么用?Java Events使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Events类属于com.google.api.services.calendar.model包,在下文中一共展示了Events类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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;
}
开发者ID:webianks,项目名称:Crimson,代码行数:31,代码来源:CheckupReminders.java
示例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 ...");
}
}
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:27,代码来源:GCalEventDownloader.java
示例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());
}
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:20,代码来源:AnnouncementTask.java
示例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;
}
开发者ID:beesenpai,项目名称:EVE,代码行数:8,代码来源:CalendarAPI.java
示例5: setReminderNow
import com.google.api.services.calendar.model.Events; //导入依赖的package包/类
private void setReminderNow(String name, String address, String full_date) {
long calID = 3;
long startMillis = 0;
long endMillis = 0;
Calendar beginTime = Calendar.getInstance();
beginTime.set(2017, 02, 11, 15, 30);
startMillis = beginTime.getTimeInMillis();
Calendar endTime = Calendar.getInstance();
endTime.set(2017, 02, 12, 15, 45);
endMillis = endTime.getTimeInMillis();
ContentResolver cr = getContentResolver();
ContentValues values = new ContentValues();
values.put(CalendarContract.Events.DTSTART, startMillis);
values.put(CalendarContract.Events.DTEND, endMillis);
values.put(CalendarContract.Events.TITLE, "Eye Checkup");
values.put(CalendarContract.Events.DESCRIPTION, name + " - " + address);
values.put(CalendarContract.Events.CALENDAR_ID, calID);
values.put(CalendarContract.Events.EVENT_TIMEZONE, "Asia/Kolkata");
Uri uri = cr.insert(CalendarContract.Events.CONTENT_URI, values);
long eventID = Long.parseLong(uri.getLastPathSegment());
Toast.makeText(this, "EventID " + eventID, Toast.LENGTH_LONG).show();
progressDialog.dismiss();
}
开发者ID:webianks,项目名称:Crimson,代码行数:32,代码来源:CheckupReminders.java
示例6: 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;
}
开发者ID:DrBookings,项目名称:drbookings,代码行数:33,代码来源:GoogleCalendarSync.java
示例7: 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;
}
开发者ID:fjakop,项目名称:ngcalsync,代码行数:36,代码来源:GoogleCalendarDAO.java
示例8: downloadEventFeed
import com.google.api.services.calendar.model.Events; //导入依赖的package包/类
/**
* Connects to Google-Calendar Service and returns the specified Events
*
* @return the corresponding Events or <code>null</code> if an error
* occurs. <i>Note:</i> We do only return events if their startTime lies between
* <code>now</code> and <code>now + 2 * refreshInterval</code> to reduce
* the amount of events to process.
*/
private static Events downloadEventFeed() {
// TODO: teichsta: there could be more than one calendar url in openHAB.cfg
// for now we accept this limitation of downloading just one feed ...
if (StringUtils.isBlank(calendar_name)) {
logger.warn("Login aborted no calendar name defined");
return null;
}
// authorization
CalendarListEntry calendarID = GCalGoogleOAuth.getCalendarId(calendar_name);
if (calendarID == null) {
return null;
}
DateTime start = new DateTime(new Date(), TimeZone.getTimeZone(calendarID.getTimeZone()));
DateTime end = new DateTime(new Date(start.getValue() + (2 * refreshInterval)),
TimeZone.getTimeZone(calendarID.getTimeZone()));
logger.debug("Downloading calendar feed for time interval: {} to {} ", start, end);
Events feed = null;
try {
Credential credential = GCalGoogleOAuth.getCredential(false);
// set up global Calendar instance
Calendar client = new Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName("openHAB").build();
Calendar.Events.List l = client.events().list(calendarID.getId()).setSingleEvents(true).setTimeMin(start)
.setTimeMax(end);
// add the fulltext filter if it has been configured
if (StringUtils.isNotBlank(filter)) {
l = l.setQ(filter);
}
feed = l.execute();
} catch (IOException e1) {
logger.error("Event fetch failed: {}", e1.getMessage());
}
try {
if (feed != null) {
checkIfFullCalendarFeed(feed.getItems());
}
return feed;
} catch (Exception e) {
logger.error("downloading CalendarEventFeed throws exception: {}", e.getMessage());
}
return null;
}
开发者ID:openhab,项目名称:openhab1-addons,代码行数:62,代码来源:GCalEventDownloader.java
示例9: showEvents
import com.google.api.services.calendar.model.Events; //导入依赖的package包/类
/**
* List all events from a calendar
* @param id the id of the calendar to list from.
* @return An iterable list of events
* @throws IOException
*/
public Events showEvents(String id) throws IOException{
return client.events().list(id).execute();
}
开发者ID:beesenpai,项目名称:EVE,代码行数:10,代码来源:CalendarAPI.java
示例10: parseEvents
import com.google.api.services.calendar.model.Events; //导入依赖的package包/类
private void parseEvents(Map<Thermostat, SortedMap<Period, ZoneStatus>> ts2schedule, Set<Thermostat> tSet, Calendar calendarClient, String id) throws IOException {
NDC.push("parseEvents");
Marker m = new Marker("parseEvents");
try {
com.google.api.services.calendar.Calendar.Events.List events = calendarClient.events().list(id);
java.util.Calendar tempCalendar = new GregorianCalendar();
tempCalendar.set(java.util.Calendar.HOUR_OF_DAY, 0);
tempCalendar.set(java.util.Calendar.MINUTE, 0);
tempCalendar.set(java.util.Calendar.SECOND, 0);
tempCalendar.set(java.util.Calendar.MILLISECOND, 0);
Date start = tempCalendar.getTime();
tempCalendar.set(java.util.Calendar.HOUR_OF_DAY, 23);
tempCalendar.set(java.util.Calendar.MINUTE, 59);
tempCalendar.set(java.util.Calendar.SECOND, 59);
tempCalendar.set(java.util.Calendar.MILLISECOND, 0);
Date end = tempCalendar.getTime();
// Now, let's produce the time zone offset and shove it down the throat of
// Google's invention that isn't capable of parsing normal TZ representation.
// This will not work with fractional offsets, but you know what?
// Go fix it yourself if you live in one of those time zones.
int tzShift = tempCalendar.getTimeZone().getRawOffset() / (60000 * 60);
String tzTail = tzFormatter.format(tzShift) + ":00";
DateFormat dateFormatter = new SimpleDateFormat(dateFormat);
DateTime dtStart = DateTime.parseRfc3339(dateFormatter.format(start) + tzTail);
DateTime dtEnd = DateTime.parseRfc3339(dateFormatter.format(end) + tzTail);
events.setTimeMin(dtStart);
events.setTimeMax(dtEnd);
events.setSingleEvents(true);
logger.info("query: " + events);
Events feed = events.execute();
// cal.query() has been known to get stuck, let's update the timestamp
touch();
parse(ts2schedule, tSet, feed.getItems());
} finally {
m.close();
NDC.pop();
}
}
开发者ID:home-climate-control,项目名称:dz,代码行数:58,代码来源:GCalScheduleUpdater.java
注:本文中的com.google.api.services.calendar.model.Events类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论