Utilspublic class Utils extends Object Utility helper functions for time and date pickers. |
Fields Summary |
---|
public static final int | MONDAY_BEFORE_JULIAN_EPOCH | public static final int | PULSE_ANIMATOR_DURATION | public static final int | SELECTED_ALPHA | public static final int | SELECTED_ALPHA_THEME_DARK | public static final int | FULL_ALPHA | static final String | SHARED_PREFS_NAME |
Methods Summary |
---|
public static int | getDaysInMonth(int month, int year)
switch (month) {
case Calendar.JANUARY:
case Calendar.MARCH:
case Calendar.MAY:
case Calendar.JULY:
case Calendar.AUGUST:
case Calendar.OCTOBER:
case Calendar.DECEMBER:
return 31;
case Calendar.APRIL:
case Calendar.JUNE:
case Calendar.SEPTEMBER:
case Calendar.NOVEMBER:
return 30;
case Calendar.FEBRUARY:
return (year % 4 == 0) ? 29 : 28;
default:
throw new IllegalArgumentException("Invalid Month");
}
| public static int | getJulianMondayFromWeeksSinceEpoch(int week)Takes a number of weeks since the epoch and calculates the Julian day of
the Monday for that week.
This assumes that the week containing the {@link Time#EPOCH_JULIAN_DAY}
is considered week 0. It returns the Julian day for the Monday
{@code week} weeks after the Monday of the week containing the epoch.
return MONDAY_BEFORE_JULIAN_EPOCH + week * 7;
| public static android.animation.ObjectAnimator | getPulseAnimator(android.view.View labelToAnimate, float decreaseRatio, float increaseRatio)Render an animator to pulsate a view in place.
Keyframe k0 = Keyframe.ofFloat(0f, 1f);
Keyframe k1 = Keyframe.ofFloat(0.275f, decreaseRatio);
Keyframe k2 = Keyframe.ofFloat(0.69f, increaseRatio);
Keyframe k3 = Keyframe.ofFloat(1f, 1f);
PropertyValuesHolder scaleX = PropertyValuesHolder.ofKeyframe("scaleX", k0, k1, k2, k3);
PropertyValuesHolder scaleY = PropertyValuesHolder.ofKeyframe("scaleY", k0, k1, k2, k3);
ObjectAnimator pulseAnimator =
ObjectAnimator.ofPropertyValuesHolder(labelToAnimate, scaleX, scaleY);
pulseAnimator.setDuration(PULSE_ANIMATOR_DURATION);
return pulseAnimator;
| public static int | getWeeksSinceEpochFromJulianDay(int julianDay, int firstDayOfWeek)Returns the week since {@link Time#EPOCH_JULIAN_DAY} (Jan 1, 1970)
adjusted for first day of week.
This takes a julian day and the week start day and calculates which
week since {@link Time#EPOCH_JULIAN_DAY} that day occurs in, starting
at 0. *Do not* use this to compute the ISO week number for the year.
int diff = Time.THURSDAY - firstDayOfWeek;
if (diff < 0) {
diff += 7;
}
int refDay = Time.EPOCH_JULIAN_DAY - diff;
return (julianDay - refDay) / 7;
| public static boolean | isJellybeanOrLater()
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN;
| public static void | tryAccessibilityAnnounce(android.view.View view, java.lang.CharSequence text)Try to speak the specified text, for accessibility. Only available on JB or later.
if (isJellybeanOrLater() && view != null && text != null) {
view.announceForAccessibility(text);
}
|
|