Search in sources :

Example 1 with Date

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();
}
Also used : Date(com.alexstyl.specialdates.date.Date) NamesInADate(com.alexstyl.specialdates.events.namedays.NamesInADate)

Example 2 with Date

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);
    }
}
Also used : ContactEvent(com.alexstyl.specialdates.date.ContactEvent) Date(com.alexstyl.specialdates.date.Date) NamesInADate(com.alexstyl.specialdates.events.namedays.NamesInADate)

Example 3 with Date

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;
}
Also used : OnUpcomingEventClickedListener(com.alexstyl.specialdates.upcoming.view.OnUpcomingEventClickedListener) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) UpcomingEventsView(com.alexstyl.specialdates.UpcomingEventsView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) Date(com.alexstyl.specialdates.date.Date) Contact(com.alexstyl.specialdates.contact.Contact)

Example 4 with Date

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);
    }
}
Also used : Date(com.alexstyl.specialdates.date.Date) Test(org.junit.Test)

Example 5 with Date

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);
}
Also used : ContactEvent(com.alexstyl.specialdates.date.ContactEvent) Date(com.alexstyl.specialdates.date.Date) Contact(com.alexstyl.specialdates.contact.Contact) Test(org.junit.Test)

Aggregations

Date (com.alexstyl.specialdates.date.Date)53 Test (org.junit.Test)34 ContactEvent (com.alexstyl.specialdates.date.ContactEvent)12 Contact (com.alexstyl.specialdates.contact.Contact)6 ContactEventsOnADate (com.alexstyl.specialdates.events.peopleevents.ContactEventsOnADate)6 ArrayList (java.util.ArrayList)4 View (android.view.View)3 Intent (android.content.Intent)2 RecyclerView (android.support.v7.widget.RecyclerView)2 TextView (android.widget.TextView)2 NamedayBundle (com.alexstyl.specialdates.events.namedays.NamedayBundle)2 NamedaysList (com.alexstyl.specialdates.events.namedays.NamedaysList)2 NamesInADate (com.alexstyl.specialdates.events.namedays.NamesInADate)2 Calendar (java.util.Calendar)2 DatePickerDialog (android.app.DatePickerDialog)1 PendingIntent (android.app.PendingIntent)1 DialogInterface (android.content.DialogInterface)1 Preference (android.preference.Preference)1 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)1 RemoteViews (android.widget.RemoteViews)1