Пример #1
0
 /**
  * Instantiates a new razor server, its services, and starts the scheduler. This can be replaced
  * by a dynamic handler manager but has the benefit of simplicity.
  */
 public RazorServer() {
   super();
   SERVICES.put(Service.ACCOUNT, AccountService.getInstance());
   SERVICES.put(Service.ALERT, AlertService.getInstance());
   SERVICES.put(Service.ASSET, AssetService.getInstance());
   SERVICES.put(Service.ATTRIBUTE, AttributeService.getInstance());
   SERVICES.put(Service.AUDIT, AuditService.getInstance());
   SERVICES.put(Service.CONTRACT, ContractService.getInstance());
   SERVICES.put(Service.FINANCE, FinanceService.getInstance());
   SERVICES.put(Service.JOURNAL, JournalService.getInstance());
   SERVICES.put(Service.IMAGE, ImageService.getInstance());
   SERVICES.put(Service.IMAGETEXT, ImageTextService.getInstance());
   SERVICES.put(Service.LICENSE, LicenseService.getInstance());
   SERVICES.put(Service.LOCATION, LocationService.getInstance());
   SERVICES.put(Service.MAIL, MailService.getInstance());
   SERVICES.put(Service.MONITOR, MonitorService.getInstance());
   SERVICES.put(Service.PARTNER, PartnerService.getInstance());
   SERVICES.put(Service.PARTY, PartyService.getInstance());
   SERVICES.put(Service.PRICE, PriceService.getInstance());
   SERVICES.put(Service.PRODUCT, ProductService.getInstance());
   SERVICES.put(Service.RATE, RateService.getInstance());
   SERVICES.put(Service.REPORT, ReportService.getInstance());
   SERVICES.put(Service.RESERVATION, ReservationService.getInstance());
   SERVICES.put(Service.SESSION, SessionService.getInstance());
   SERVICES.put(Service.SMS, SmsService.getInstance());
   SERVICES.put(Service.TASK, TaskService.getInstance());
   SERVICES.put(Service.TAX, TaxService.getInstance());
   SERVICES.put(Service.TEXT, TextService.getInstance());
   SERVICES.put(Service.WORKFLOW, WorkflowService.getInstance());
   //		startScheduler();
   //		PartnerService.startSchedulers();
 }
  @Override
  protected void onStop() {
    super.onStop();
    AlertService.updateAlertNotification(this);

    if (mCursor != null) {
      mCursor.deactivate();
    }
  }
Пример #3
0
  @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();
  }