当前位置: 首页>>代码示例>>Java>>正文


Java Event类代码示例

本文整理汇总了Java中com.google.api.services.calendar.model.Event的典型用法代码示例。如果您正苦于以下问题:Java Event类的具体用法?Java Event怎么用?Java Event使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Event类属于com.google.api.services.calendar.model包,在下文中一共展示了Event类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: inRange

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
private boolean inRange(Announcement a, Event e) {
	long maxDifferenceMs = 5 * 60 * 1000; //5 minutes

	long announcementTimeMs = Integer.toUnsignedLong(a.getMinutesBefore() + (a.getHoursBefore() * 60)) * 60 * 1000;
	long timeUntilEvent = getEventStartMs(e) - System.currentTimeMillis();

	long difference = timeUntilEvent - announcementTimeMs;

	if (difference < 0) {
		//Event past, we can delete announcement depending on the type
		if (a.getAnnouncementType() == AnnouncementType.SPECIFIC) {
			DatabaseManager.getManager().deleteAnnouncement(a.getAnnouncementId().toString());
		}
		return false;
	} else {
		return difference <= maxDifferenceMs;
	}
}
 
开发者ID:NovaFox161,项目名称:DisCal-Discord-Bot,代码行数:19,代码来源:AnnouncementTask.java

示例2: getEntries

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
/**
 * Gets a list of entries belonging to the given calendar defined between the given range of time. Recurring events
 * are not expanded, always recurrence is handled manually within the framework.
 *
 * @param calendar The calendar owner of the entries.
 * @param startDate The start date, not nullable.
 * @param endDate The end date, not nullable
 * @param zoneId The timezone in which the dates are represented.
 * @return A non-null list of entries.
 * @throws IOException For unexpected errors
 */
public List<GoogleEntry> getEntries(GoogleCalendar calendar, LocalDate startDate, LocalDate endDate, ZoneId zoneId) throws IOException {
    if (!calendar.existsInGoogle()) {
        return new ArrayList<>(0);
    }

    ZonedDateTime st = ZonedDateTime.of(startDate, LocalTime.MIN, zoneId);
    ZonedDateTime et = ZonedDateTime.of(endDate, LocalTime.MAX, zoneId);
    String calendarId = URLDecoder.decode(calendar.getId(), "UTF-8");

    List<Event> events = dao.events()
            .list(calendarId)
            .setTimeMin(new DateTime(Date.from(st.toInstant())))
            .setTimeMax(new DateTime(Date.from(et.toInstant())))
            .setSingleEvents(false)
            .setShowDeleted(false)
            .execute()
            .getItems();

    return toGoogleEntries(events);
}
 
开发者ID:dlemmermann,项目名称:CalendarFX,代码行数:32,代码来源:GoogleCalendarService.java

示例3: update

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
void update(Event e){
    event = e;
    String text = "<html>";
    text += "<center>" + e.getSummary() + "</center>";
    text += "Description: " + ((e.getDescription() == null) ? "[none]" : e.getDescription()) + "<br />";
    String start, end;
    if(CalendarAPI.getDateTime(e.getStart().getDateTime()) == null) {
        start = CalendarAPI.getDate(e.getStart().getDate()).format(DateTimeFormatter.ofPattern("EEE. MMMM dd, yyyy"));
        end = CalendarAPI.getDate(e.getEnd().getDate()).format(DateTimeFormatter.ofPattern("EEE. MMMM dd, yyyy"));
    }
    else {
        start = CalendarAPI.getDateTime(e.getStart().getDateTime()).format(DateTimeFormatter.ofPattern("EEE. MMMM dd, yyyy h:m a"));
        end = CalendarAPI.getDateTime(e.getEnd().getDateTime()).format(DateTimeFormatter.ofPattern("EEE. MMMM dd, yyyy h:m a"));
    }
    text += "Start: " + start + "<br/>";
    text += "End: " + end + "<br/>";
    text += "</html>";

    label.setText(text);
    setVisible(true);
}
 
开发者ID:beesenpai,项目名称:EVE,代码行数:22,代码来源:EventContentPane.java

示例4: getDataFromApi

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
@Override
protected List<Event> getDataFromApi() throws IOException {
    Date start = mMonth;
    start.setDate(1);
    start.setHours(0);
    start.setMinutes(0);
    DateTime dateTime = new DateTime(mMonth);
    Date end = (Date) start.clone();
    end.setMonth(start.getMonth() + 1);
    end.setHours(0);
    end.setMinutes(0);
    DateTime nextMonth = new DateTime(end);
    Log.d(TAG, "Find events between " + dateTime.toString() + " and " + end.toString());
    return getCalendarService().events().list(mCalendarId)
            .setTimeMin(dateTime)
            .setTimeMax(nextMonth)
            .setSingleEvents(true)
            .execute()
            .getItems();
}
 
开发者ID:ITVlab,项目名称:Family-Calendar,代码行数:21,代码来源:ListCalendarEventsMonthRequestTask.java

示例5: getDataFromApi

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
@Override
protected List<CalendarListEntry> getDataFromApi() throws IOException {
    List<CalendarListEntry> calList =
            getCalendarService().calendarList().list().execute().getItems();
    if (DEBUG) {
        Log.d(TAG, calList.toString());
        for (CalendarListEntry calendarListEntry : calList) {
            List<Event> events = new ListCalendarEventsRequestTask(getCredential(),
                    calendarListEntry.getId()).getDataFromApi();
            if (DEBUG) {
                Log.d(TAG, calendarListEntry.getSummary());
                Log.d(TAG, calendarListEntry.getId());
                Log.d(TAG, "Events: " + events.toString());
            }
        }
    }
    return calList;
}
 
开发者ID:ITVlab,项目名称:Family-Calendar,代码行数:19,代码来源:ListCalendarListRequestTask.java

示例6: getEventView

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
private View getEventView(Event event) {
    LinearLayout layout =
            (LinearLayout) getLayoutInflator().inflate(R.layout.event_card, null, false);
    ((TextView) layout.findViewById(R.id.event_title)).setText(event.getSummary());
    ((TextView)  layout.findViewById(R.id.event_time)).setText(
            CalendarUtils.getEventStartEndTimesAsString(event));

    if (event.getColorId() != null) {
        Log.d(TAG, "Color: " + event.getColorId());
        layout.setBackgroundColor(CalendarColorMap.getColors(event.getColorId()).background);
    } else if (event.getStart().getDateTime() != null) {
        layout.setBackgroundColor(getContext().getResources()
                .getColor(MonthThemer.getPrimaryDarkColor(new Date(event.getStart()
                        .getDateTime().getValue()).getMonth())));
    } else if (event.getStart().getDate() != null) {
        layout.setBackgroundColor(getContext().getResources()
                .getColor(MonthThemer.getPrimaryDarkColor(new Date(event.getStart()
                        .getDate().getValue()).getMonth())));
    }
    return layout;
}
 
开发者ID:ITVlab,项目名称:Family-Calendar,代码行数:22,代码来源:MonthViewAdapter.java

示例7: onBindViewHolder

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
    super.onBindViewHolder(holder, position);
    Event event = getItemAt(position);
    ((TextView) holder.layout.findViewById(R.id.event_title)).setText(event.getSummary());
    ((TextView) holder.layout.findViewById(R.id.event_time)).setText(
            CalendarUtils.getEventStartEndAsString(event));
    if (event.getLocation() != null) {
        ((TextView) holder.layout.findViewById(R.id.event_location)).setText(
                event.getLocation());
    }
    if (event.getColorId() != null) {
        Log.d(TAG, "Color: " + event.getColorId());
        holder.layout.setBackgroundColor(CalendarColorMap.getColors(event.getColorId()).background);
    } else if (event.getStart().getDateTime() != null) {
        holder.layout.setBackgroundColor(getContext().getResources()
                .getColor(MonthThemer.getPrimaryDarkColor(new Date(event.getStart()
                        .getDateTime().getValue()).getMonth())));
    } else if (event.getStart().getDate() != null) {
        holder.layout.setBackgroundColor(getContext().getResources()
                .getColor(MonthThemer.getPrimaryDarkColor(new Date(event.getStart()
                        .getDate().getValue()).getMonth())));
    }
}
 
开发者ID:ITVlab,项目名称:Family-Calendar,代码行数:25,代码来源:AgendaViewAdapter.java

示例8: addSchedule

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
public String addSchedule(Date start, Date end, String title, String description, String location, String color, ArrayList<String> recurrence, TimeZone timezone) throws Exception {
	String id = null;

	Event googleSchedule = new Event();
	googleSchedule.setStart(new EventDateTime().setTimeZone(timezone.getID()).setDateTime(new DateTime(start)));
	googleSchedule.setEnd(new EventDateTime().setTimeZone(timezone.getID()).setDateTime(new DateTime(end)));
	googleSchedule.setRecurrence(null);
	googleSchedule.setSummary(title.trim());
	googleSchedule.setDescription(description.trim());
	googleSchedule.setLocation(location.trim());
	googleSchedule.setColorId(color);

	googleSchedule.setRecurrence(recurrence);

	Event createdEvent = this.CALENDAR.events().insert(this.CALENDAR_NAME, googleSchedule).execute();
	id = createdEvent.getId();

	return id;
}
 
开发者ID:cybozu,项目名称:garoon-google,代码行数:20,代码来源:GoogleCalendar.java

示例9: insertData

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
private void insertData() throws IOException
{
    final DateTime date = Date.today();
    final Prayers prayers = new Prayers(context, date);

    for (int i = 0; i < Prayers.COUNT; i++)
    {
        final String title = prayers.getEnglishName(i) + PRAYER;
        final EventDateTime time = getEventTime(prayers.getDateTime(i, date));

        final Event event = new Event().setSummary(title)
                .setDescription("Iqama time for Islamic Center of Blacksburg")
                .setStart(time).setEnd(time).setLocation("Islamic Center of Blacksburg")
                .setRecurrence(getRecurrenceRule(date))
                .setReminders(getReminders());

        calendar.events().insert(calendarId, event).execute();
    }
}
 
开发者ID:amrabed,项目名称:Iqama,代码行数:20,代码来源:CalendarUpdateTask.java

示例10: leaveEvent

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
/**
 * This method removes the private copy of the Calendar Event
 * 
 * @param event
 * @param zeppaUser
 * @param user
 * @throws GeneralSecurityException
 * @throws IOException
 */
public static boolean leaveEvent(ZeppaEvent event, ZeppaUser zeppaUser) throws IOException {

	boolean success = false;
	com.google.api.services.calendar.Calendar service = GoogleCalendarUtils.makeCalendarServiceInstance();

	Event calEvent = service.events().get(event.getGoogleCalendarId(), event.getGoogleCalendarEventId()).execute();
	Iterator<EventAttendee> iterator = calEvent.getAttendees().iterator();

	while (iterator.hasNext()) {
		EventAttendee attendee = iterator.next();
		if (attendee.getEmail().equals(zeppaUser.getAuthEmail())) {
			success = calEvent.getAttendees().remove(attendee);
			break;
		}
	}

	if (success) {
		service.events().update(event.getGoogleCalendarId(), event.getGoogleCalendarEventId(), calEvent).execute();
	}

	return success;
}
 
开发者ID:pschuette22,项目名称:Zeppa-AppEngine,代码行数:32,代码来源:GoogleCalendarService.java

示例11: run

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
/**
 * Creates a test event, pauses while the user modifies the event in the Calendar UI, and then
 * checks if the event has been modified.
 */
private static void run() throws IOException {
  // Create a test event.
  Event event = Utils.createTestEvent(client, "Test Event");
  System.out.println(String.format("Event created: %s", event.getHtmlLink()));

  // Pause while the user modifies the event in the Calendar UI.
  System.out.println("Modify the event's description and hit enter to continue.");
  System.in.read();

  // Fetch the event again if it's been modified.
  Calendar.Events.Get getRequest = client.events().get("primary", event.getId());
  getRequest.setRequestHeaders(new HttpHeaders().setIfNoneMatch(event.getEtag()));
  try {
    event = getRequest.execute();
    System.out.println("The event was modified, retrieved latest version.");
  } catch (GoogleJsonResponseException e) {
    if (e.getStatusCode() == 304) {
      // A 304 status code, "Not modified", indicates that the etags match, and the event has
      // not been modified since we last retrieved it.
      System.out.println("The event was not modified, using local version.");
    } else {
      throw e;
    }
  }
}
 
开发者ID:googlesamples,项目名称:calendar-sync,代码行数:30,代码来源:ConditionalRetrievalSample.java

示例12: store

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
/**
 * Creates a new Google Calendar Entry for each <code>item</code> and adds
 * it to the processing queue. The entries' title will either be the items
 * name or <code>alias</code> if it is <code>!= null</code>.
 *
 * The new Calendar Entry will contain a single command to be executed e.g.<br>
 * <p>
 * <code>send &lt;item.name&gt; &lt;item.state&gt;</code>
 * </p>
 *
 * @param item the item which state should be persisted.
 * @param alias the alias under which the item should be persisted.
 */
@Override
public void store(final Item item, final String alias) {
    if (initialized) {
        String newAlias = alias != null ? alias : item.getName();

        Event event = new Event();
        event.setSummary("[PresenceSimulation] " + newAlias);
        event.setDescription(String.format(executeScript, item.getName(), item.getState().toString()));
        Date now = new Date();
        Date startDate = new Date(now.getTime() + 3600000L * 24 * offset);
        Date endDate = startDate;
        DateTime start = new DateTime(startDate);
        event.setStart(new EventDateTime().setDateTime(start));
        DateTime end = new DateTime(endDate);
        event.setEnd(new EventDateTime().setDateTime(end));

        entries.offer(event);

        logger.trace("added new entry '{}' for item '{}' to upload queue", event.getSummary(), item.getName());
    } else {
        logger.debug(
                "GCal PresenceSimulation Service isn't initialized properly! No entries will be uploaded to your Google Calendar");
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:38,代码来源:GCalPersistenceService.java

示例13: execute

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
    logger.trace("going to upload {} calendar entries to Google now ...", entries.size());
    Calendar calendarClient = null;
    if (entries.size() > 0) {
        Credential credential = GCalGoogleOAuth.getCredential(false);
        if (credential == null) {
            logger.error(
                    "Please configure gcal:client_id/gcal:client_secret in openhab.cfg. Refer to wiki how to create client_id/client_secret pair");
        } else {
            // set up global Calendar instance
            calendarClient = new com.google.api.services.calendar.Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY,
                    credential).setApplicationName("openHABpersistence").build();
        }
    }
    for (Event entry : entries) {
        upload(calendarClient, entry);
        entries.remove(entry);
    }
}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:21,代码来源:GCalPersistenceService.java

示例14: createCalendarEvent

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
/**
 * Creates a new calendar entry.
 *
 * @param event the event to create in the remote calendar identified by the
 *            full calendar feed configured in </code>openhab.cfg</code>
 * @return the newly created entry
 * @throws IOException
 */
private Event createCalendarEvent(Calendar calendarClient, Event event) throws IOException {

    if (calendarClient == null) {
        logger.error(
                "Please configure gcal:client_id/gcal:client_secret in openhab.cfg. Refer to wiki how to create client_id/client_secret pair");
    } else {
        // set up global Calendar instance
        CalendarListEntry calendarID = GCalGoogleOAuth.getCalendarId(calendar_name);
        if (calendarID != null) {
            return calendarClient.events().insert(calendarID.getId(), event).execute();
        }

    }

    return null;

}
 
开发者ID:openhab,项目名称:openhab1-addons,代码行数:26,代码来源:GCalPersistenceService.java

示例15: scheduleNotification

import com.google.api.services.calendar.model.Event; //导入依赖的package包/类
@POST
@Path("{patientEmail}")
@Produces({MediaType.TEXT_PLAIN})
public String scheduleNotification(@PathParam("patientEmail") String patientEmail,
                                   @FormParam("calendarId") String calendarId,
                                   @FormParam("eventId") String eventId) throws IOException {
    verifyPatientEmail(patientEmail);
    Event event = getCalendarEvent(patientEmail, calendarId, eventId);
    String appointmentTime = event.getStart().getDateTime().toStringRfc3339();

    TaskOptions task = withUrl("/tasks/notification/")
            .method(TaskOptions.Method.GET)
            .param("patientEmail", patientEmail)
            .param("appointmentAddress", event.getLocation())
            .param("appointmentTime", appointmentTime);

    Queue queue = QueueFactory.getQueue(QUEUE_NAME);
    queue.add(task);

    return "OK";
}
 
开发者ID:openmash,项目名称:mashmesh,代码行数:22,代码来源:SendEventNotificationResource.java


注:本文中的com.google.api.services.calendar.model.Event类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。