/** Ensures that any all day events are converted to UTC before a VIEW_EVENT command is sent. */ private void sendViewEvent(AgendaItem item, long selectedTime) { long startTime; long endTime; if (item.allDay) { startTime = Utils.convertAlldayLocalToUTC(null, item.begin, mTimeZone); endTime = Utils.convertAlldayLocalToUTC(null, item.end, mTimeZone); } else { startTime = item.begin; endTime = item.end; } if (DEBUGLOG) { Log.d(TAG, "Sent (AgendaWindowAdapter): VIEW EVENT: " + new Date(startTime)); } CalendarController.getInstance(mContext) .sendEventRelatedEventWithExtra( this, EventType.VIEW_EVENT, item.id, startTime, endTime, 0, 0, CalendarController.EventInfo.buildViewExtraLong( Attendees.ATTENDEE_STATUS_NONE, item.allDay), selectedTime); }
public AgendaWindowAdapter( Context context, AgendaListView agendaListView, boolean showEventOnStart) { mContext = context; mResources = context.getResources(); mSelectedItemBackgroundColor = mResources.getColor(R.color.agenda_selected_background_color); mSelectedItemTextColor = mResources.getColor(R.color.agenda_selected_text_color); mItemRightMargin = mResources.getDimension(R.dimen.agenda_item_right_margin); mIsTabletConfig = Utils.getConfigBool(mContext, R.bool.tablet_config); mTimeZone = Utils.getTimeZone(context, mTZUpdater); mAgendaListView = agendaListView; mQueryHandler = new QueryHandler(context.getContentResolver()); mStringBuilder = new StringBuilder(50); mFormatter = new Formatter(mStringBuilder, Locale.getDefault()); mShowEventOnStart = showEventOnStart; // Implies there is no sticky header if (!mShowEventOnStart) { mStickyHeaderSize = 0; } mSearchQuery = null; LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); mHeaderView = (TextView) inflater.inflate(R.layout.agenda_header_footer, null); mFooterView = (TextView) inflater.inflate(R.layout.agenda_header_footer, null); mHeaderView.setText(R.string.loading); mAgendaListView.addHeaderView(mHeaderView); }
@Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; QuerySpec other = (QuerySpec) obj; if (end != other.end || queryStartMillis != other.queryStartMillis || queryType != other.queryType || start != other.start || Utils.equals(searchQuery, other.searchQuery) || id != other.id) { return false; } if (goToTime != null) { if (goToTime.toMillis(false) != other.goToTime.toMillis(false)) { return false; } } else { if (other.goToTime != null) { return false; } } return true; }
@Override public void onHandleIntent(Intent intent) { long eventId = intent.getLongExtra(AlertUtils.EVENT_ID_KEY, -1); long eventStart = intent.getLongExtra(AlertUtils.EVENT_START_KEY, -1); long eventEnd = intent.getLongExtra(AlertUtils.EVENT_END_KEY, -1); long snoozeDelay = intent.getLongExtra(AlertUtils.SNOOZE_DELAY_KEY, Utils.getDefaultSnoozeDelayMs(this)); // The ID reserved for the expired notification digest should never be passed in // here, so use that as a default. int notificationId = intent.getIntExtra( AlertUtils.NOTIFICATION_ID_KEY, AlertUtils.EXPIRED_GROUP_NOTIFICATION_ID); if (eventId != -1) { ContentResolver resolver = getContentResolver(); // Remove notification if (notificationId != AlertUtils.EXPIRED_GROUP_NOTIFICATION_ID) { NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); nm.cancel(notificationId); } // Dismiss current alarm Uri uri = CalendarAlerts.CONTENT_URI; String selection = CalendarAlerts.STATE + "=" + CalendarAlerts.STATE_FIRED + " AND " + CalendarAlerts.EVENT_ID + "=" + eventId; ContentValues dismissValues = new ContentValues(); dismissValues.put(PROJECTION[COLUMN_INDEX_STATE], CalendarAlerts.STATE_DISMISSED); resolver.update(uri, dismissValues, selection, null); // Add a new alarm long alarmTime = System.currentTimeMillis() + snoozeDelay; ContentValues values = AlertUtils.makeContentValues(eventId, eventStart, eventEnd, alarmTime, 0); resolver.insert(uri, values); AlertUtils.scheduleAlarm( SnoozeAlarmsService.this, AlertUtils.createAlarmManager(this), alarmTime); } AlertService.updateAlertNotification(this); stopSelf(); }
@Override public void run() { mTimeZone = Utils.getTimeZone(mContext, this); notifyDataSetChanged(); }
static { if (!Utils.isJellybeanOrLater()) { PROJECTION[INDEX_COLOR] = Instances.CALENDAR_COLOR; } }