Java Code Examples for android.text.format.Time#getCurrentTimezone()

The following examples show how to use android.text.format.Time#getCurrentTimezone() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleMonthView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public SimpleMonthView(Context context, TypedArray typedArray)
{
    super(context);

    Resources resources = context.getResources();
    mDayLabelCalendar = Calendar.getInstance();
    mCalendar = Calendar.getInstance();
    today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mDayOfWeekTypeface = "sans_serif";
    mMonthTitleTypeface = "sans_serif";
    mCurrentDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorCurrentDay, resources.getColor(R.color.normal_day));
    mMonthTextColor = typedArray.getColor(R.styleable.DayPickerView_colorMonthName, resources.getColor(R.color.normal_day));
    mDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorDayName, resources.getColor(R.color.normal_day));
    mDayNumColor = typedArray.getColor(R.styleable.DayPickerView_colorNormalDay, resources.getColor(R.color.normal_day));
    mPreviousDayColor = typedArray.getColor(R.styleable.DayPickerView_colorPreviousDay, resources.getColor(R.color.normal_day));
    mSelectedDaysColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayBackground, resources.getColor(R.color.selected_day_background));
    mMonthTitleBGColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayText, resources.getColor(R.color.selected_day_text));

    mDrawRect = typedArray.getBoolean(R.styleable.DayPickerView_drawRoundRect, false);

    mStringBuilder = new StringBuilder(50);

    MINI_DAY_NUMBER_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeDay, resources.getDimensionPixelSize(R.dimen.text_size_day));
    MONTH_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeMonth, resources.getDimensionPixelSize(R.dimen.text_size_month));
    MONTH_DAY_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeDayName, resources.getDimensionPixelSize(R.dimen.text_size_day_name));
    MONTH_HEADER_SIZE = typedArray.getDimensionPixelOffset(R.styleable.DayPickerView_headerMonthHeight, resources.getDimensionPixelOffset(R.dimen.header_month_height));
    DAY_SELECTED_CIRCLE_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_selectedDayRadius, resources.getDimensionPixelOffset(R.dimen.selected_day_radius));

    mRowHeight = ((typedArray.getDimensionPixelSize(R.styleable.DayPickerView_calendarHeight, resources.getDimensionPixelOffset(R.dimen.calendar_height)) - MONTH_HEADER_SIZE) / 6);

    isPrevDayEnabled = typedArray.getBoolean(R.styleable.DayPickerView_enablePreviousDay, true);

    initView();

}
 
Example 2
Source File: SimpleMonthView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
public SimpleMonthView(Context context, TypedArray typedArray)
{
    super(context);

    Resources resources = context.getResources();
    mDayLabelCalendar = Calendar.getInstance();
    mCalendar = Calendar.getInstance();
    today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mDayOfWeekTypeface = "sans_serif";
    mMonthTitleTypeface = "sans_serif";
    mCurrentDayTextColor = typedArray.getColor(R.styleable.DayPickerView_dpv_colorCurrentDay, resources.getColor(R.color.normal_day));
    mMonthTextColor = typedArray.getColor(R.styleable.DayPickerView_dpv_colorMonthName, resources.getColor(R.color.normal_day));
    mDayTextColor = typedArray.getColor(R.styleable.DayPickerView_dpv_colorDayName, resources.getColor(R.color.normal_day));
    mDayNumColor = typedArray.getColor(R.styleable.DayPickerView_dpv_colorNormalDay, resources.getColor(R.color.normal_day));
    mPreviousDayColor = typedArray.getColor(R.styleable.DayPickerView_dpv_colorPreviousDay, resources.getColor(R.color.normal_day));
    mSelectedDaysColor = typedArray.getColor(R.styleable.DayPickerView_dpv_colorSelectedDayBackground, resources.getColor(R.color.selected_day_background));
    mMonthTitleBGColor = typedArray.getColor(R.styleable.DayPickerView_dpv_colorSelectedDayText, resources.getColor(R.color.selected_day_text));

    mDrawRect = typedArray.getBoolean(R.styleable.DayPickerView_dpv_drawRoundRect, false);

    mStringBuilder = new StringBuilder(50);

    MINI_DAY_NUMBER_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_dpv_textSizeDay, resources.getDimensionPixelSize(R.dimen.text_size_day));
    MONTH_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_dpv_textSizeMonth, resources.getDimensionPixelSize(R.dimen.text_size_month));
    MONTH_DAY_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_dpv_textSizeDayName, resources.getDimensionPixelSize(R.dimen.text_size_day_name));
    MONTH_HEADER_SIZE = typedArray.getDimensionPixelOffset(R.styleable.DayPickerView_dpv_headerMonthHeight, resources.getDimensionPixelOffset(R.dimen.header_month_height));
    DAY_SELECTED_CIRCLE_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_dpv_selectedDayRadius, resources.getDimensionPixelOffset(R.dimen.selected_day_radius));

    mRowHeight = ((typedArray.getDimensionPixelSize(R.styleable.DayPickerView_dpv_calendarHeight, resources.getDimensionPixelOffset(R.dimen.calendar_height)) - MONTH_HEADER_SIZE) / 6);

    isPrevDayEnabled = typedArray.getBoolean(R.styleable.DayPickerView_dpv_enablePreviousDay, true);

    initView();

}
 
Example 3
Source File: SimpleMonthView.java    From DateTimepicker with Apache License 2.0 5 votes vote down vote up
public void setMonthParams(HashMap<String, Integer> monthParams) {
	if ((!monthParams.containsKey("month")) && (!monthParams.containsKey("year")))
		throw new InvalidParameterException("You must specify the month and year for this view");
	setTag(monthParams);
	if (monthParams.containsKey("height")) {
		this.mRowHeight = ((Integer) monthParams.get("height")).intValue();
		if (this.mRowHeight < MIN_HEIGHT)
			this.mRowHeight = MIN_HEIGHT;
	}
	if (monthParams.containsKey("selected_day"))
		this.mSelectedDay = ((Integer) monthParams.get("selected_day")).intValue();
	this.mMonth = ((Integer) monthParams.get("month")).intValue();
	this.mYear = ((Integer) monthParams.get("year")).intValue();
	Time time = new Time(Time.getCurrentTimezone());
	time.setToNow();
	this.mHasToday = false;
	this.mToday = -1;
	this.mCalendar.set(Calendar.MONTH, this.mMonth);
	this.mCalendar.set(Calendar.YEAR, this.mYear);
	this.mCalendar.set(Calendar.DAY_OF_MONTH, 1);
	this.mDayOfWeekStart = this.mCalendar.get(Calendar.DAY_OF_WEEK);
	if (monthParams.containsKey("week_start")) {
		this.mWeekStart = ((Integer) monthParams.get("week_start")).intValue();
	} else {
		this.mWeekStart = this.mCalendar.getFirstDayOfWeek();
	}
	this.mNumCells = Utils.getDaysInMonth(this.mMonth, this.mYear);
	for (int day = 0; day < this.mNumCells; day++) {
		int monthDay = day + 1;
		if (sameDay(monthDay, time)) {
			this.mHasToday = true;
			this.mToday = monthDay;
		}
	}
	this.mNumRows = calculateNumRows();
}
 
Example 4
Source File: SimpleMonthView.java    From CalendarListview with MIT License 5 votes vote down vote up
public SimpleMonthView(Context context, TypedArray typedArray)
{
    super(context);

    Resources resources = context.getResources();
    mDayLabelCalendar = Calendar.getInstance();
    mCalendar = Calendar.getInstance();
    today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mDayOfWeekTypeface = resources.getString(R.string.sans_serif);
    mMonthTitleTypeface = resources.getString(R.string.sans_serif);
    mCurrentDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorCurrentDay, resources.getColor(R.color.normal_day));
    mMonthTextColor = typedArray.getColor(R.styleable.DayPickerView_colorMonthName, resources.getColor(R.color.normal_day));
    mDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorDayName, resources.getColor(R.color.normal_day));
    mDayNumColor = typedArray.getColor(R.styleable.DayPickerView_colorNormalDay, resources.getColor(R.color.normal_day));
    mPreviousDayColor = typedArray.getColor(R.styleable.DayPickerView_colorPreviousDay, resources.getColor(R.color.normal_day));
    mSelectedDaysColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayBackground, resources.getColor(R.color.selected_day_background));
    mMonthTitleBGColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayText, resources.getColor(R.color.selected_day_text));

    mDrawRect = typedArray.getBoolean(R.styleable.DayPickerView_drawRoundRect, false);

    mStringBuilder = new StringBuilder(50);

    MINI_DAY_NUMBER_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeDay, resources.getDimensionPixelSize(R.dimen.text_size_day));
    MONTH_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeMonth, resources.getDimensionPixelSize(R.dimen.text_size_month));
    MONTH_DAY_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeDayName, resources.getDimensionPixelSize(R.dimen.text_size_day_name));
    MONTH_HEADER_SIZE = typedArray.getDimensionPixelOffset(R.styleable.DayPickerView_headerMonthHeight, resources.getDimensionPixelOffset(R.dimen.header_month_height));
    DAY_SELECTED_CIRCLE_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_selectedDayRadius, resources.getDimensionPixelOffset(R.dimen.selected_day_radius));

    mRowHeight = ((typedArray.getDimensionPixelSize(R.styleable.DayPickerView_calendarHeight, resources.getDimensionPixelOffset(R.dimen.calendar_height)) - MONTH_HEADER_SIZE) / 6);

    isPrevDayEnabled = typedArray.getBoolean(R.styleable.DayPickerView_enablePreviousDay, true);

    initView();

}
 
Example 5
Source File: AirMonthView.java    From AirCalendar with MIT License 4 votes vote down vote up
public AirMonthView(Context context, TypedArray typedArray, boolean showBooking, boolean monthDayLabels, ArrayList<String> bookingdates, int maxActiveMonth, int startYear) {
    super(context);

    isMonthDayLabels = monthDayLabels;
    isShowBooking = showBooking;
    mContext = context;
    bookingDateArray = bookingdates;
    mMaxActiveMonth = maxActiveMonth;
    mStartYear = startYear;

    Resources resources = context.getResources();
    mDayLabelCalendar = Calendar.getInstance();
    mCalendar = Calendar.getInstance();
    today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mDayOfWeekTypeface = resources.getString(R.string.sans_serif);
    mMonthTitleTypeface = resources.getString(R.string.sans_serif);
    mCurrentDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorCurrentDay, resources.getColor(R.color.normal_day));
    mMonthTextColor = typedArray.getColor(R.styleable.DayPickerView_colorMonthName, resources.getColor(R.color.colorMonthTextColor));
    mDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorDayName, resources.getColor(R.color.selected_day_text));
    mDayNumColor = typedArray.getColor(R.styleable.DayPickerView_colorNormalDay, resources.getColor(R.color.normal_day));
    mPreviousDayColor = typedArray.getColor(R.styleable.DayPickerView_colorPreviousDay, resources.getColor(R.color.normal_day));
    mSelectedDaysBgColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayBackground, resources.getColor(R.color.selected_day_background));
    mSelectedDaysColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayText, resources.getColor(R.color.selected_day_interval_text));
    mMonthTitleBGColor = typedArray.getColor(R.styleable.DayPickerView_colorMonthName, resources.getColor(R.color.colorMonthTextColor));
    mWeekDayLineColor = typedArray.getColor(R.styleable.DayPickerView_colorWeekDayLineColor, resources.getColor(R.color.colorWeekDayLineColor));
    mWeekEndColor = typedArray.getColor(R.styleable.DayPickerView_colorWeekEndColor, resources.getColor(R.color.colorWeekEndColor));
    mOldDayNumTextColor = typedArray.getColor(R.styleable.DayPickerView_colorOldDayColor, resources.getColor(R.color.color_old_day_text_color));

    mMonthPlus3 = (today.month) + 3;

    mDrawRect = typedArray.getBoolean(R.styleable.DayPickerView_drawRoundRect, false);

    mStringBuilder = new StringBuilder(50);

    MINI_DAY_NUMBER_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeDay, resources.getDimensionPixelSize(R.dimen.text_size_day));
    MONTH_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeMonth, resources.getDimensionPixelSize(R.dimen.text_size_month));

    MONTH_DAY_LABEL_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeDayName, resources.getDimensionPixelSize(R.dimen.text_size_day_name));

    MONTH_HEADER_SIZE = typedArray.getDimensionPixelOffset(R.styleable.DayPickerView_headerMonthHeight, resources.getDimensionPixelOffset(R.dimen.header_month_height));
    DAY_SELECTED_CIRCLE_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_selectedDayRadius, resources.getDimensionPixelOffset(R.dimen.selected_day_radius));

    mRowHeight = ((typedArray.getDimensionPixelSize(R.styleable.DayPickerView_calendarHeight, resources.getDimensionPixelOffset(R.dimen.calendar_height)) - MONTH_HEADER_SIZE) / 6);

    isPrevDayEnabled = typedArray.getBoolean(R.styleable.DayPickerView_enablePreviousDay, true);

    mWeekLabels = getResources().getStringArray(R.array.label_calender_week);

    initView();

}
 
Example 6
Source File: MonthView.java    From narrate-android with Apache License 2.0 4 votes vote down vote up
/**
 * Sets all the parameters for displaying this week. The only required
 * parameter is the week number. Other parameters have a default value and
 * will only update if a new value is included, except for focus month,
 * which will always default to no focus month if no value is passed in. See
 * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
 *
 * @param params A map of the new parameters, see
 *               {@link #VIEW_PARAMS_HEIGHT}
 */
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }

    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);

    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;

    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }

    mNumCells = Utils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();

    // Invalidate cached accessibility information.
    mTouchHelper.invalidateRoot();
}
 
Example 7
Source File: MonthView.java    From BottomSheetPickers with Apache License 2.0 4 votes vote down vote up
/**
 * Sets all the parameters for displaying this week. The only required
 * parameter is the week number. Other parameters have a default value and
 * will only update if a new value is included, except for focus month,
 * which will always default to no focus month if no value is passed in. See
 * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
 *
 * @param params A map of the new parameters, see
 *            {@link #VIEW_PARAMS_HEIGHT}
 */
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }

    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);

    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;

    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }

    mNumCells = Utils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();

    // Invalidate cached accessibility information.
    mTouchHelper.invalidateRoot();
}
 
Example 8
Source File: SimpleMonthView.java    From CalendarView with Apache License 2.0 4 votes vote down vote up
/**
     * @param context
     * @param typedArray
     * @param dataModel
     */
    public SimpleMonthView(Context context, TypedArray typedArray, DayPickerView.DataModel dataModel) {
        super(context);

        Resources resources = context.getResources();
        mDayLabelCalendar = Calendar.getInstance();
        mCalendar = Calendar.getInstance();
        today = new Time(Time.getCurrentTimezone());
        today.setToNow();
        mDayOfWeekTypeface = resources.getString(R.string.sans_serif);
        mMonthTitleTypeface = resources.getString(R.string.sans_serif);
        mCurrentDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorCurrentDay, resources.getColor(R.color.normal_day));
        mYearMonthTextColor = typedArray.getColor(R.styleable.DayPickerView_colorYearMonthText, resources.getColor(R.color.normal_day));
        mWeekTextColor = typedArray.getColor(R.styleable.DayPickerView_colorWeekText, resources.getColor(R.color.normal_day));
//        mDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorDayName, resources.getColor(R.color.normal_day));
        mDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorNormalDayText, resources.getColor(R.color.normal_day));
        mPreviousDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorPreviousDayText, resources.getColor(R.color.normal_day));
        mSelectedDaysBgColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayBackground, resources.getColor(R.color.selected_day_background));
        mSelectedDayTextColor = typedArray.getColor(R.styleable.DayPickerView_colorSelectedDayText, resources.getColor(R.color.selected_day_text));
        mBusyDaysBgColor = typedArray.getColor(R.styleable.DayPickerView_colorBusyDaysBg, Color.GRAY);
        mInValidDaysBgColor = typedArray.getColor(R.styleable.DayPickerView_colorInValidDaysBg, Color.GRAY);
        mBusyDaysTextColor = typedArray.getColor(R.styleable.DayPickerView_colorBusyDaysText, resources.getColor(R.color.normal_day));
        mInValidDaysTextColor = typedArray.getColor(R.styleable.DayPickerView_colorInValidDaysText, resources.getColor(R.color.normal_day));
//        mDrawRect = typedArray.getBoolean(R.styleable.DayPickerView_drawRoundRect, true);

        mStringBuilder = new StringBuilder(50);

        MINI_DAY_NUMBER_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeDay, resources.getDimensionPixelSize(R.dimen.text_size_day));
        TAG_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeTag, resources.getDimensionPixelSize(R.dimen.text_size_tag));
        YEAR_MONTH_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeYearMonth, resources.getDimensionPixelSize(R.dimen.text_size_month));
        WEEK_TEXT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_textSizeWeek, resources.getDimensionPixelSize(R.dimen.text_size_day_name));
        MONTH_HEADER_SIZE = typedArray.getDimensionPixelOffset(R.styleable.DayPickerView_headerMonthHeight, resources.getDimensionPixelOffset(R.dimen.header_month_height));
        DAY_SELECTED_RECT_SIZE = typedArray.getDimensionPixelSize(R.styleable.DayPickerView_selectedDayRadius, resources.getDimensionPixelOffset(R.dimen.selected_day_radius));

        mRowHeight = ((typedArray.getDimensionPixelSize(R.styleable.DayPickerView_calendarHeight,
                resources.getDimensionPixelOffset(R.dimen.calendar_height)) - MONTH_HEADER_SIZE - ROW_SEPARATOR) / 6);

        isPrevDayEnabled = typedArray.getBoolean(R.styleable.DayPickerView_enablePreviousDay, false);
        mInvalidDays = dataModel.invalidDays;
        mBusyDays = dataModel.busyDays;
        mCalendarTags = dataModel.tags;
        mDefTag = dataModel.defTag;

        cellCalendar = new SimpleMonthAdapter.CalendarDay();

        initView();
    }
 
Example 9
Source File: SimpleMonthView.java    From Conquer with Apache License 2.0 4 votes vote down vote up
public void setMonthParams(HashMap<String, Integer> params) {
       if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
           throw new InvalidParameterException("You must specify month and year for this view");
       }
	setTag(params);

       if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
           mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
           if (mRowHeight < MIN_HEIGHT) {
               mRowHeight = MIN_HEIGHT;
           }
       }
       if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
           mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
       }

       mMonth = params.get(VIEW_PARAMS_MONTH);
       mYear = params.get(VIEW_PARAMS_YEAR);

       final Time today = new Time(Time.getCurrentTimezone());
       today.setToNow();
       mHasToday = false;
       mToday = -1;

	mCalendar.set(Calendar.MONTH, mMonth);
	mCalendar.set(Calendar.YEAR, mYear);
	mCalendar.set(Calendar.DAY_OF_MONTH, 1);
	mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

       if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
           mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
       } else {
           mWeekStart = mCalendar.getFirstDayOfWeek();
       }

       mNumCells = Utils.getDaysInMonth(mMonth, mYear);
       for (int i = 0; i < mNumCells; i++) {
           final int day = i + 1;
           if (sameDay(day, today)) {
               mHasToday = true;
               mToday = day;
           }
       }

       mNumRows = calculateNumRows();
}
 
Example 10
Source File: CountdownTimerActivity.java    From Android-CountdownTimer with MIT License 4 votes vote down vote up
private void configureConferenceDate() {
	conferenceTime.set(second, minute, hour, monthDay, month, year);
	conferenceTime.normalize(true);
	long confMillis = conferenceTime.toMillis(true);

	Time nowTime = new Time(Time.getCurrentTimezone());
	nowTime.setToNow();
	nowTime.normalize(true);
	long nowMillis = nowTime.toMillis(true);

	long milliDiff = confMillis - nowMillis;

	new CountDownTimer(milliDiff, 1000) {

		@Override
		public void onTick(long millisUntilFinished) {
			// decompose difference into days, hours, minutes and seconds
			CountdownTimerActivity.this.mDisplayDays = (int) ((millisUntilFinished / 1000) / 86400);
			CountdownTimerActivity.this.mDisplayHours = (int) (((millisUntilFinished / 1000) - (CountdownTimerActivity.this.mDisplayDays * 86400)) / 3600);
			CountdownTimerActivity.this.mDisplayMinutes = (int) (((millisUntilFinished / 1000) - ((CountdownTimerActivity.this.mDisplayDays * 86400) + (CountdownTimerActivity.this.mDisplayHours * 3600))) / 60);
			CountdownTimerActivity.this.mDisplaySeconds = (int) ((millisUntilFinished / 1000) % 60);

			CountdownTimerActivity.this.mDaysWheel.setText(String.valueOf(CountdownTimerActivity.this.mDisplayDays));
			CountdownTimerActivity.this.mDaysWheel.setProgress(CountdownTimerActivity.this.mDisplayDays);

			CountdownTimerActivity.this.mHoursWheel.setText(String.valueOf(CountdownTimerActivity.this.mDisplayHours));
			CountdownTimerActivity.this.mHoursWheel.setProgress(CountdownTimerActivity.this.mDisplayHours * 15);

			CountdownTimerActivity.this.mMinutesWheel.setText(String.valueOf(CountdownTimerActivity.this.mDisplayMinutes));
			CountdownTimerActivity.this.mMinutesWheel.setProgress(CountdownTimerActivity.this.mDisplayMinutes * 6);

			Animation an = new RotateAnimation(0.0f, 90.0f, 250f, 273f);
			an.setFillAfter(true);

			CountdownTimerActivity.this.mSecondsWheel.setText(String.valueOf(CountdownTimerActivity.this.mDisplaySeconds));
			CountdownTimerActivity.this.mSecondsWheel.setProgress(CountdownTimerActivity.this.mDisplaySeconds * 6);
		}

		@Override
		public void onFinish() {
			//TODO: this is where you would launch a subsequent activity if you'd like.  I'm currently just setting the seconds to zero
			Logger.d(TAG, "Timer Finished...");
			CountdownTimerActivity.this.mSecondsWheel.setText("0");
        		CountdownTimerActivity.this.mSecondsWheel.setProgress(0);
		}
	}.start();
}
 
Example 11
Source File: MonthView.java    From StyleableDateTimePicker with MIT License 4 votes vote down vote up
/**
 * Sets all the parameters for displaying this week. The only required
 * parameter is the week number. Other parameters have a default value and
 * will only update if a new value is included, except for focus month,
 * which will always default to no focus month if no value is passed in. See
 * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
 *
 * @param params A map of the new parameters, see
 *            {@link #VIEW_PARAMS_HEIGHT}
 */
public void setMonthParams(HashMap<String, Integer> params) {
    if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
        throw new InvalidParameterException("You must specify month and year for this view");
    }
    setTag(params);
    // We keep the current value for any params not present
    if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
        mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
        if (mRowHeight < MIN_HEIGHT) {
            mRowHeight = MIN_HEIGHT;
        }
    }
    if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
        mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
    }

    // Allocate space for caching the day numbers and focus values
    mMonth = params.get(VIEW_PARAMS_MONTH);
    mYear = params.get(VIEW_PARAMS_YEAR);

    // Figure out what day today is
    final Time today = new Time(Time.getCurrentTimezone());
    today.setToNow();
    mHasToday = false;
    mToday = -1;

    mCalendar.set(Calendar.MONTH, mMonth);
    mCalendar.set(Calendar.YEAR, mYear);
    mCalendar.set(Calendar.DAY_OF_MONTH, 1);
    mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

    if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
        mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
    } else {
        mWeekStart = mCalendar.getFirstDayOfWeek();
    }

    mNumCells = Utils.getDaysInMonth(mMonth, mYear);
    for (int i = 0; i < mNumCells; i++) {
        final int day = i + 1;
        if (sameDay(day, today)) {
            mHasToday = true;
            mToday = day;
        }
    }
    mNumRows = calculateNumRows();

    // Invalidate cached accessibility information.
    mTouchHelper.invalidateRoot();
}
 
Example 12
Source File: MonthView.java    From cathode with Apache License 2.0 4 votes vote down vote up
/**
 * Sets all the parameters for displaying this week. The only required
 * parameter is the week number. Other parameters have a default value and
 * will only update if a new value is included, except for focus month,
 * which will always default to no focus month if no value is passed in. See
 * {@link #VIEW_PARAMS_HEIGHT} for more info on parameters.
 *
 * @param params A map of the new parameters, see
 * {@link #VIEW_PARAMS_HEIGHT}
 */
public void setMonthParams(HashMap<String, Integer> params) {
  if (!params.containsKey(VIEW_PARAMS_MONTH) && !params.containsKey(VIEW_PARAMS_YEAR)) {
    throw new InvalidParameterException("You must specify month and year for this view");
  }
  setTag(params);
  // We keep the current value for any params not present
  if (params.containsKey(VIEW_PARAMS_HEIGHT)) {
    mRowHeight = params.get(VIEW_PARAMS_HEIGHT);
    if (mRowHeight < MIN_HEIGHT) {
      mRowHeight = MIN_HEIGHT;
    }
  }
  if (params.containsKey(VIEW_PARAMS_SELECTED_DAY)) {
    mSelectedDay = params.get(VIEW_PARAMS_SELECTED_DAY);
  }

  // Allocate space for caching the day numbers and focus values
  mMonth = params.get(VIEW_PARAMS_MONTH);
  mYear = params.get(VIEW_PARAMS_YEAR);

  // Figure out what day today is
  final Time today = new Time(Time.getCurrentTimezone());
  today.setToNow();
  mHasToday = false;
  mToday = -1;

  mCalendar.set(Calendar.MONTH, mMonth);
  mCalendar.set(Calendar.YEAR, mYear);
  mCalendar.set(Calendar.DAY_OF_MONTH, 1);
  mDayOfWeekStart = mCalendar.get(Calendar.DAY_OF_WEEK);

  if (params.containsKey(VIEW_PARAMS_WEEK_START)) {
    mWeekStart = params.get(VIEW_PARAMS_WEEK_START);
  } else {
    mWeekStart = mCalendar.getFirstDayOfWeek();
  }

  mNumCells = Utils.getDaysInMonth(mMonth, mYear);
  for (int i = 0; i < mNumCells; i++) {
    final int day = i + 1;
    if (sameDay(day, today)) {
      mHasToday = true;
      mToday = day;
    }
  }
  mNumRows = calculateNumRows();

  // Invalidate cached accessibility information.
  mTouchHelper.invalidateRoot();
}