public void refreshAllActions() { try { List<RecurringAction> actions = getActiveActions(); recreateAppointments(actions); } catch (SQLException e) { e.printStackTrace(); } finally { databaseHelper.close(); } }
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(); } }
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(); }
public void refreshAction(RecurringAction action) { List<RecurringAction> actionList = new LinkedList<>(); actionList.add(action); recreateAppointments(actionList); databaseHelper.close(); }