use of org.threeten.bp.LocalDate in project material-calendarview by prolificinteractive.
the class CalendarPagerView method buildWeekDays.
private void buildWeekDays(LocalDate calendar) {
LocalDate local = calendar;
for (int i = 0; i < DEFAULT_DAYS_IN_WEEK; i++) {
WeekDayView weekDayView = new WeekDayView(getContext(), local.getDayOfWeek());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
weekDayView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO);
}
weekDayViews.add(weekDayView);
addView(weekDayView);
local = local.plusDays(1);
}
}
use of org.threeten.bp.LocalDate in project material-calendarview by prolificinteractive.
the class WeekView method buildDayViews.
@Override
protected void buildDayViews(final Collection<DayView> dayViews, final LocalDate calendar) {
LocalDate temp = calendar;
for (int i = 0; i < DEFAULT_DAYS_IN_WEEK; i++) {
addDayView(dayViews, temp);
temp = temp.plusDays(1);
}
}
use of org.threeten.bp.LocalDate in project material-calendarview by prolificinteractive.
the class CalendarPagerAdapter method selectRange.
/**
* Clear the previous selection, select the range of days from first to last, and finally
* invalidate. First day should be before last day, otherwise the selection won't happen.
*
* @param first The first day of the range.
* @param last The last day in the range.
* @see CalendarPagerAdapter#setDateSelected(CalendarDay, boolean)
*/
public void selectRange(final CalendarDay first, final CalendarDay last) {
selectedDates.clear();
// Copy to start from the first day and increment
LocalDate temp = LocalDate.of(first.getYear(), first.getMonth(), first.getDay());
// for comparison
final LocalDate end = last.getDate();
while (temp.isBefore(end) || temp.equals(end)) {
selectedDates.add(CalendarDay.from(temp));
temp = temp.plusDays(1);
}
invalidateSelectedDates();
}
use of org.threeten.bp.LocalDate in project Eye by tommyolsson.
the class TabFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_tab_layout, container, false);
((MainActivity) getActivity()).setActionBarTitle(getResources().getString(R.string.menu_calendar));
((MainActivity) getActivity()).showBackButton();
final TabLayout tabLayout = view.findViewById(R.id.tabLayout);
DayOfWeek weekDay = LocalDateTime.now().getDayOfWeek();
tabLayout.addTab(tabLayout.newTab().setText(weekDay.getDisplayName(TextStyle.FULL, Locale.getDefault())));
LocalDate date = LocalDate.now();
TemporalField woy = WeekFields.of(Locale.getDefault()).weekOfWeekBasedYear();
int weekNumber = date.get(woy);
tabLayout.addTab(tabLayout.newTab().setText("Vecka " + weekNumber));
viewPager = view.findViewById(R.id.viewpager);
PagerAdapter pagerAdapter = new PagerAdapter(getChildFragmentManager(), allEvents);
viewPager.setAdapter(pagerAdapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
return view;
}
use of org.threeten.bp.LocalDate in project SeriesGuide by UweTrottmann.
the class TimeTools method parseEpisodeReleaseDate.
/**
* Calculates the episode release date time as a millisecond instant. Adjusts for time zone
* effects on release time, e.g. delays between time zones (e.g. in the United States) and DST.
*
* @param showTimeZone See {@link #getDateTimeZone(String)}.
* @param showReleaseTime See {@link #getShowReleaseTime(int)}.
* @return -1 if no conversion was possible. Otherwise, any other long value (may be negative!).
*/
public static long parseEpisodeReleaseDate(@NonNull ZoneId showTimeZone, @Nullable Date releaseDate, @NonNull LocalTime showReleaseTime, @Nullable String showCountry, @Nullable String showNetwork, @NonNull String deviceTimeZone) {
if (releaseDate == null) {
return Constants.EPISODE_UNKNOWN_RELEASE;
}
// Get local date: tmdb-java parses date string to Date using SimpleDateFormat,
// which uses the default time zone.
Instant instant = Instant.ofEpochMilli(releaseDate.getTime());
LocalDate localDate = instant.atZone(ZoneId.systemDefault()).toLocalDate();
// set time
LocalDateTime localDateTime = localDate.atTime(showReleaseTime);
localDateTime = handleHourPastMidnight(showCountry, showNetwork, localDateTime);
// get a valid datetime in the show time zone, this auto-forwards time if inside DST gap
ZonedDateTime dateTime = localDateTime.atZone(showTimeZone);
// handle time zone effects on release time for US shows (only if device is set to US zone)
if (deviceTimeZone.startsWith(TIMEZONE_ID_PREFIX_AMERICA)) {
dateTime = applyUnitedStatesCorrections(showCountry, deviceTimeZone, dateTime);
}
return dateTime.toInstant().toEpochMilli();
}
Aggregations