Пример #1
0
 public void refreshAllActions() {
   try {
     List<RecurringAction> actions = getActiveActions();
     recreateAppointments(actions);
   } catch (SQLException e) {
     e.printStackTrace();
   } finally {
     databaseHelper.close();
   }
 }
Пример #2
0
 public AppointmentWizard(Context context) {
   this.context = context;
   ContentResolver contentResolver = context.getContentResolver();
   eventRepository = new EventRepository(contentResolver, new CalendarRepository(contentResolver));
   sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
   FreetimeCalculator freetimeCalculator =
       new FreetimeCalculator(
           sharedPref.getLong(
               "pref_resttime_start", SettingsFragment.PREFERENCE_RESTTIME_START_DEFAULT),
           sharedPref.getLong(
               "pref_resttime_end", SettingsFragment.PREFERENCE_RESTTIME_END_DEFAULT));
   appointmentFinder =
       new AppointmentFinder(getCalendarIds(), eventRepository, freetimeCalculator);
   databaseHelper = new DatabaseHelper(context);
   try {
     eventDao = databaseHelper.getEventDao();
     recurringActionDao = databaseHelper.getRecurringActionDao();
   } catch (SQLException e) {
     e.printStackTrace();
   }
 }
Пример #3
0
  public void recreateAppointments(List<RecurringAction> actions) {
    Date startDate = getStartDate();
    Date endDate = getEndDate(startDate, OUTLOOK_DAYS);
    int nrOfAppointments = 0;
    for (RecurringAction recurringAction : actions) {
      removeOldAppointments(recurringAction);
      nrOfAppointments += createAppointmentsForTimeSpan(recurringAction, startDate, endDate);
    }

    notifyUser(nrOfAppointments);

    databaseHelper.close();
  }
Пример #4
0
 public void refreshAction(RecurringAction action) {
   List<RecurringAction> actionList = new LinkedList<>();
   actionList.add(action);
   recreateAppointments(actionList);
   databaseHelper.close();
 }