Example usage for android.text.format Time MONDAY

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

Introduction

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

Prototype

int MONDAY

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

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
 *//*www  .  j a  va2s.  c o m*/
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.j  a v  a 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  ava  2  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 ww w.  ja v a  2 s  .co  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 w  w  w .j av  a2s. 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();//from www . ja  v  a  2 s  .  co 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:de.tum.in.tumcampus.auxiliary.calendar.DayView.java

private void init(Context context) {
    setFocusable(true);/*from   w ww  .  j  ava 2s  .c o m*/

    // Allow focus in touch mode so that we can do keyboard shortcuts
    // even after we've entered touch mode.
    setFocusableInTouchMode(true);
    setClickable(true);
    setOnCreateContextMenuListener(this);

    mFirstDayOfWeek = Time.MONDAY;

    mCurrentTime = new Time(DayUtils.getTimeZone(context, mTZUpdater));
    long currentTime = System.currentTimeMillis();
    mCurrentTime.set(currentTime);
    mTodayJulianDay = Time.getJulianDay(currentTime, mCurrentTime.gmtoff);

    mEventTextPaint.setTextSize(EVENT_TEXT_FONT_SIZE);
    mEventTextPaint.setTextAlign(Align.LEFT);
    mEventTextPaint.setAntiAlias(true);

    int gridLineColor = 0xff707070;
    Paint p = mSelectionPaint;
    p.setColor(gridLineColor);
    p.setStyle(Style.FILL);
    p.setAntiAlias(false);

    p = mPaint;
    p.setAntiAlias(true);

    // Long day names
    mDayStrsLong = new String[14];

    // Allocate space for 2 weeks worth of weekday names so that we can
    // easily start the week display at any week day.
    mDayStrs = new String[14];

    // Also create an array of 2-letter abbreviations.
    mDayStrs2Letter = new String[14];

    for (int i = Calendar.SUNDAY; i <= Calendar.SATURDAY; i++) {
        int index = i - Calendar.SUNDAY;

        mDayStrsLong[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_LONG).toUpperCase();
        mDayStrsLong[index + 7] = mDayStrsLong[index];
        // e.g. Tue for Tuesday
        mDayStrs[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_MEDIUM).toUpperCase();
        mDayStrs[index + 7] = mDayStrs[index];
        // e.g. Tu for Tuesday
        mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORT).toUpperCase();

        // If we don't have 2-letter day strings, fall back to 1-letter.
        if (mDayStrs2Letter[index].equals(mDayStrs[index])) {
            mDayStrs2Letter[index] = DateUtils.getDayOfWeekString(i, DateUtils.LENGTH_SHORTEST);
        }

        mDayStrs2Letter[index + 7] = mDayStrs2Letter[index];
    }

    // Figure out how much space we need for the 3-letter abbrev names
    // in the worst case.
    p.setTextSize(DATE_HEADER_FONT_SIZE);
    p.setTypeface(mBold);
    String[] dateStrs = { " 28", " 30" };
    mDateStrWidth = computeMaxStringWidth(0, dateStrs, p);
    Time time = new Time();
    time.setJulianDay(mFirstJulianDay);
    String s = SimpleDateFormat.getDateInstance().format(new Date(time.toMillis(false)));
    mDateStrWidthLong = computeMaxStringWidth(0, new String[] { s }, p);
    p.setTextSize(DAY_HEADER_FONT_SIZE);
    mDateStrWidth += computeMaxStringWidth(0, mDayStrs, p);
    mDateStrWidthLong += computeMaxStringWidth(0, mDayStrsLong, p);

    p.setTextSize(HOURS_TEXT_SIZE);
    p.setTypeface(null);
    handleOnResume();

    mAmString = DateUtils.getAMPMString(Calendar.AM).toUpperCase();
    mPmString = DateUtils.getAMPMString(Calendar.PM).toUpperCase();
    String[] ampm = { mAmString, mPmString };
    p.setTextSize(AMPM_TEXT_SIZE);
    mHoursWidth = Math.max(HOURS_MARGIN, computeMaxStringWidth(mHoursWidth, ampm, p) + HOURS_RIGHT_MARGIN);
    mHoursWidth = Math.max(MIN_HOURS_WIDTH, mHoursWidth);

    LayoutInflater inflater;
    inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    Resources.Theme dialogTheme = getResources().newTheme();
    dialogTheme.applyStyle(android.R.style.Theme_Dialog, true);
    TypedArray ta = dialogTheme.obtainStyledAttributes(new int[] { android.R.attr.windowBackground });

    // Catch long clicks for creating a new event
    mBaseDate = new Time(DayUtils.getTimeZone(context, mTZUpdater));
    long millis = System.currentTimeMillis();
    mBaseDate.set(millis);

    mEarliestStartHour = new int[mNumDays];
    mHasAllDayEvent = new boolean[mNumDays];

    // mLines is the array of points used with Canvas.drawLines() in
    // drawGridBackground() and drawAllDayEvents().  Its size depends
    // on the max number of lines that can ever be drawn by any single
    // drawLines() call in either of those methods.
    final int maxGridLines = (24 + 1) // max horizontal lines we might draw
            + (mNumDays + 1); // max vertical lines we might draw
    mLines = new float[maxGridLines * 4];
}