Search in sources :

Example 1 with TemporalField

use of org.threeten.bp.temporal.TemporalField in project material-calendarview by prolificinteractive.

the class CalendarPagerView method resetAndGetWorkingCalendar.

protected LocalDate resetAndGetWorkingCalendar() {
    final TemporalField firstDayOfWeek = WeekFields.of(this.firstDayOfWeek, 1).dayOfWeek();
    final LocalDate temp = getFirstViewDay().getDate().with(firstDayOfWeek, 1);
    int dow = temp.getDayOfWeek().getValue();
    int delta = getFirstDayOfWeek().getValue() - dow;
    // If the delta is positive, we want to remove a week
    boolean removeRow = showOtherMonths(showOtherDates) ? delta >= 0 : delta > 0;
    if (removeRow) {
        delta -= DEFAULT_DAYS_IN_WEEK;
    }
    return temp.plusDays(delta);
}
Also used : TemporalField(org.threeten.bp.temporal.TemporalField) LocalDate(org.threeten.bp.LocalDate)

Example 2 with TemporalField

use of org.threeten.bp.temporal.TemporalField 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)

Aggregations

LocalDate (org.threeten.bp.LocalDate)2 TemporalField (org.threeten.bp.temporal.TemporalField)2 Nullable (android.support.annotation.Nullable)1 TabLayout (android.support.design.widget.TabLayout)1 View (android.view.View)1 MainActivity (kogvet.eye.MainActivity)1 DayOfWeek (org.threeten.bp.DayOfWeek)1