Search in sources :

Example 1 with DayOfWeek

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

Example 2 with DayOfWeek

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);
    }
}
Also used : DayOfWeek(org.threeten.bp.DayOfWeek) TextView(android.widget.TextView)

Example 3 with DayOfWeek

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;
        }
    }
}
Also used : DayOfWeek(org.threeten.bp.DayOfWeek) Paint(android.graphics.Paint)

Example 4 with DayOfWeek

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

Example 5 with DayOfWeek

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

DayOfWeek (org.threeten.bp.DayOfWeek)5 Paint (android.graphics.Paint)1 Nullable (android.support.annotation.Nullable)1 TabLayout (android.support.design.widget.TabLayout)1 View (android.view.View)1 TextView (android.widget.TextView)1 MainActivity (kogvet.eye.MainActivity)1 Instant (org.threeten.bp.Instant)1 LocalDate (org.threeten.bp.LocalDate)1 TemporalField (org.threeten.bp.temporal.TemporalField)1