Example usage for android.text.format Time SUNDAY

List of usage examples for android.text.format Time SUNDAY

Introduction

In this page you can find the example usage for android.text.format Time SUNDAY.

Prototype

int SUNDAY

To view the source code for android.text.format Time SUNDAY.

Click Source Link

Usage

From source file:Main.java

/**
 * Get first day of week as android.text.format.Time constant.
 *
 * @return the first day of week in android.text.format.Time
 *//*  w w  w. jav a  2 s . c  om*/
public static int getFirstDayOfWeek(Context context) {
    int startDay = Calendar.SUNDAY;

    if (startDay == Calendar.SATURDAY) {
        return Time.SATURDAY;
    } else if (startDay == Calendar.MONDAY) {
        return Time.MONDAY;
    } else {
        return Time.SUNDAY;
    }
}

From source file:Main.java

/**
 * Get first day of week as android.text.format.Time constant.
 *
 * @return the first day of week in android.text.format.Time
 *///w w  w .  ja va  2  s. c  o  m
public static int getFirstDayOfWeek() {
    int startDay = Calendar.getInstance().getFirstDayOfWeek();

    if (startDay == Calendar.SATURDAY) {
        return Time.SATURDAY;
    } else if (startDay == Calendar.MONDAY) {
        return Time.MONDAY;
    } else {
        return Time.SUNDAY;
    }
}

From source file:Main.java

/**
 * Converts the day of the week from android.text.format.Time to java.util.Calendar
 *//*w  w w . j  av a2  s . c o  m*/
public static int convertDayOfWeekFromTimeToCalendar(int timeDayOfWeek) {
    switch (timeDayOfWeek) {
    case Time.MONDAY:
        return Calendar.MONDAY;
    case Time.TUESDAY:
        return Calendar.TUESDAY;
    case Time.WEDNESDAY:
        return Calendar.WEDNESDAY;
    case Time.THURSDAY:
        return Calendar.THURSDAY;
    case Time.FRIDAY:
        return Calendar.FRIDAY;
    case Time.SATURDAY:
        return Calendar.SATURDAY;
    case Time.SUNDAY:
        return Calendar.SUNDAY;
    default:
        throw new IllegalArgumentException("Argument must be between Time.SUNDAY and " + "Time.SATURDAY");
    }
}

From source file:Main.java

/**
 * Get first day of week as android.text.format.Time constant.
 *
 * @return the first day of week in android.text.format.Time
 *//*from w  w w . ja va  2  s  .  c  o  m*/
public static int getFirstDayOfWeek(Context context) {
    int startDay = Calendar.getInstance().getFirstDayOfWeek();

    if (startDay == Calendar.SATURDAY) {
        return Time.SATURDAY;
    } else if (startDay == Calendar.MONDAY) {
        return Time.MONDAY;
    } else {
        return Time.SUNDAY;
    }
}

From source file:edu.htl3r.schoolplanner.gui.timetable.WeekView.java

private DateTime getMonday() {
    DateTime d = DateTimeUtils.getNow();

    if (d.getWeekDay() == Time.SUNDAY) {
        d.increaseDay();/*from   www.  j  a v a 2s  .  c  om*/
        return d;
    }

    while (d.getWeekDay() != Time.MONDAY) {
        d.decreaseDay();
    }
    return d;
}

From source file:edu.htl3r.schoolplanner.gui.timetable.WeekView.java

public void setDateforDialog(DateTime date) {
    DateTime d = date.clone();/*www .j av  a  2  s. c o m*/
    d.setHour(0);
    d.setMinute(0);
    d.setSecond(0);

    Toast.makeText(this, date.getDay() + "." + date.getMonth() + "." + date.getYear(), Toast.LENGTH_SHORT)
            .show();
    if (d.getWeekDay() == Time.SUNDAY) {
        d.increaseDay();
    } else {
        while (d.getWeekDay() != Time.MONDAY) {
            d.decreaseDay();
        }
    }

    DateTime now = getMonday().clone();
    now.setHour(0);
    now.setMinute(0);
    now.setSecond(0);

    int count = 0;

    if (d.compareTo(now) < 0) {
        while (d.compareTo(now) != 0) {
            now.set(now.getDay() - 7, now.getMonth(), now.getYear());
            count--;
        }
    } else if (d.compareTo(now) > 0) {
        while (d.compareTo(now) != 0) {
            now.set(now.getDay() + 7, now.getMonth(), now.getYear());
            count++;
        }
    }
    myViewPager.setCurrentItem(50 + count);
}

From source file:com.xandy.calendar.month.SimpleDayPickerFragment.java

/**
 * Fixes the day names header to provide correct spacing and updates the
 * label text. Override this to set up a custom header.
 *///w  ww  .  ja v  a 2s  .  c  o  m
protected void updateHeader() {
    TextView label = (TextView) mDayNamesHeader.findViewById(R.id.wk_label);
    if (mShowWeekNumber) {
        label.setVisibility(View.VISIBLE);
    } else {
        label.setVisibility(View.GONE);
    }
    int offset = mFirstDayOfWeek - 1;
    for (int i = 1; i < 8; i++) {
        label = (TextView) mDayNamesHeader.getChildAt(i);
        if (i < mDaysPerWeek + 1) {
            int position = (offset + i) % 7;
            label.setText(mDayLabels[position]);
            label.setVisibility(View.VISIBLE);
            if (position == Time.SATURDAY) {
                label.setTextColor(mSaturdayColor);
            } else if (position == Time.SUNDAY) {
                label.setTextColor(mSundayColor);
            } else {
                label.setTextColor(mDayNameColor);
            }
        } else {
            label.setVisibility(View.GONE);
        }
    }
    mDayNamesHeader.invalidate();
}

From source file:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

private void drawDayHeaderLoop(Rect r, Canvas canvas, Paint p) {
    p.setTypeface(mBold);//from  ww w.j a v a  2s . c o m
    p.setTextAlign(Align.RIGHT);
    int cell = mFirstJulianDay;

    String[] dayNames;
    if (mDateStrWidthLong < mCellWidth && mNumDays == 1) {
        dayNames = mDayStrsLong;
    } else if (mDateStrWidth < mCellWidth) {
        dayNames = mDayStrs;
    } else {
        dayNames = mDayStrs2Letter;
    }

    p.setAntiAlias(true);
    for (int day = 0; day < mNumDays; day++, cell++) {
        int dayOfWeek = day + mFirstVisibleDayOfWeek;
        if (dayOfWeek >= 14) {
            dayOfWeek -= 14;
        }

        int color = mCalendarDateBannerTextColor;
        if (mNumDays == 1) {
            if (dayOfWeek == Time.SATURDAY) {
                color = mWeek_saturdayColor;
            } else if (dayOfWeek == Time.SUNDAY) {
                color = mWeek_sundayColor;
            }
        } else {
            final int column = day % 7;
            if (DayUtils.isSaturday(column, mFirstDayOfWeek)) {
                color = mWeek_saturdayColor;
            } else if (DayUtils.isSunday(column, mFirstDayOfWeek)) {
                color = mWeek_sundayColor;
            }
        }

        p.setColor(color);
        if (mNumDays == 1) {
            Time time = new Time();
            time.setJulianDay(mFirstJulianDay);
            String s = SimpleDateFormat.getDateInstance().format(new Date(time.toMillis(false)));
            drawDayHeader(dayNames[dayOfWeek], day, s, canvas, p);
        } else {
            int dateNum = mFirstVisibleDate + day;
            if (dateNum > mMonthLength) {
                dateNum -= mMonthLength;
            }
            drawDayHeader(dayNames[dayOfWeek], day, String.valueOf(dateNum), canvas, p);
        }
    }
    p.setTypeface(null);
}