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);
}
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;
}
Aggregations