use of org.threeten.bp.DayOfWeek in project SeriesGuide by UweTrottmann.
the class TimeTools method isSameWeekDay.
public static boolean isSameWeekDay(Date episodeDateTime, @Nullable Date showDateTime, int weekDay) {
if (weekDay == RELEASE_WEEKDAY_DAILY) {
return true;
}
if (showDateTime == null || weekDay == RELEASE_WEEKDAY_UNKNOWN) {
return false;
}
Instant showInstant = Instant.ofEpochMilli(showDateTime.getTime());
DayOfWeek showDayOfWeek = LocalDateTime.ofInstant(showInstant, ZoneId.systemDefault()).getDayOfWeek();
Instant episodeInstant = Instant.ofEpochMilli(episodeDateTime.getTime());
DayOfWeek episodeDayOfWeek = LocalDateTime.ofInstant(episodeInstant, ZoneId.systemDefault()).getDayOfWeek();
return episodeDayOfWeek == showDayOfWeek;
}
use of org.threeten.bp.DayOfWeek in project Eye by tommyolsson.
the class FragmentWeek method underlineDayInWeek.
/* Underlines the current day in the UI*/
private void underlineDayInWeek(View view) {
DayOfWeek weekDay = LocalDateTime.now().getDayOfWeek();
TextView textView = null;
switch(weekDay) {
case MONDAY:
textView = view.findViewById(R.id.monday);
break;
case TUESDAY:
textView = view.findViewById(R.id.tuesday);
break;
case WEDNESDAY:
textView = view.findViewById(R.id.wednesday);
break;
case THURSDAY:
textView = view.findViewById(R.id.thursday);
break;
case FRIDAY:
textView = view.findViewById(R.id.friday);
break;
default:
break;
}
if (textView != null) {
textView.setTypeface(null, Typeface.BOLD);
textView.setPaintFlags(textView.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
}
}
use of org.threeten.bp.DayOfWeek in project Eye by tommyolsson.
the class FragmentWeek method getWeekDayEvents.
/* Puts all events in the correct arraylist according to weekday */
private void getWeekDayEvents(ArrayList<EventClass> allEvents) {
activitiesMonday = new ArrayList<>();
activitiesTuesday = new ArrayList<>();
activitiesWednesday = new ArrayList<>();
activitiesThursday = new ArrayList<>();
activitiesFriday = new ArrayList<>();
for (int i = 0; i < allEvents.size(); i++) {
DayOfWeek weekDay = allEvents.get(i).getStartTimeObj().getDayOfWeek();
switch(weekDay) {
case MONDAY:
activitiesMonday.add(allEvents.get(i));
break;
case TUESDAY:
activitiesTuesday.add(allEvents.get(i));
break;
case WEDNESDAY:
activitiesWednesday.add(allEvents.get(i));
break;
case THURSDAY:
activitiesThursday.add(allEvents.get(i));
break;
case FRIDAY:
activitiesFriday.add(allEvents.get(i));
break;
default:
break;
}
}
}
use of org.threeten.bp.DayOfWeek in project Douya by DreaminginCodeZH.
the class CalendarDay method getDayOfMonthColor.
public int getDayOfMonthColor(int weekdayColor, int weekendColor) {
DayOfWeek dayOfWeek = getDate().getDayOfWeek();
boolean isWeekend = dayOfWeek == DayOfWeek.SATURDAY || dayOfWeek == DayOfWeek.SUNDAY;
return isWeekend ? weekendColor : weekdayColor;
}
use of org.threeten.bp.DayOfWeek 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