android.text.format.Time Java Examples

The following examples show how to use android.text.format.Time. 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: TimeFieldAdapter.java    From opentasks with Apache License 2.0 6 votes vote down vote up
@Override
public Time getDefault(ContentSet values)
{
    // create a new Time for the given time zone, falling back to the default time zone if none is given
    String timezone = mTzField == null ? Time.TIMEZONE_UTC : values.getAsString(mTzField);
    Time value = new Time(timezone == null ? TimeZone.getDefault().getID() : timezone);

    value.setToNow();

    Integer allDayInt = mAllDayField == null ? null : values.getAsInteger(mAllDayField);
    if ((allDayInt != null && allDayInt != 0) || (mAllDayField == null && mAllDayDefault))
    {
        // make it an allday value
        value.set(value.monthDay, value.month, value.year);
        value.timezone = Time.TIMEZONE_UTC; // all-day values are saved in UTC
    }

    return value;
}
 
Example #2
Source File: TasksExtension.java    From opentasks with Apache License 2.0 6 votes vote down vote up
private String getTaskTitleDueString(Cursor c, boolean isAllDay)
{
    if (isAllDay)
    {
        return getString(R.string.dashclock_widget_title_due_expanded_allday, c.getString(c.getColumnIndex(Tasks.TITLE)));
    }
    else
    {
        TimeFieldAdapter timeFieldAdapter = new TimeFieldAdapter(Instances.DUE, Instances.TZ, Instances.IS_ALLDAY);
        Time dueTime = timeFieldAdapter.get(c);
        if (dueTime == null)
        {
            return null;
        }
        String dueTimeString = mDateFormatter.format(dueTime, DateFormatContext.DASHCLOCK_VIEW);
        return getString(R.string.dashclock_widget_title_due_expanded, c.getString(c.getColumnIndex(Tasks.TITLE)), dueTimeString);
    }
}
 
Example #3
Source File: MyWatchFace.java    From AndroidDemoProjects with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(SurfaceHolder holder) {
    super.onCreate(holder);

    setWatchFaceStyle(new WatchFaceStyle.Builder(MyWatchFace.this)
            .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT)
            .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
            .setShowSystemUiTime(false)
            .build());

    mHourHandBitmap = loadBitmaps(R.array.hourHandIds);
    mMinuteHandBitmap = loadBitmaps(R.array.minuteHandIds);
    mSecondsHandBitmap = loadBitmaps( R.array.secondHandIds );

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor( Color.parseColor("black") );

    mTime = new Time();

    mFilterPaint = new Paint();
    mFilterPaint.setFilterBitmap(true);

    initTickPaint();
}
 
Example #4
Source File: BatmanWatchFaceService.java    From wearable with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(SurfaceHolder holder) {
    super.onCreate(holder);
        //see https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceStyle.Builder.html for more info on the methods use
        //in the next command
    setWatchFaceStyle(new WatchFaceStyle.Builder(BatmanWatchFaceService.this)
            .setStatusBarGravity(Gravity.TOP | Gravity.END) //where the battery and connect icons shows.
            .build());
    Resources resources = BatmanWatchFaceService.this.getResources();
    mYOffset = resources.getDimension(R.dimen.digital_y_offset);

    bm_c = BitmapFactory.decodeResource(resources,R.drawable.batman2c);
    bm_bw = BitmapFactory.decodeResource(resources,R.drawable.batman2bw);
    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(resources.getColor(R.color.digital_background));

    mTextPaint_time = new Paint();
    mTextPaint_time = createTextPaint(resources.getColor(R.color.digital_text));
    mTextPaint_date = new Paint();
    mTextPaint_date = createTextPaint(resources.getColor(R.color.digital_text));

    mTime = new Time();
}
 
Example #5
Source File: MyWatchFaceService.java    From io2015-codelabs with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(SurfaceHolder holder) {
    super.onCreate(holder);

    setWatchFaceStyle(new WatchFaceStyle.Builder(MyWatchFaceService.this)
            .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT)
            .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
            .setShowSystemUiTime(false)
            .build());

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(Color.BLACK);

    final int backgroundResId = R.drawable.custom_background;

    mBackgroundBitmap = BitmapFactory.decodeResource(getResources(), backgroundResId);
    mHandPaint = new Paint();
    mHandPaint.setColor(Color.WHITE);
    mHandPaint.setStrokeWidth(STROKE_WIDTH);
    mHandPaint.setAntiAlias(true);
    mHandPaint.setStrokeCap(Paint.Cap.ROUND);
    mHandPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, Color.BLACK);
    mHandPaint.setStyle(Paint.Style.STROKE);

    mTime = new Time();
}
 
Example #6
Source File: EventRecurrence.java    From Android-RecurrencePicker with Apache License 2.0 6 votes vote down vote up
public static int day2TimeDay(int day) {
    switch (day) {
        case SU:
            return Time.SUNDAY;
        case MO:
            return Time.MONDAY;
        case TU:
            return Time.TUESDAY;
        case WE:
            return Time.WEDNESDAY;
        case TH:
            return Time.THURSDAY;
        case FR:
            return Time.FRIDAY;
        case SA:
            return Time.SATURDAY;
        default:
            throw new RuntimeException("bad day of week: " + day);
    }
}
 
Example #7
Source File: MyWatchFaceService.java    From io2015-codelabs with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(SurfaceHolder holder) {
    super.onCreate(holder);

    setWatchFaceStyle(new WatchFaceStyle.Builder(MyWatchFaceService.this)
            .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT)
            .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
            .setShowSystemUiTime(false)
            .build());

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(Color.BLACK);

    mHandPaint = new Paint();
    mHandPaint.setColor(Color.WHITE);
    mHandPaint.setStrokeWidth(STROKE_WIDTH);
    mHandPaint.setAntiAlias(true);
    mHandPaint.setStrokeCap(Paint.Cap.ROUND);

    mTime = new Time();
}
 
Example #8
Source File: EventRecurrence.java    From Android-RecurrencePicker with Apache License 2.0 6 votes vote down vote up
public static int timeDay2Day(int day) {
    switch (day) {
        case Time.SUNDAY:
            return SU;
        case Time.MONDAY:
            return MO;
        case Time.TUESDAY:
            return TU;
        case Time.WEDNESDAY:
            return WE;
        case Time.THURSDAY:
            return TH;
        case Time.FRIDAY:
            return FR;
        case Time.SATURDAY:
            return SA;
        default:
            throw new RuntimeException("bad day of week: " + day);
    }
}
 
Example #9
Source File: ShiftTime.java    From opentasks with Apache License 2.0 6 votes vote down vote up
@Override
public Time apply(ContentSet currentValues, Time oldValue, Time newValue)
{
    Time timeToShift = mTimeAdapter.get(currentValues);
    if (timeToShift != null && newValue != null && oldValue != null)
    {
        boolean isAllDay = timeToShift.allDay;
        timeToShift.set(timeToShift.toMillis(false) + (newValue.toMillis(false) - oldValue.toMillis(false)));

        // ensure the event is still allday if is was allday before.
        if (isAllDay)
        {
            timeToShift.set(timeToShift.monthDay, timeToShift.month, timeToShift.year);
        }
        mTimeAdapter.set(currentValues, timeToShift);
    }
    return newValue;
}
 
Example #10
Source File: MyWatchFaceService.java    From android-codelab-watchface with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(SurfaceHolder holder) {
    super.onCreate(holder);

    setWatchFaceStyle(new WatchFaceStyle.Builder(MyWatchFaceService.this)
            .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT)
            .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
            .setShowSystemUiTime(false)
            .build());

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(Color.BLACK);

    final int backgroundResId = R.drawable.custom_background;

    mBackgroundBitmap = BitmapFactory.decodeResource(getResources(), backgroundResId);

    mHandPaint = new Paint();
    mHandPaint.setColor(Color.WHITE);
    mHandPaint.setStrokeWidth(STROKE_WIDTH);
    mHandPaint.setAntiAlias(true);
    mHandPaint.setStrokeCap(Paint.Cap.ROUND);

    mTime = new Time();
}
 
Example #11
Source File: Utility.java    From Krishi-Seva with MIT License 6 votes vote down vote up
/**
 * Given a day, returns just the name to use for that day.
 * E.g "today", "tomorrow", "wednesday".
 *
 * @param context Context to use for resource localization
 * @param dateInMillis The date in milliseconds
 * @return
 */
public static String getDayName(Context context, long dateInMillis) {
    // If the date is today, return the localized version of "Today" instead of the actual
    // day name.

    Time t = new Time();
    t.setToNow();
    int julianDay = Time.getJulianDay(dateInMillis, t.gmtoff);
    int currentJulianDay = Time.getJulianDay(System.currentTimeMillis(), t.gmtoff);
    if (julianDay == currentJulianDay) {
        return context.getString(R.string.today);
    } else if ( julianDay == currentJulianDay +1 ) {
        return context.getString(R.string.tomorrow);
    } else {
        Time time = new Time();
        time.setToNow();
        // Otherwise, the format is just the day of the week (e.g "Wednesday".
        SimpleDateFormat dayFormat = new SimpleDateFormat("EEEE");
        return dayFormat.format(dateInMillis);
    }
}
 
Example #12
Source File: DefaultBefore.java    From opentasks with Apache License 2.0 6 votes vote down vote up
@Override
public Time getCustomDefault(ContentSet currentValues, Time genericDefault)
{
    Time reference = mReferenceAdapter != null ? mReferenceAdapter.get(currentValues) : null;
    boolean useReference = reference != null && !genericDefault.before(reference);
    Time value = new Time(useReference ? reference : genericDefault);
    if (value.allDay)
    {
        value.set(value.monthDay - (useReference ? 1 : 0), value.month, value.year);
    }
    else
    {
        value.minute--;
        value.normalize(false);
        value.second = 0;
        value.minute = 0;
    }
    return value;
}
 
Example #13
Source File: MyWatchFaceService.java    From android-codelab-watchface with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(SurfaceHolder holder) {
    super.onCreate(holder);

    setWatchFaceStyle(new WatchFaceStyle.Builder(MyWatchFaceService.this)
            .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT)
            .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
            .setShowSystemUiTime(false)
            .build());

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(Color.BLACK);

    mHandPaint = new Paint();
    mHandPaint.setColor(Color.WHITE);
    mHandPaint.setStrokeWidth(STROKE_WIDTH);
    mHandPaint.setAntiAlias(true);
    mHandPaint.setStrokeCap(Paint.Cap.ROUND);

    mTime = new Time();
}
 
Example #14
Source File: DateFormatter.java    From opentasks with Apache License 2.0 6 votes vote down vote up
/**
 * {@link Time} will eventually be replaced with {@link DateTime} in the project.
 * This conversion function is only needed in the transition period.
 */
@VisibleForTesting
Time toTime(DateTime dateTime)
{
    if (dateTime.isFloating() && !dateTime.isAllDay())
    {
        throw new IllegalArgumentException("Cannot support floating DateTime that is not all-day, can't represent it with Time");
    }

    // Time always needs a TimeZone (default ctor falls back to TimeZone.getDefault())
    String timeZoneId = dateTime.getTimeZone() == null ? "UTC" : dateTime.getTimeZone().getID();
    Time time = new Time(timeZoneId);

    time.set(dateTime.getTimestamp());

    // TODO Would using time.set(monthDay, month, year) be better?
    if (dateTime.isAllDay())
    {
        time.allDay = true;
        // This is needed as per time.allDay docs:
        time.hour = 0;
        time.minute = 0;
        time.second = 0;
    }
    return time;
}
 
Example #15
Source File: TimeFieldView.java    From opentasks with Apache License 2.0 6 votes vote down vote up
@Override
public void onClick(View v)
{
    int id = v.getId();
    Time time = mAdapter.get(mValues);
    if (id == R.id.button_add_one_day)
    {
        time.monthDay++;
        time.normalize(true);
    }
    else if (id == R.id.button_add_one_hour)
    {
        time.hour++;
        time.normalize(false);
    }
    mAdapter.validateAndSet(mValues, time);
}
 
Example #16
Source File: Utils.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
public static String formatTime(Context context, long when) {
	// TODO: DateUtils should make this easier
	Time then = new Time();
	then.set(when);
	Time now = new Time();
	now.setToNow();

	int flags = DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL;

	if (then.year != now.year) {
		flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
	} else if (then.yearDay != now.yearDay) {
		flags |= DateUtils.FORMAT_SHOW_DATE;
	} else {
		flags |= DateUtils.FORMAT_SHOW_TIME;
	}

	return DateUtils.formatDateTime(context, when, flags);
}
 
Example #17
Source File: Utils.java    From FireFiles with Apache License 2.0 6 votes vote down vote up
public static String formatTime(Context context, long when) {
	// TODO: DateUtils should make this easier
	Time then = new Time();
	then.set(when);
	Time now = new Time();
	now.setToNow();

	int flags = DateUtils.FORMAT_NO_NOON | DateUtils.FORMAT_NO_MIDNIGHT | DateUtils.FORMAT_ABBREV_ALL;

	if (then.year != now.year) {
		flags |= DateUtils.FORMAT_SHOW_YEAR | DateUtils.FORMAT_SHOW_DATE;
	} else if (then.yearDay != now.yearDay) {
		flags |= DateUtils.FORMAT_SHOW_DATE;
	} else {
		flags |= DateUtils.FORMAT_SHOW_TIME;
	}

	return DateUtils.formatDateTime(context, when, flags);
}
 
Example #18
Source File: CalendarQueryService.java    From AndroidWearable-Samples with Apache License 2.0 6 votes vote down vote up
@Override
protected void onHandleIntent(Intent intent) {
    mGoogleApiClient.blockingConnect(CONNECTION_TIME_OUT_MS, TimeUnit.MILLISECONDS);
    // Query calendar events in the next 24 hours.
    Time time = new Time();
    time.setToNow();
    long beginTime = time.toMillis(true);
    time.monthDay++;
    time.normalize(true);
    long endTime = time.normalize(true);

    List<Event> events = queryEvents(this, beginTime, endTime);
    for (Event event : events) {
        final PutDataMapRequest putDataMapRequest = event.toPutDataMapRequest();
        if (mGoogleApiClient.isConnected()) {
            Wearable.DataApi.putDataItem(
                mGoogleApiClient, putDataMapRequest.asPutDataRequest()).await();
        } else {
            Log.e(TAG, "Failed to send data item: " + putDataMapRequest
                     + " - Client disconnected from Google Play Services");
        }
    }
    mGoogleApiClient.disconnect();
}
 
Example #19
Source File: CalendarSyncAdapterService.java    From haxsync with GNU General Public License v2.0 6 votes vote down vote up
private static long createCalendar(Account account, String name, int color){
	ContentValues values = new ContentValues();
	values.put(CalendarContract.Calendars.NAME, name);
	values.put(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, name);
	values.put(CalendarContract.Calendars.CALENDAR_COLOR, color);
	values.put(CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL, CalendarContract.Calendars.CAL_ACCESS_OWNER);
	values.put(CalendarContract.Calendars.OWNER_ACCOUNT, account.name);
	values.put(CalendarContract.Calendars.ACCOUNT_NAME, account.name);
	values.put(CalendarContract.Calendars.ACCOUNT_TYPE, account.type);
	values.put(CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL, CalendarContract.Calendars.CAL_ACCESS_READ);
	values.put(CalendarContract.Calendars.SYNC_EVENTS, 1);
	values.put(CalendarContract.Calendars.CALENDAR_TIME_ZONE, Time.getCurrentTimezone());
	Uri calSyncUri = CalendarContract.Calendars.CONTENT_URI.buildUpon()
			.appendQueryParameter(android.provider.CalendarContract.CALLER_IS_SYNCADAPTER, "true")
			.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_NAME, account.name)
			.appendQueryParameter(CalendarContract.Calendars.ACCOUNT_TYPE, account.type)
			.build();
	Uri calUri = mContentResolver.insert(calSyncUri, values);	
       long calId = ContentUris.parseId(calUri);
	return calId;
}
 
Example #20
Source File: MyWatchFaceService.java    From android-codelab-watchface with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(SurfaceHolder holder) {
    super.onCreate(holder);

    setWatchFaceStyle(new WatchFaceStyle.Builder(MyWatchFaceService.this)
            .setCardPeekMode(WatchFaceStyle.PEEK_MODE_SHORT)
            .setBackgroundVisibility(WatchFaceStyle.BACKGROUND_VISIBILITY_INTERRUPTIVE)
            .setShowSystemUiTime(false)
            .build());

    mBackgroundPaint = new Paint();
    mBackgroundPaint.setColor(Color.BLACK);

    final int backgroundResId = R.drawable.custom_background;

    mBackgroundBitmap = BitmapFactory.decodeResource(getResources(), backgroundResId);
    mHandPaint = new Paint();
    mHandPaint.setColor(Color.WHITE);
    mHandPaint.setStrokeWidth(STROKE_WIDTH);
    mHandPaint.setAntiAlias(true);
    mHandPaint.setStrokeCap(Paint.Cap.ROUND);
    mHandPaint.setShadowLayer(SHADOW_RADIUS, 0, 0, Color.BLACK);
    mHandPaint.setStyle(Paint.Style.STROKE);

    mTime = new Time();
}
 
Example #21
Source File: GosScheduleEditDateAcitivty.java    From Gizwits-SmartBuld_Android with MIT License 5 votes vote down vote up
/**
 * Description:根据时间在云端创建规则和更新数据库
 */
private void setRuleOnSiteAndUpdateDateBase() {
	final String utcDate;
	final String utcTime;
	Time nowTime = new Time();
	nowTime.setToNow();
	int now = nowTime.hour * 60 + nowTime.minute;
	int pick = npHour.getValue() * 60 + npMin.getValue();

	if (selectDate.getUserPickRepeat().equals("none")) {
		// 没有重复天数
		if (now < pick) {
			// 当前时间早于选择时间,设置为今天
			selectDate.setDateTimeToToday(
					String.format("%02d", npHour.getValue()) + ":" + String.format("%02d", npMin.getValue()));
		} else {
			// 当前时间晚于选择时间,设置为明天
			selectDate.setDateTimeToTomorrow(
					String.format("%02d", npHour.getValue()) + ":" + String.format("%02d", npMin.getValue()));
		}
	} else {
		// 有重复天数
		utcDate = "";
		utcTime = GetUTCTimeUtil.getUTCTimeFromLocal(
				String.format("%02d", npHour.getValue()) + ":" + String.format("%02d", npMin.getValue()));

		setRepeatDateAccordingPickTime(pick);
		selectDate.setDate(utcDate);
		selectDate.setTime(utcTime);
	}

	progressDialog.show();

	selectDate.setOnSite(handler);

}
 
Example #22
Source File: WeatherProxy.java    From MaterialCalendar with Apache License 2.0 5 votes vote down vote up
public static Weather getTodayWeather() {
    Time time = new Time();
    time.setToNow();
    int month = time.month + 1;
    String todayDate = String.valueOf(time.year)
            + String.valueOf(month < 10 ? "0" + month : month)
            + String.valueOf(time.monthDay < 10 ? "0" + time.monthDay : time.monthDay);
    return getWeatherByDate(todayDate);
}
 
Example #23
Source File: ShiftIfAfter.java    From opentasks with Apache License 2.0 5 votes vote down vote up
@Override
public Time apply(ContentSet currentValues, Time oldValue, Time newValue)
{
    Time notAfterThisTime = mTimeAdapter.get(currentValues);
    if (notAfterThisTime != null && newValue != null)
    {
        if (newValue.after(notAfterThisTime))
        {
            mTimeAdapter.set(currentValues, newValue);
        }
    }
    return newValue;
}
 
Example #24
Source File: TimeRangeCursorFactory.java    From opentasks with Apache License 2.0 5 votes vote down vote up
public TimeRangeCursorFactory(String[] projection)
{
    super(projection);
    mProjectionList = Arrays.asList(projection);
    mTimezone = TimeZone.getDefault();
    mTime = new Time(mTimezone.getID());
}
 
Example #25
Source File: Ticket.java    From sms-ticket with Apache License 2.0 5 votes vote down vote up
public Time getValidTo() {
    if (validTo != null) {
        validTo.switchTimezone(Time.getCurrentTimezone());
    }

    return validTo;
}
 
Example #26
Source File: Globalization.java    From cordova-android-chromeview with Apache License 2.0 5 votes vote down vote up
private JSONObject getIsDayLightSavingsTime(JSONArray options) throws GlobalizationError{
    JSONObject obj = new JSONObject();
    boolean dst = false;
    try{
        Date date = new Date((Long)options.getJSONObject(0).get(DATE));
        //TimeZone tz = Calendar.getInstance(Locale.getDefault()).getTimeZone();
        TimeZone tz = TimeZone.getTimeZone(Time.getCurrentTimezone());
        dst = tz.inDaylightTime(date); //get daylight savings data from date object and user timezone settings

        return obj.put("dst",dst);
    }catch(Exception ge){
        throw new GlobalizationError(GlobalizationError.UNKNOWN_ERROR);
    }
}
 
Example #27
Source File: Logger.java    From nfcspy with GNU General Public License v3.0 5 votes vote down vote up
static CharSequence fmtHceDeactivatedMessage(long stamp) {
	Time time = new Time();
	time.set(stamp);

	return fmt(
			ThisApplication.getStringResource(R.string.status_deactivated),
			fmtTime(time), fmtDate(time));
}
 
Example #28
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 #29
Source File: InputDialogContainer.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private Time normalizeTime(int year, int month, int monthDay,
                           int hour, int minute, int second) {
    Time result = new Time();
    if (year == 0 && month == 0 && monthDay == 0 && hour == 0 &&
            minute == 0 && second == 0) {
        Calendar cal = Calendar.getInstance();
        result.set(cal.get(Calendar.SECOND), cal.get(Calendar.MINUTE),
                cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.DATE),
                cal.get(Calendar.MONTH), cal.get(Calendar.YEAR));
    } else {
        result.set(second, minute, hour, monthDay, month, year);
    }
    return result;
}
 
Example #30
Source File: Globalization.java    From phonegapbootcampsite with MIT License 5 votes vote down vote up
private JSONObject getIsDayLightSavingsTime(JSONArray options) throws GlobalizationError{
    JSONObject obj = new JSONObject();
    boolean dst = false;
    try{
        Date date = new Date((Long)options.getJSONObject(0).get(DATE));
        //TimeZone tz = Calendar.getInstance(Locale.getDefault()).getTimeZone();
        TimeZone tz = TimeZone.getTimeZone(Time.getCurrentTimezone());
        dst = tz.inDaylightTime(date); //get daylight savings data from date object and user timezone settings

        return obj.put("dst",dst);
    }catch(Exception ge){
        throw new GlobalizationError(GlobalizationError.UNKNOWN_ERROR);
    }
}