List of usage examples for java.text DateFormatSymbols DateFormatSymbols
public DateFormatSymbols()
From source file:com.a.mirko.android.datetimepicker.time.TimePickerDialog.java
@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.findViewById(R.id.time_picker_dialog).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);/*ww w. jav a 2 s. c o m*/ 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; }
From source file:com.azuyo.happybeing.fourmob.timepicker.TimePickerDialog.java
@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.app_blue); mBlack = res.getColor(R.color.numbers_text_color); mWhite = res.getColor(R.color.white); 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/*from w ww . j ava2s .c o m*/ 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(); } }); mCancelButton = (TextView) view.findViewById(R.id.cancel_button); mDoneButton = (TextView) view.findViewById(R.id.done_button); mCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); mCancelButton.setOnKeyListener(keyboardListener); 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; }
From source file:cn.fulldroid.lib.datetimepicker.time.TimePickerDialog.java
@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 = ContextCompat.getColor(getContext(), R.color.blue); mBlack = ContextCompat.getColor(getContext(), 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// w ww. j a va 2s . c o m 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; }
From source file:com.grottworkshop.gwsdatetimepicker.TimePickerDialog.java
@SuppressWarnings("deprecation") @Override/* w w w.j a v a 2 s .c om*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); @SuppressLint("InflateParams") 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); //TODO: getColor is depreciated mBlue = res.getColor(R.color.blue); //TODO: getColor is depreciated 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) { if (savedInstanceState != null) { mTypedTimes = savedInstanceState.getIntegerArrayList(KEY_TYPED_TIMES); } tryStartingKbMode(-1); mHourView.invalidate(); } else if (mTypedTimes == null) { mTypedTimes = new ArrayList<>(); } return view; }
From source file:jp.seesaa.android.datetimepicker.time.TimePickerDialog.java
public View createView(LayoutInflater inflater, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.dtp_time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); Resources res = getResources(); mHourPickerDescription = res.getString(R.string.dtp_hour_picker_description); mSelectHours = res.getString(R.string.dtp_select_hours); mMinutePickerDescription = res.getString(R.string.dtp_minute_picker_description); mSelectMinutes = res.getString(R.string.dtp_select_minutes); mSelectedColor = res.getColor(mThemeDark ? R.color.dtp_red : R.color.dtp_blue); mUnselectedColor = res.getColor(mThemeDark ? R.color.dtp_white : R.color.dtp_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); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0];//from w ww .j a v a 2s.c om 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(); } }); // mDoneButton = (TextView) view.findViewById(R.id.done_button); // mDoneButton.setOnClickListener(new OnClickListener() { // @Override // public void onClick(View v) { // if (mInKbMode && isTypedTimeFullyLegal()) { // finishKbMode(false); // } else { // tryVibrate(); // } // if (mCallback != null) { // mCallback.onTimeSet(mTimePicker, // mTimePicker.getHours(), mTimePicker.getMinutes()); // } // dismiss(); // } // }); // 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) { 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.dtp_time_placeholder); mDeletedKeyFormat = res.getString(R.string.dtp_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(getActivity().getApplicationContext(), mThemeDark); // Prepare some colors to use. int white = res.getColor(R.color.dtp_white); int circleBackground = res.getColor(R.color.dtp_circle_background); int line = res.getColor(R.color.dtp_line_background); int timeDisplay = res.getColor(R.color.dtp_numbers_text_color); ColorStateList doneTextColor = res.getColorStateList(R.color.dtp_done_text_color); int doneBackground = R.drawable.dtp_done_background_color; int darkGray = res.getColor(R.color.dtp_dark_gray); int lightGray = res.getColor(R.color.dtp_light_gray); int darkLine = res.getColor(R.color.dtp_line_dark); ColorStateList darkDoneTextColor = res.getColorStateList(R.color.dtp_done_text_color_dark); int darkDoneBackground = R.drawable.dtp_done_background_color_dark; // Set the colors for each view based on the theme. view.findViewById(R.id.time_display_background).setBackgroundColor(mThemeDark ? darkGray : white); view.findViewById(R.id.time_display).setBackgroundColor(mThemeDark ? darkGray : white); ((TextView) view.findViewById(R.id.separator)).setTextColor(mThemeDark ? white : timeDisplay); ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mThemeDark ? white : timeDisplay); // view.findViewById(R.id.line).setBackgroundColor(mThemeDark ? darkLine : line); // mDoneButton.setTextColor(mThemeDark ? darkDoneTextColor : doneTextColor); mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground); // mDoneButton.setBackgroundResource(mThemeDark ? darkDoneBackground : doneBackground); return view; }
From source file:nya.miku.wishmaster.chans.nullchancc.NullchanccModule.java
@SuppressLint("SimpleDateFormat") @Override/* w w w. ja v a2s .c o m*/ protected WakabaReader getWakabaReader(InputStream stream, UrlPageModel urlModel) { if (urlModel != null && urlModel.chanName != null && urlModel.chanName.equals("expand")) { stream = new SequenceInputStream(new ByteArrayInputStream("<form id=\"delform\">".getBytes()), stream); } return new WakabaReader(stream) { private final DateFormat dateFormat; { DateFormatSymbols symbols = new DateFormatSymbols(); symbols.setShortMonths(new String[] { "", "", "", "?", "", "", "", "?", "", "", "??", "" }); dateFormat = new SimpleDateFormat("yyyy MMM dd HH:mm:ss", symbols); dateFormat.setTimeZone(TimeZone.getTimeZone("GMT+3")); } @Override protected void parseDate(String date) { if (date.length() > 0) { date = date.replaceAll("(?:[^\\d]*)(\\d(?:.*))", "$1"); try { currentPost.timestamp = dateFormat.parse(date).getTime(); } catch (Exception e) { Logger.e(TAG, "cannot parse date", e); } } } @Override protected void parseOmittedString(String omitted) { if (omitted.indexOf('>') != -1) omitted = omitted.substring(omitted.indexOf('>')); super.parseOmittedString(omitted); } @Override protected void postprocessPost(PostModel post) { Matcher matcher = PATTERN_EMBEDDED.matcher(post.comment); while (matcher.find()) { String id = matcher.group(1); String div = matcher.group(0).toLowerCase(Locale.US); String url = null; if (div.contains("youtube")) { url = "http://www.youtube.com/watch?v=" + id; } else if (div.contains("vimeo")) { url = "http://vimeo.com/" + id; } else if (div.contains("coub")) { url = "http://coub.com/view/" + id; } if (url != null) { AttachmentModel attachment = new AttachmentModel(); attachment.type = AttachmentModel.TYPE_OTHER_NOTFILE; attachment.path = url; attachment.thumbnail = div.contains("youtube") ? ("http://img.youtube.com/vi/" + id + "/default.jpg") : null; int oldCount = post.attachments != null ? post.attachments.length : 0; AttachmentModel[] attachments = new AttachmentModel[oldCount + 1]; for (int i = 0; i < oldCount; ++i) attachments[i] = post.attachments[i]; attachments[oldCount] = attachment; post.attachments = attachments; } } } }; }
From source file:com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialog.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (getShowsDialog()) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); }//from w ww . jav a 2 s . c om View view = inflater.inflate(R.layout.radial_time_picker_dialog, null); KeyboardListener keyboardListener = new KeyboardListener(); view.findViewById(R.id.time_picker_dialog).setOnKeyListener(keyboardListener); Resources res = getResources(); TypedArray themeColors = getActivity().obtainStyledAttributes(mStyleResId, R.styleable.BetterPickersRadialTimePickerDialog); 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); mSelectedColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpAccentColor, R.color.bpBlue); mUnselectedColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainTextColor, 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); 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(); } }); mDoneButton = (TextView) view.findViewById(R.id.done_button); if (mDoneText != null) { mDoneButton.setText(mDoneText); } mDoneButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } if (mCallback != null) { mCallback.onTimeSet(RadialTimePickerDialog.this, mTimePicker.getHours(), mTimePicker.getMinutes()); } dismiss(); } }); 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) { 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); // Prepare some colors to use. int mainColor1 = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainColor1, R.color.bpWhite); int mainColor2 = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainColor2, R.color.circle_background); int lineColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpLineColor, R.color.bpLine_background); int mainTextColor = themeColors.getColor(R.styleable.BetterPickersRadialTimePickerDialog_bpMainTextColor, R.color.numbers_text_color); ColorStateList doneTextColor = themeColors .getColorStateList(R.styleable.BetterPickersRadialTimePickerDialog_bpDoneTextColor); int doneBackground = themeColors.getResourceId( R.styleable.BetterPickersRadialTimePickerDialog_bpDoneBackgroundColor, R.drawable.done_background_color); // Set the colors for each view based on the theme. view.findViewById(R.id.time_display_background).setBackgroundColor(mainColor1); view.findViewById(R.id.time_display).setBackgroundColor(mainColor1); ((TextView) view.findViewById(R.id.separator)).setTextColor(mainTextColor); ((TextView) view.findViewById(R.id.ampm_label)).setTextColor(mainTextColor); view.findViewById(R.id.line).setBackgroundColor(lineColor); mDoneButton.setTextColor(doneTextColor); mTimePicker.setBackgroundColor(mainColor2); mDoneButton.setBackgroundResource(doneBackground); return view; }
From source file:org.astrojournal.generator.statistics.LatexStatistics.java
/** * Write the average number of monthly reports to a LaTeX file. * //from ww w . j a v a 2 s . co m * @param writer * The writer to write the statistics in LaTeX format. * * @param basicStatistics * The statistics to write * * @return true if the file was written correctly * @throws IOException * if the statistics are not written correctly. */ public boolean writeMonthlyReportsAvg(Writer writer, BasicStatistics basicStatistics) throws IOException { // Average reports per month writer.write("\\begin{tabular}[t]{ll} \n"); writer.write("\\hline \n"); writer.write("{\\bf Month} & {\\bf AvgReports} \\\\ \n"); writer.write("\\hline \n"); // Let's sort the elements for improving readability HashMap<String, MutableFloat> monthlyReportsAvg = basicStatistics.getMonthlyReportsAvg(); String[] sortedKeys = monthlyReportsAvg.keySet().toArray(new String[0]); Arrays.sort(sortedKeys); for (String key : sortedKeys) { log.debug("Count(" + new DateFormatSymbols().getMonths()[Integer.parseInt(key) - 1] + "): " + basicStatistics.getFloatCount(monthlyReportsAvg, key)); writer.write(new DateFormatSymbols().getMonths()[Integer.parseInt(key) - 1] + " & " + basicStatistics.getFloatCount(monthlyReportsAvg, key) + "\\\\ \n"); } writer.write("\\hline \n"); writer.write("\\end{tabular} \n"); return true; }
From source file:com.wdullaer.materialdatetimepicker.time.TimePickerView.java
private void initView(Context context) { // View.inflate(getContext(), R.layout.mdtp_time_picker_view, this); LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); inflater.inflate(R.layout.mdtp_time_picker_view, this); KeyboardListener keyboardListener = new KeyboardListener(); findViewById(R.id.time_picker_view).setOnKeyListener(keyboardListener); // If an accent color has not been set manually, get it from the context if (mAccentColor == -1) { mAccentColor = Utils.getAccentColorFromThemeIfAvailable(getContext()); }//ww w.j a v a2 s . co m // if theme mode has not been set by java code, check if it is specified in Style.xml if (!mThemeDarkChanged) { mThemeDark = Utils.isDarkTheme(getContext(), mThemeDark); } Resources res = getResources(); // Context context = getContext(); mHourPickerDescription = res.getString(R.string.mdtp_hour_picker_description); mSelectHours = res.getString(R.string.mdtp_select_hours); mMinutePickerDescription = res.getString(R.string.mdtp_minute_picker_description); mSelectMinutes = res.getString(R.string.mdtp_select_minutes); mSecondPickerDescription = res.getString(R.string.mdtp_second_picker_description); mSelectSeconds = res.getString(R.string.mdtp_select_seconds); mSelectedColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_text_disabled_dark_theme); mUnselectedColor = ContextCompat.getColor(context, R.color.mdtp_date_picker_month_day_dark_theme); mHourView = (TextView) findViewById(R.id.hours); mHourView.setOnKeyListener(keyboardListener); mHourSpaceView = (TextView) findViewById(R.id.hour_space); mMinuteSpaceView = (TextView) findViewById(R.id.minutes_space); mMinuteView = (TextView) findViewById(R.id.minutes); mMinuteView.setOnKeyListener(keyboardListener); mSecondSpaceView = (TextView) findViewById(R.id.seconds_space); mSecondView = (TextView) findViewById(R.id.seconds); mSecondView.setOnKeyListener(keyboardListener); mAmPmTextView = (TextView) findViewById(R.id.ampm_label); mAmPmTextView.setOnKeyListener(keyboardListener); String[] amPmTexts = new DateFormatSymbols().getAmPmStrings(); mAmText = amPmTexts[0]; mPmText = amPmTexts[1]; mHapticFeedbackController = new HapticFeedbackController(getContext()); mInitialTime = roundToNearest(mInitialTime); mTimePicker = (RadialPickerLayout) findViewById(R.id.time_picker); mTimePicker.setOnValueSelectedListener(this); mTimePicker.setOnKeyListener(keyboardListener); mTimePicker.initialize(getContext(), this, mInitialTime, mIs24HourMode); mHapticFeedbackController.start(); 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(); } }); mSecondView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { setCurrentItemShowing(SECOND_INDEX, true, false, true); tryVibrate(); } }); /*mOkButton = (Button) findViewById(R.id.ok); mOkButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (mInKbMode && isTypedTimeFullyLegal()) { finishKbMode(false); } else { tryVibrate(); } notifyOnDateListener(); // dismiss(); } }); mOkButton.setOnKeyListener(keyboardListener); mOkButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium")); if(mOkString != null) mOkButton.setText(mOkString); else mOkButton.setText(mOkResid); mCancelButton = (Button) findViewById(R.id.cancel); mCancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { tryVibrate(); if (getDialog() != null) getDialog().cancel(); } }); mCancelButton.setTypeface(TypefaceHelper.get(context, "Roboto-Medium")); if(mCancelString != null) mCancelButton.setText(mCancelString); else mCancelButton.setText(mCancelResid); mCancelButton.setVisibility(isCancelable() ? View.VISIBLE : View.GONE);*/ // Enable or disable the AM/PM view. mAmPmHitspace = findViewById(R.id.ampm_hitspace); if (mIs24HourMode) { mAmPmTextView.setVisibility(View.GONE); } else { mAmPmTextView.setVisibility(View.VISIBLE); updateAmPmDisplay(mInitialTime.isAM() ? AM : PM); mAmPmHitspace.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Don't do anything if either AM or PM are disabled if (isAmDisabled() || isPmDisabled()) return; tryVibrate(); int amOrPm = mTimePicker.getIsCurrentlyAmOrPm(); if (amOrPm == AM) { amOrPm = PM; } else if (amOrPm == PM) { amOrPm = AM; } mTimePicker.setAmOrPm(amOrPm); } }); } // Disable seconds picker if (!mEnableSeconds) { mSecondSpaceView.setVisibility(View.GONE); findViewById(R.id.separator_seconds).setVisibility(View.GONE); } // Center stuff depending on what's visible if (mIs24HourMode && !mEnableSeconds) { // center first separator RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.CENTER_IN_PARENT); TextView separatorView = (TextView) findViewById(R.id.separator); separatorView.setLayoutParams(paramsSeparator); } else if (mEnableSeconds) { // link separator to minutes final View separator = findViewById(R.id.separator); RelativeLayout.LayoutParams paramsSeparator = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsSeparator.addRule(RelativeLayout.LEFT_OF, R.id.minutes_space); paramsSeparator.addRule(RelativeLayout.CENTER_VERTICAL, RelativeLayout.TRUE); separator.setLayoutParams(paramsSeparator); if (!mIs24HourMode) { // center minutes RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsMinutes.addRule(RelativeLayout.CENTER_IN_PARENT); mMinuteSpaceView.setLayoutParams(paramsMinutes); } else { // move minutes to right of center RelativeLayout.LayoutParams paramsMinutes = new RelativeLayout.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); paramsMinutes.addRule(RelativeLayout.RIGHT_OF, R.id.center_view); mMinuteSpaceView.setLayoutParams(paramsMinutes); } } mAllowAutoAdvance = true; setHour(mInitialTime.getHour(), true); setMinute(mInitialTime.getMinute()); setSecond(mInitialTime.getSecond()); // Set up for keyboard mode. mDoublePlaceholderText = res.getString(R.string.mdtp_time_placeholder); mDeletedKeyFormat = res.getString(R.string.mdtp_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<>(); }*/ mTypedTimes = new ArrayList<>(); // Set the title (if any) TextView timePickerHeader = (TextView) findViewById(R.id.time_picker_header); if (!mTitle.isEmpty()) { timePickerHeader.setVisibility(TextView.VISIBLE); timePickerHeader.setText(mTitle.toUpperCase(Locale.getDefault())); } // Set the theme at the end so that the initialize()s above don't counteract the theme. // mOkButton.setTextColor(mAccentColor); // mCancelButton.setTextColor(mAccentColor); timePickerHeader.setBackgroundColor(getResources().getColor(R.color.mdtp_white)); findViewById(R.id.time_display_background).setBackgroundColor(getResources().getColor(R.color.mdtp_white)); findViewById(R.id.time_display).setBackgroundColor(getResources().getColor(R.color.mdtp_white)); /*if(getDialog() == null) { view.findViewById(R.id.done_background).setVisibility(View.GONE); }*/ int circleBackground = ContextCompat.getColor(context, R.color.mdtp_circle_background); int backgroundColor = ContextCompat.getColor(context, R.color.mdtp_background_color); int darkBackgroundColor = ContextCompat.getColor(context, R.color.mdtp_light_gray); int lightGray = ContextCompat.getColor(context, R.color.mdtp_light_gray); // mTimePicker.setBackgroundColor(mThemeDark? lightGray : circleBackground); mTimePicker.setBackgroundColor(mThemeDark ? lightGray : circleBackground); findViewById(R.id.time_picker_view).setBackgroundColor(mThemeDark ? darkBackgroundColor : backgroundColor); }