use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.
the class PeopleEventsSearchTest method aYearFromNow.
private static TimePeriod aYearFromNow() {
Date today = Date.Companion.today();
Date aYearFromNow = today.addDay(364);
return TimePeriod.Companion.between(today, aYearFromNow);
}
use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.
the class DateTest method givenAEndOfTheYearDate_whenAddingOneDay_thenTheFirstDayOftheNextYearIsReturned.
@Test
public void givenAEndOfTheYearDate_whenAddingOneDay_thenTheFirstDayOftheNextYearIsReturned() {
Date lastDayOfYear = Date.Companion.on(31, DECEMBER, 1990);
Date firstDayOfNextYear = lastDayOfYear.addDay(1);
assertThat(firstDayOfNextYear.getMonth()).isEqualTo(1);
assertThat(firstDayOfNextYear.getDayOfMonth()).isEqualTo(1);
int nextYear = lastDayOfYear.getYear() + 1;
assertThat(firstDayOfNextYear.getYear()).isEqualTo(nextYear);
}
use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.
the class TodayAppWidgetProvider method updateForDate.
private void updateForDate(Context context, final AppWidgetManager appWidgetManager, int[] appWidgetIds, ContactEventsOnADate contactEvents) {
Date eventDate = contactEvents.getDate();
Date date = Date.Companion.on(eventDate.getDayOfMonth(), eventDate.getMonth(), Date.Companion.today().getYear());
Intent intent = HomeActivity.getStartIntent(context);
intent.setData(Uri.parse(String.valueOf(date.hashCode())));
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
String title = labelOf(date);
String label = NaturalLanguageUtils.joinContacts(strings, contactEvents.getContacts(), 2);
WidgetVariant selectedVariant = preferences.getSelectedVariant();
TransparencyColorCalculator transparencyColorCalculator = new TransparencyColorCalculator();
float opacity = preferences.getOppacityLevel();
int selectedTextColor = context.getResources().getColor(selectedVariant.getTextColor());
WidgetColorCalculator calculator = new WidgetColorCalculator(selectedTextColor);
int finalHeaderColor = calculator.getColor(Date.Companion.today(), date);
int avatarSizeInPx = context.getResources().getDimensionPixelSize(R.dimen.widget_avatar_size);
for (int appWidgetId : appWidgetIds) {
// Get the layout for the App Widget and attach an on-click listener
// to the button
final RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_today);
remoteViews.setTextViewText(R.id.upcoming_widget_header, title);
remoteViews.setTextViewText(R.id.upcoming_widget_events_text, label);
remoteViews.setTextColor(R.id.upcoming_widget_events_text, selectedTextColor);
remoteViews.setTextColor(R.id.upcoming_widget_header, finalHeaderColor);
int background = context.getResources().getColor(selectedVariant.getBackgroundColorResId());
int backgroundColor = transparencyColorCalculator.calculateColor(background, opacity);
remoteViews.setInt(R.id.upcoming_widget_background_image, "setBackgroundColor", backgroundColor);
remoteViews.setOnClickPendingIntent(R.id.upcoming_widget_background, pendingIntent);
appWidgetManager.updateAppWidget(appWidgetId, remoteViews);
widgetImageLoader.loadPicture(contactEvents.getContacts(), appWidgetId, remoteViews, avatarSizeInPx);
}
}
use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.
the class QueryUpcomingPeopleEventsTask method doInBackground.
@Override
protected Optional<ContactEventsOnADate> doInBackground(Object... params) {
Date today = Date.Companion.today();
Date date = eventsProvider.findClosestEventDateOnOrAfter(today);
if (date != null) {
return new Optional<>(eventsProvider.fetchEventsOn(date));
}
return Optional.absent();
}
use of com.alexstyl.specialdates.date.Date in project Memento-Calendar by alexstyl.
the class NamedaysList method indexOf.
private int indexOf(Date date) {
for (int i = 0; i < namedays.size(); i++) {
NamesInADate inlistDate = namedays.get(i);
Date comparingDate = inlistDate.getDate();
if (isRecurringEvent(comparingDate) && areMatching(comparingDate, date)) {
return i;
} else if (comparingDate.equals(date)) {
return i;
}
}
return -1;
}
Aggregations