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);
}
use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.
the class DebugFragment method onCreate.
@Override
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
DebugAppComponent debugAppComponent = ((DebugApplication) getActivity().getApplication()).getDebugAppComponent();
debugAppComponent.inject(this);
addPreferencesFromResource(R.xml.preference_debug);
dailyReminderDebugPreferences = DailyReminderDebugPreferences.newInstance(getActivity());
findPreference(R.string.key_debug_refresh_db).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
DebugPeopleEventsUpdater.newInstance(getActivity(), namedayUserSettings, contactsProvider, tracker, dateParser).refresh();
showToast("Refreshing Database");
return true;
}
});
findPreference(R.string.key_debug_refresh_widget).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
refresher.refreshViews();
showToast("Widget(s) refreshed");
return true;
}
});
findPreference(R.string.key_debug_daily_reminder_date_enable).setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
dailyReminderDebugPreferences.setEnabled((boolean) newValue);
return true;
}
});
findPreference(R.string.key_debug_daily_reminder_date).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Date today = dailyReminderDebugPreferences.getSelectedDate();
DatePickerDialog datePickerDialog = new DatePickerDialog(getActivity(), onDailyReminderDateSelectedListener, today.getYear(), today.getMonth() - 1, today.getDayOfMonth());
datePickerDialog.show();
return false;
}
});
findPreference(R.string.key_debug_daily_reminder).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
DailyReminderIntentService.startService(getActivity());
showToast("Daily Reminder Triggered");
return true;
}
});
findPreference(R.string.key_debug_start_calendar).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
startDateIntent();
return true;
}
});
findPreference(R.string.key_debug_trigger_wear_service).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
new WearSyncUpcomingEventsView(getActivity()).reloadUpcomingEventsView();
return true;
}
});
findPreference(R.string.key_debug_reset_donations).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
DebugDonationPreferences.newInstance(preference.getContext(), monitor).reset();
Toast.makeText(preference.getContext(), "Donations reset. You should see ads from now on", Toast.LENGTH_SHORT).show();
return true;
}
});
findPreference(R.string.key_debug_trigger_support).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
DebugPreferences.newInstance(preference.getContext(), R.string.pref_call_to_rate).wipe();
new AskForSupport(preference.getContext()).requestForRatingSooner();
String message = "Support triggered. You should now see a prompt to rate the app when you launch it";
showToast(message);
return true;
}
});
findPreference(R.string.key_debug_facebook).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(getActivity(), FacebookLogInActivity.class);
startActivity(intent);
return true;
}
});
findPreference(R.string.key_debug_facebook_fetch_friends).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent intent = new Intent(getActivity(), FacebookFriendsIntentService.class);
getActivity().startService(intent);
return true;
}
});
findPreference(R.string.key_debug_open_contact).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(contactPickerIntent, RESULT_PICK_CONTACT);
return true;
}
});
}
Aggregations