Search in sources :

Example 16 with LocalDate

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);
    }
}
Also used : LocalDate(org.threeten.bp.LocalDate)

Example 17 with LocalDate

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);
    }
}
Also used : LocalDate(org.threeten.bp.LocalDate) SuppressLint(android.annotation.SuppressLint)

Example 18 with LocalDate

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();
}
Also used : LocalDate(org.threeten.bp.LocalDate)

Example 19 with LocalDate

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;
}
Also used : DayOfWeek(org.threeten.bp.DayOfWeek) TemporalField(org.threeten.bp.temporal.TemporalField) TabLayout(android.support.design.widget.TabLayout) MainActivity(kogvet.eye.MainActivity) View(android.view.View) LocalDate(org.threeten.bp.LocalDate) Nullable(android.support.annotation.Nullable)

Example 20 with LocalDate

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();
}
Also used : LocalDateTime(org.threeten.bp.LocalDateTime) ZonedDateTime(org.threeten.bp.ZonedDateTime) Instant(org.threeten.bp.Instant) LocalDate(org.threeten.bp.LocalDate)

Aggregations

LocalDate (org.threeten.bp.LocalDate)20 SuppressLint (android.annotation.SuppressLint)4 ZonedDateTime (org.threeten.bp.ZonedDateTime)4 Nullable (android.support.annotation.Nullable)2 View (android.view.View)2 HighlightWeekendsDecorator (com.prolificinteractive.materialcalendarview.sample.decorators.HighlightWeekendsDecorator)2 MySelectorDecorator (com.prolificinteractive.materialcalendarview.sample.decorators.MySelectorDecorator)2 MainActivity (kogvet.eye.MainActivity)2 Test (org.junit.Test)2 TemporalField (org.threeten.bp.temporal.TemporalField)2 DatePickerDialog (android.app.DatePickerDialog)1 TimePickerDialog (android.app.TimePickerDialog)1 NonNull (android.support.annotation.NonNull)1 TabLayout (android.support.design.widget.TabLayout)1 DatePicker (android.widget.DatePicker)1 TimePicker (android.widget.TimePicker)1 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Date (java.util.Date)1