use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.
the class DailyReminderIntentService method getDayDateToDisplay.
private Date getDayDateToDisplay() {
if (BuildConfig.DEBUG) {
DailyReminderDebugPreferences preferences = DailyReminderDebugPreferences.newInstance(this);
if (preferences.isFakeDateEnabled()) {
Date selectedDate = preferences.getSelectedDate();
Log.d("Using DEBUG date to display: " + selectedDate);
return selectedDate;
}
}
return Date.Companion.today();
}
use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.
the class DailyReminderIntentService method onHandleIntent.
@Override
protected void onHandleIntent(Intent intent) {
Date today = getDayDateToDisplay();
if (hasContactPermission()) {
List<ContactEvent> celebrationDate = peopleEventsProvider.fetchEventsBetween(TimePeriod.Companion.between(today, today));
if (containsAnyContactEvents(celebrationDate)) {
notifier.forDailyReminder(today, celebrationDate);
}
}
if (namedaysAreEnabledForAllCases()) {
notifyForNamedaysFor(today);
}
if (bankholidaysAreEnabled()) {
notifyForBankholidaysFor(today);
}
DailyReminderPreferences preferences = DailyReminderPreferences.newInstance(this);
if (preferences.isEnabled()) {
new DailyReminderScheduler(AlarmManagerCompat.from(this), this).setupReminder(preferences);
}
}
use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.
the class UpcomingEventsFragment method onCreateView.
@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final View view = inflater.inflate(R.layout.fragment_upcoming_events, container, false);
root = Views.findById(view, R.id.root);
progressBar = Views.findById(view, R.id.upcoming_events_progress);
emptyView = Views.findById(view, R.id.upcoming_events_emptyview);
upcomingList = Views.findById(view, R.id.upcoming_events_list);
upcomingList.setHasFixedSize(true);
upcomingList.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false));
upcomingList.addItemDecoration(new UpcomingEventsDecorator(getResources().getDimensionPixelSize(R.dimen.upcoming_event_header_vertical_spacing), getResources().getDimensionPixelSize(R.dimen.upcoming_event_vertical_spacing)));
adapter = new UpcomingEventsAdapter(new UpcomingViewHolderFactory(inflater, imageLoader), new OnUpcomingEventClickedListener() {
@Override
public void onContactClicked(Contact contact) {
navigator.toContactDetails(contact, getActivity());
}
@Override
public void onNamedayClicked(Date date) {
navigator.toDateDetails(date, getActivity());
}
});
adapter.setHasStableIds(true);
upcomingList.setAdapter(adapter);
return view;
}
use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.
the class RomanianEasterSpecialCalculatorTest method calculatesSundayBeforeEasterCorrectly.
@Test
public void calculatesSundayBeforeEasterCorrectly() {
RomanianEasterSpecialCalculator calculator = new RomanianEasterSpecialCalculator(OrthodoxEasterCalculator.INSTANCE);
List<Date> expectedDates = buildExpectedDates();
for (Date expectedDate : expectedDates) {
Date actualDate = calculator.calculateSpecialRomanianDayForYear(expectedDate.getYear());
assertThat(expectedDate).isEqualTo(actualDate);
}
}
use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.
the class PeopleDynamicNamedaysProviderTest method gettingSpecialNamedaysOnSpecificDateOnlyReturnsTheEventsForThatDate.
@Test
public void gettingSpecialNamedaysOnSpecificDateOnlyReturnsTheEventsForThatDate() {
List<Contact> testContacts = createSomeContacts();
testContacts.add(EASTER_CELEBRATING_CONTACT);
when(mockContactsProvider.getAllContacts()).thenReturn(testContacts);
Date easterDate = OrthodoxEasterCalculator.INSTANCE.calculateEasterForYear(YEAR);
List<ContactEvent> contactEvents = calculator.fetchEventsBetween(TimePeriod.Companion.between(easterDate, easterDate));
assertThat(contactEvents).hasSize(1);
assertThat(contactEvents.get(0).getContact()).isEqualTo(EASTER_CELEBRATING_CONTACT);
}
Aggregations