use of java.text.DateFormatSymbols in project datetimepicker by flavienlaurent.
the class TimePickerDialog method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
View view = inflater.inflate(R.layout.time_picker_dialog, null);
KeyboardListener keyboardListener = new KeyboardListener();
view.setOnKeyListener(keyboardListener);
Resources res = getResources();
mHourPickerDescription = res.getString(R.string.hour_picker_description);
mSelectHours = res.getString(R.string.select_hours);
mMinutePickerDescription = res.getString(R.string.minute_picker_description);
mSelectMinutes = res.getString(R.string.select_minutes);
mBlue = res.getColor(R.color.blue);
mBlack = res.getColor(R.color.numbers_text_color);
mHourView = (TextView) view.findViewById(R.id.hours);
mHourView.setOnKeyListener(keyboardListener);
mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
mMinuteView = (TextView) view.findViewById(R.id.minutes);
mMinuteView.setOnKeyListener(keyboardListener);
mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
mAmPmTextView.setOnKeyListener(keyboardListener);
if (Build.VERSION.SDK_INT <= 14) {
mAmPmTextView.setTransformationMethod(new TransformationMethod() {
private final Locale locale = getResources().getConfiguration().locale;
@Override
public CharSequence getTransformation(CharSequence source, View view) {
return source != null ? source.toString().toUpperCase(locale) : null;
}
@Override
public void onFocusChanged(View view, CharSequence sourceText, boolean focused, int direction, Rect previouslyFocusedRect) {
}
});
}
String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
mAmText = amPmTexts[0];
mPmText = amPmTexts[1];
mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
mTimePicker.setOnValueSelectedListener(this);
mTimePicker.setOnKeyListener(keyboardListener);
mTimePicker.initialize(getActivity(), mInitialHourOfDay, mInitialMinute, mIs24HourMode, mVibrate);
int currentItemShowing = HOUR_INDEX;
if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
}
setCurrentItemShowing(currentItemShowing, false, true, true);
mTimePicker.invalidate();
mHourView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setCurrentItemShowing(HOUR_INDEX, true, false, true);
mTimePicker.tryVibrate();
}
});
mMinuteView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setCurrentItemShowing(MINUTE_INDEX, true, false, true);
mTimePicker.tryVibrate();
}
});
mDoneButton = (TextView) view.findViewById(R.id.done_button);
mDoneButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onDoneButtonClick();
}
});
mDoneButton.setOnKeyListener(keyboardListener);
// Enable or disable the AM/PM view.
mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
if (mIs24HourMode) {
mAmPmTextView.setVisibility(View.GONE);
RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
TextView separatorView = (TextView) view.findViewById(R.id.separator);
separatorView.setLayoutParams(paramsSeparator);
} else {
mAmPmTextView.setVisibility(View.VISIBLE);
updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM);
mAmPmHitspace.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
mTimePicker.tryVibrate();
int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
if (amOrPm == AM) {
amOrPm = PM;
} else if (amOrPm == PM) {
amOrPm = AM;
}
updateAmPmDisplay(amOrPm);
mTimePicker.setAmOrPm(amOrPm);
}
});
}
mAllowAutoAdvance = true;
setHour(mInitialHourOfDay, true);
setMinute(mInitialMinute);
// Set up for keyboard mode.
mDoublePlaceholderText = res.getString(R.string.time_placeholder);
mDeletedKeyFormat = res.getString(R.string.deleted_key);
mPlaceholderText = mDoublePlaceholderText.charAt(0);
mAmKeyCode = mPmKeyCode = -1;
generateLegalTimesTree();
if (mInKbMode) {
mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
tryStartingKbMode(-1);
mHourView.invalidate();
} else if (mTypedTimes == null) {
mTypedTimes = new ArrayList<Integer>();
}
return view;
}
use of java.text.DateFormatSymbols in project android-betterpickers by code-troopers.
the class RadialTimePickerDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
if (getShowsDialog()) {
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
}
View view = inflater.inflate(R.layout.radial_time_picker_dialog, container, false);
KeyboardListener keyboardListener = new KeyboardListener();
view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener);
Resources res = getResources();
TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId, R.styleable.BetterPickersDialogs);
// Prepare some colors to use.
int headerBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpBlue));
int bodyBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpBodyBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
int buttonBgColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsBackgroundColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
int buttonTextColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpButtonsTextColor, ContextCompat.getColor(getActivity(), R.color.bpBlue));
mSelectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderSelectedTextColor, ContextCompat.getColor(getActivity(), R.color.bpWhite));
mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersDialogs_bpHeaderUnselectedTextColor, ContextCompat.getColor(getActivity(), R.color.radial_gray_light));
mHourPickerDescription = res.getString(R.string.hour_picker_description);
mSelectHours = res.getString(R.string.select_hours);
mMinutePickerDescription = res.getString(R.string.minute_picker_description);
mSelectMinutes = res.getString(R.string.select_minutes);
mHourView = (TextView) view.findViewById(R.id.hours);
mHourView.setOnKeyListener(keyboardListener);
mHourSpaceView = (TextView) view.findViewById(R.id.hour_space);
mMinuteSpaceView = (TextView) view.findViewById(R.id.minutes_space);
mMinuteView = (TextView) view.findViewById(R.id.minutes);
mMinuteView.setOnKeyListener(keyboardListener);
mAmPmTextView = (TextView) view.findViewById(R.id.ampm_label);
mAmPmTextView.setOnKeyListener(keyboardListener);
String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
mAmText = amPmTexts[0];
mPmText = amPmTexts[1];
mHapticFeedbackController = new HapticFeedbackController(getActivity());
mTimePicker = (RadialPickerLayout) view.findViewById(R.id.time_picker);
mTimePicker.setOnValueSelectedListener(this);
mTimePicker.setOnKeyListener(keyboardListener);
mTimePicker.initialize(getActivity(), mHapticFeedbackController, mInitialHourOfDay, mInitialMinute, mIs24HourMode);
int currentItemShowing = HOUR_INDEX;
if (savedInstanceState != null && savedInstanceState.containsKey(KEY_CURRENT_ITEM_SHOWING)) {
currentItemShowing = savedInstanceState.getInt(KEY_CURRENT_ITEM_SHOWING);
}
setCurrentItemShowing(currentItemShowing, false, true, true);
mTimePicker.invalidate();
mHourView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setCurrentItemShowing(HOUR_INDEX, true, false, true);
tryVibrate();
}
});
mMinuteView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
setCurrentItemShowing(MINUTE_INDEX, true, false, true);
tryVibrate();
}
});
mTitleTextView = (TextView) view.findViewById(R.id.time_picker_header);
if (mTitleText != null) {
mTitleTextView.setVisibility(View.VISIBLE);
mTitleTextView.setText(mTitleText);
} else {
mTitleTextView.setVisibility(View.GONE);
}
mError = (NumberPickerErrorTextView) view.findViewById(R.id.error);
if (hasTimeLimits()) {
mError.setVisibility(View.INVISIBLE);
} else {
mError.setVisibility(View.GONE);
}
mDoneButton = (Button) view.findViewById(R.id.done_button);
if (mDoneText != null) {
mDoneButton.setText(mDoneText);
}
mDoneButton.setTextColor(buttonTextColor);
mDoneButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mInKbMode && isTypedTimeFullyLegal()) {
finishKbMode(false);
} else {
tryVibrate();
}
doneClickValidateAndCallback();
}
});
mDoneButton.setOnKeyListener(keyboardListener);
Button cancelButton = (Button) view.findViewById(R.id.cancel_button);
if (mCancelText != null) {
cancelButton.setText(mCancelText);
}
cancelButton.setTextColor(buttonTextColor);
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
tryVibrate();
dismiss();
}
});
// Enable or disable the AM/PM view.
mAmPmHitspace = view.findViewById(R.id.ampm_hitspace);
if (mIs24HourMode) {
mAmPmTextView.setVisibility(View.GONE);
RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT);
TextView separatorView = (TextView) view.findViewById(R.id.separator);
separatorView.setLayoutParams(paramsSeparator);
} else {
mAmPmTextView.setVisibility(View.VISIBLE);
updateAmPmDisplay(mInitialHourOfDay < 12 ? AM : PM);
mAmPmHitspace.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
tryVibrate();
int amOrPm = mTimePicker.getIsCurrentlyAmOrPm();
if (amOrPm == AM) {
amOrPm = PM;
} else if (amOrPm == PM) {
amOrPm = AM;
}
updateAmPmDisplay(amOrPm);
mTimePicker.setAmOrPm(amOrPm);
}
});
}
mAllowAutoAdvance = true;
setHour(mInitialHourOfDay, true);
setMinute(mInitialMinute);
// Set up for keyboard mode.
mDoublePlaceholderText = res.getString(R.string.time_placeholder);
mDeletedKeyFormat = res.getString(R.string.deleted_key);
mPlaceholderText = mDoublePlaceholderText.charAt(0);
mAmKeyCode = mPmKeyCode = -1;
generateLegalTimesTree();
if (mInKbMode) {
mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES);
tryStartingKbMode(-1);
mHourView.invalidate();
} else if (mTypedTimes == null) {
mTypedTimes = new ArrayList<Integer>();
}
// Set the theme at the end so that the initialize()s above don't counteract the theme.
mTimePicker.setTheme(themeColors);
// Set the colors for each view based on the theme.
view.findViewById(R.id.time_display_background).setBackgroundColor(headerBgColor);
view.findViewById(R.id.ok_cancel_buttons_layout).setBackgroundColor(buttonBgColor);
view.findViewById(R.id.time_display).setBackgroundColor(headerBgColor);
view.findViewById(R.id.time_picker_error_holder).setBackgroundColor(headerBgColor);
((TextView) view.findViewById(R.id.separator)).setTextColor(mUnselectedColor);
((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mUnselectedColor);
mTimePicker.setBackgroundColor(bodyBgColor);
return view;
}
use of java.text.DateFormatSymbols in project android-betterpickers by code-troopers.
the class RecurrencePickerDialogFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRecurrence.wkst = EventRecurrence.timeDay2Day(Utils.getFirstDayOfWeek(getActivity()));
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
boolean endCountHasFocus = false;
if (savedInstanceState != null) {
RecurrenceModel m = (RecurrenceModel) savedInstanceState.get(BUNDLE_MODEL);
if (m != null) {
mModel = m;
}
endCountHasFocus = savedInstanceState.getBoolean(BUNDLE_END_COUNT_HAS_FOCUS);
} else {
Bundle bundle = getArguments();
if (bundle != null) {
mTime.set(bundle.getLong(BUNDLE_START_TIME_MILLIS));
String tz = bundle.getString(BUNDLE_TIME_ZONE);
if (!TextUtils.isEmpty(tz)) {
mTime.timezone = tz;
}
mTime.normalize(false);
// Time days of week: Sun=0, Mon=1, etc
mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
String rrule = bundle.getString(BUNDLE_RRULE);
if (!TextUtils.isEmpty(rrule)) {
mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE;
mRecurrence.parse(rrule);
copyEventRecurrenceToModel(mRecurrence, mModel);
// Leave today's day of week as checked by default in weekly view.
if (mRecurrence.bydayCount == 0) {
mModel.weeklyByDayOfWeek[mTime.weekDay] = true;
}
}
mModel.forceHideSwitchButton = bundle.getBoolean(BUNDLE_HIDE_SWITCH_BUTTON, false);
} else {
mTime.setToNow();
}
}
mResources = getResources();
mView = inflater.inflate(R.layout.recurrencepicker, container, true);
final Activity activity = getActivity();
final Configuration config = activity.getResources().getConfiguration();
mRepeatSwitch = (SwitchCompat) mView.findViewById(R.id.repeat_switch);
if (mModel.forceHideSwitchButton) {
mRepeatSwitch.setChecked(true);
mRepeatSwitch.setVisibility(View.GONE);
mModel.recurrenceState = RecurrenceModel.STATE_RECURRENCE;
} else {
mRepeatSwitch.setChecked(mModel.recurrenceState == RecurrenceModel.STATE_RECURRENCE);
mRepeatSwitch.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
mModel.recurrenceState = isChecked ? RecurrenceModel.STATE_RECURRENCE : RecurrenceModel.STATE_NO_RECURRENCE;
togglePickerOptions();
}
});
}
mFreqSpinner = (Spinner) mView.findViewById(R.id.freqSpinner);
mFreqSpinner.setOnItemSelectedListener(this);
ArrayAdapter<CharSequence> freqAdapter = ArrayAdapter.createFromResource(getActivity(), R.array.recurrence_freq, R.layout.recurrencepicker_freq_item);
freqAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
mFreqSpinner.setAdapter(freqAdapter);
mInterval = (EditText) mView.findViewById(R.id.interval);
mInterval.addTextChangedListener(new minMaxTextWatcher(1, INTERVAL_DEFAULT, INTERVAL_MAX) {
@Override
void onChange(int v) {
if (mIntervalResId != -1 && mInterval.getText().toString().length() > 0) {
mModel.interval = v;
updateIntervalText();
mInterval.requestLayout();
}
}
});
mIntervalPreText = (TextView) mView.findViewById(R.id.intervalPreText);
mIntervalPostText = (TextView) mView.findViewById(R.id.intervalPostText);
mEndNeverStr = mResources.getString(R.string.recurrence_end_continously);
mEndDateLabel = mResources.getString(R.string.recurrence_end_date_label);
mEndCountLabel = mResources.getString(R.string.recurrence_end_count_label);
mEndSpinnerArray.add(mEndNeverStr);
mEndSpinnerArray.add(mEndDateLabel);
mEndSpinnerArray.add(mEndCountLabel);
mEndSpinner = (Spinner) mView.findViewById(R.id.endSpinner);
mEndSpinner.setOnItemSelectedListener(this);
mEndSpinnerAdapter = new EndSpinnerAdapter(getActivity(), mEndSpinnerArray, R.layout.recurrencepicker_freq_item, R.layout.recurrencepicker_end_text);
mEndSpinnerAdapter.setDropDownViewResource(R.layout.recurrencepicker_freq_item);
mEndSpinner.setAdapter(mEndSpinnerAdapter);
mEndCount = (EditText) mView.findViewById(R.id.endCount);
mEndCount.addTextChangedListener(new minMaxTextWatcher(1, COUNT_DEFAULT, COUNT_MAX) {
@Override
void onChange(int v) {
if (mModel.endCount != v) {
mModel.endCount = v;
updateEndCountText();
mEndCount.requestLayout();
}
}
});
mPostEndCount = (TextView) mView.findViewById(R.id.postEndCount);
mEndDateTextView = (TextView) mView.findViewById(R.id.endDate);
mEndDateTextView.setOnClickListener(this);
if (mModel.endDate == null) {
mModel.endDate = new Time(mTime);
switch(mModel.freq) {
case RecurrenceModel.FREQ_HOURLY:
case RecurrenceModel.FREQ_DAILY:
case RecurrenceModel.FREQ_WEEKLY:
mModel.endDate.month += 1;
break;
case RecurrenceModel.FREQ_MONTHLY:
mModel.endDate.month += 3;
break;
case RecurrenceModel.FREQ_YEARLY:
mModel.endDate.year += 3;
break;
}
mModel.endDate.normalize(false);
}
mWeekGroup = (LinearLayout) mView.findViewById(R.id.weekGroup);
mWeekGroup2 = (LinearLayout) mView.findViewById(R.id.weekGroup2);
// In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
String[] dayOfWeekString = new DateFormatSymbols().getWeekdays();
mMonthRepeatByDayOfWeekStrs = new String[7][];
// from Time.SUNDAY as 0 through Time.SATURDAY as 6
mMonthRepeatByDayOfWeekStrs[0] = mResources.getStringArray(R.array.repeat_by_nth_sun);
mMonthRepeatByDayOfWeekStrs[1] = mResources.getStringArray(R.array.repeat_by_nth_mon);
mMonthRepeatByDayOfWeekStrs[2] = mResources.getStringArray(R.array.repeat_by_nth_tues);
mMonthRepeatByDayOfWeekStrs[3] = mResources.getStringArray(R.array.repeat_by_nth_wed);
mMonthRepeatByDayOfWeekStrs[4] = mResources.getStringArray(R.array.repeat_by_nth_thurs);
mMonthRepeatByDayOfWeekStrs[5] = mResources.getStringArray(R.array.repeat_by_nth_fri);
mMonthRepeatByDayOfWeekStrs[6] = mResources.getStringArray(R.array.repeat_by_nth_sat);
// In Time.java day of week order e.g. Sun = 0
int idx = Utils.getFirstDayOfWeek(getActivity());
// In Calendar.java day of week order e.g Sun = 1 ... Sat = 7
dayOfWeekString = new DateFormatSymbols().getShortWeekdays();
int numOfButtonsInRow1;
int numOfButtonsInRow2;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR2) {
// Get screen width in dp first
Display display = getActivity().getWindowManager().getDefaultDisplay();
DisplayMetrics outMetrics = new DisplayMetrics();
display.getMetrics(outMetrics);
float density = getResources().getDisplayMetrics().density;
float dpWidth = outMetrics.widthPixels / density;
if (dpWidth > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
numOfButtonsInRow1 = 7;
numOfButtonsInRow2 = 0;
mWeekGroup2.setVisibility(View.GONE);
mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
} else {
numOfButtonsInRow1 = 4;
numOfButtonsInRow2 = 3;
mWeekGroup2.setVisibility(View.VISIBLE);
// Set rightmost button on the second row invisible so it takes up
// space and everything centers properly
mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
}
} else if (mResources.getConfiguration().screenWidthDp > MIN_SCREEN_WIDTH_FOR_SINGLE_ROW_WEEK) {
numOfButtonsInRow1 = 7;
numOfButtonsInRow2 = 0;
mWeekGroup2.setVisibility(View.GONE);
mWeekGroup2.getChildAt(3).setVisibility(View.GONE);
} else {
numOfButtonsInRow1 = 4;
numOfButtonsInRow2 = 3;
mWeekGroup2.setVisibility(View.VISIBLE);
// Set rightmost button on the second row invisible so it takes up
// space and everything centers properly
mWeekGroup2.getChildAt(3).setVisibility(View.INVISIBLE);
}
/* First row */
for (int i = 0; i < 7; i++) {
if (i >= numOfButtonsInRow1) {
mWeekGroup.getChildAt(i).setVisibility(View.GONE);
continue;
}
mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup.getChildAt(i);
mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
mWeekByDayButtons[idx].setOnCheckedChangeListener(this);
if (++idx >= 7) {
idx = 0;
}
}
/* 2nd Row */
for (int i = 0; i < 3; i++) {
if (i >= numOfButtonsInRow2) {
mWeekGroup2.getChildAt(i).setVisibility(View.GONE);
continue;
}
mWeekByDayButtons[idx] = (ToggleButton) mWeekGroup2.getChildAt(i);
mWeekByDayButtons[idx].setTextOff(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
mWeekByDayButtons[idx].setTextOn(dayOfWeekString[TIME_DAY_TO_CALENDAR_DAY[idx]]);
mWeekByDayButtons[idx].setOnCheckedChangeListener(this);
if (++idx >= 7) {
idx = 0;
}
}
mMonthGroup = (LinearLayout) mView.findViewById(R.id.monthGroup);
mMonthRepeatByRadioGroup = (RadioGroup) mView.findViewById(R.id.monthGroup);
mMonthRepeatByRadioGroup.setOnCheckedChangeListener(this);
mRepeatMonthlyByNthDayOfWeek = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfTheWeek);
mRepeatMonthlyByNthDayOfMonth = (RadioButton) mView.findViewById(R.id.repeatMonthlyByNthDayOfMonth);
mDoneButton = (Button) mView.findViewById(R.id.done_button);
mDoneButton.setOnClickListener(this);
Button cancelButton = (Button) mView.findViewById(R.id.cancel_button);
//FIXME no text color for this one ?
cancelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
togglePickerOptions();
updateDialog();
if (endCountHasFocus) {
mEndCount.requestFocus();
}
return mView;
}
use of java.text.DateFormatSymbols in project android-betterpickers by code-troopers.
the class AmPmCirclesView method initialize.
public void initialize(Context context, int amOrPm) {
if (mIsInitialized) {
Log.e(TAG, "AmPmCirclesView may only be initialized once.");
return;
}
Resources res = context.getResources();
mUnselectedColor = res.getColor(R.color.bpWhite);
mSelectedColor = res.getColor(R.color.bpBlue);
mAmPmTextColor = res.getColor(R.color.ampm_text_color);
String typefaceFamily = res.getString(R.string.sans_serif);
Typeface tf = Typeface.create(typefaceFamily, Typeface.NORMAL);
mPaint.setTypeface(tf);
mPaint.setAntiAlias(true);
mPaint.setTextAlign(Align.CENTER);
mCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.circle_radius_multiplier));
mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.ampm_circle_radius_multiplier));
String[] amPmTexts = new DateFormatSymbols().getAmPmStrings();
mAmText = amPmTexts[0];
mPmText = amPmTexts[1];
setAmOrPm(amOrPm);
mAmOrPmPressed = -1;
mIsInitialized = true;
}
use of java.text.DateFormatSymbols in project j2objc by google.
the class DateFormatTest method test_getTimeInstanceILjava_util_Locale.
/**
* @tests java.text.DateFormat#getTimeInstance(int, java.util.Locale)
*/
public void test_getTimeInstanceILjava_util_Locale() {
SimpleDateFormat f2 = (SimpleDateFormat) DateFormat.getTimeInstance(DateFormat.SHORT, Locale.GERMAN);
assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(new DateFormatSymbols(Locale.GERMAN)));
assertTrue("Doesn't work", f2.format(new Date()).getClass() == String.class);
f2 = (SimpleDateFormat) DateFormat.getTimeInstance(DateFormat.MEDIUM, Locale.GERMAN);
assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(new DateFormatSymbols(Locale.GERMAN)));
assertTrue("Doesn't work", f2.format(new Date()).getClass() == String.class);
f2 = (SimpleDateFormat) DateFormat.getTimeInstance(DateFormat.LONG, Locale.GERMAN);
assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(new DateFormatSymbols(Locale.GERMAN)));
assertTrue("Doesn't work", f2.format(new Date()).getClass() == String.class);
f2 = (SimpleDateFormat) DateFormat.getTimeInstance(DateFormat.FULL, Locale.GERMAN);
assertTrue("Wrong class", f2.getClass() == SimpleDateFormat.class);
assertTrue("Wrong symbols", f2.getDateFormatSymbols().equals(new DateFormatSymbols(Locale.GERMAN)));
assertTrue("Doesn't work", f2.format(new Date()).getClass() == String.class);
// regression test for HARMONY-940
try {
DateFormat.getTimeInstance(77, Locale.GERMAN);
fail("Should throw IAE");
} catch (IllegalArgumentException iae) {
//expected
}
}
Aggregations