コード例 #1
0
        @Override
        protected Intent getActivityIntent() {
          // Make sure the EULA screen is not shown.
          SettingsUtils.markTosAccepted(InstrumentationRegistry.getTargetContext(), true);

          // Create intent to load the keynote session.
          mSessionUri = ScheduleContract.Sessions.buildSessionUri(SESSION_ID);
          Intent intent = new Intent(Intent.ACTION_VIEW, mSessionUri);

          return intent;
        }
コード例 #2
0
  /**
   * Processes all sessions in the {@link com.meetingcpp.sched.provider.ScheduleProvider}, adding or
   * removing calendar events to/from the specified Google Calendar depending on whether a session
   * is in the user's schedule or not.
   */
  private ArrayList<ContentProviderOperation> processAllSessionsCalendar(
      ContentResolver resolver, final long calendarId) {

    ArrayList<ContentProviderOperation> batch = new ArrayList<ContentProviderOperation>();

    // Unable to find the Calendar associated with the user. Stop here.
    if (calendarId == INVALID_CALENDAR_ID) {
      return batch;
    }

    // Retrieves all sessions. For each session, add to Calendar if starred and attempt to
    // remove from Calendar if unstarred.
    Cursor cursor =
        resolver.query(
            ScheduleContract.Sessions.CONTENT_URI, SessionsQuery.PROJECTION, null, null, null);

    if (cursor != null) {
      while (cursor.moveToNext()) {
        Uri uri =
            ScheduleContract.Sessions.buildSessionUri(Long.valueOf(cursor.getLong(0)).toString());
        boolean isAddEvent = (cursor.getInt(SessionsQuery.SESSION_IN_MY_SCHEDULE) == 1);
        if (isAddEvent) {
          batch.addAll(
              processSessionCalendar(
                  resolver,
                  calendarId,
                  isAddEvent,
                  uri,
                  cursor.getLong(SessionsQuery.SESSION_START),
                  cursor.getLong(SessionsQuery.SESSION_END),
                  cursor.getString(SessionsQuery.SESSION_TITLE),
                  cursor.getString(SessionsQuery.ROOM_NAME)));
        }
      }
      cursor.close();
    }

    return batch;
  }