com.wdullaer.materialdatetimepicker.R Java Examples
The following examples show how to use
com.wdullaer.materialdatetimepicker.R.
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: TimePickerDialog.java From MaterialDateTimePicker with Apache License 2.0 | 6 votes |
public void initialize(OnTimeSetListener callback, int hourOfDay, int minute, int second, boolean is24HourMode) { mCallback = callback; mInitialTime = new Timepoint(hourOfDay, minute, second); mIs24HourMode = is24HourMode; mInKbMode = false; mTitle = ""; mThemeDark = false; mThemeDarkChanged = false; mVibrate = true; mDismissOnPause = false; mEnableSeconds = false; mEnableMinutes = true; mOkResid = R.string.mdtp_ok; mCancelResid = R.string.mdtp_cancel; mVersion = Build.VERSION.SDK_INT < Build.VERSION_CODES.M ? Version.VERSION_1 : Version.VERSION_2; // Throw away the current TimePicker, which might contain old state if the dialog instance is reused mTimePicker = null; }
Example #2
Source File: CircleView.java From AssistantBySDK with Apache License 2.0 | 6 votes |
public void initialize(Context context, TimePickerController controller) { if (mIsInitialized) { Log.e(TAG, "CircleView may only be initialized once."); return; } Resources res = context.getResources(); int colorRes = controller.isThemeDark() ? R.color.mdtp_circle_background_dark_theme : R.color.mdtp_circle_color; mCircleColor = getResources().getColor(colorRes); mDotColor = controller.getAccentColor(); mPaint.setAntiAlias(true); mIs24HourMode = controller.is24HourMode(); if (mIs24HourMode || controller.getVersion() != TimePickerDialog.Version.VERSION_1) { mCircleRadiusMultiplier = Float.parseFloat( res.getString(R.string.mdtp_circle_radius_multiplier_24HourMode)); } else { mCircleRadiusMultiplier = Float.parseFloat( res.getString(R.string.mdtp_circle_radius_multiplier)); mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier)); } mIsInitialized = true; }
Example #3
Source File: YearPickerView.java From AlarmOn with Apache License 2.0 | 6 votes |
/** * @param context */ public YearPickerView(Context context, DatePickerController controller) { super(context); mController = controller; mController.registerOnDateChangedListener(this); ViewGroup.LayoutParams frame = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); setLayoutParams(frame); Resources res = context.getResources(); mViewSize = res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height); mChildSize = res.getDimensionPixelOffset(R.dimen.mdtp_year_label_height); setVerticalFadingEdgeEnabled(true); setFadingEdgeLength(mChildSize / 3); init(context); setOnItemClickListener(this); setSelector(new StateListDrawable()); setDividerHeight(0); onDateChanged(); }
Example #4
Source File: CircleView.java From AlarmOn with Apache License 2.0 | 6 votes |
public void initialize(Context context, TimePickerController controller) { if (mIsInitialized) { Log.e(TAG, "CircleView may only be initialized once."); return; } Resources res = context.getResources(); int colorRes = controller.isThemeDark() ? R.color.mdtp_circle_background_dark_theme : R.color.mdtp_circle_color; mCircleColor = ContextCompat.getColor(context, colorRes); mDotColor = controller.getAccentColor(); mPaint.setAntiAlias(true); mIs24HourMode = controller.is24HourMode(); if (mIs24HourMode) { mCircleRadiusMultiplier = Float.parseFloat( res.getString(R.string.mdtp_circle_radius_multiplier_24HourMode)); } else { mCircleRadiusMultiplier = Float.parseFloat( res.getString(R.string.mdtp_circle_radius_multiplier)); mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier)); } mIsInitialized = true; }
Example #5
Source File: TimePickerDialog.java From Blackbulb with GNU General Public License v3.0 | 6 votes |
public void initialize(OnTimeSetListener callback, int hourOfDay, int minute, int second, boolean is24HourMode) { mCallback = callback; mInitialTime = new Timepoint(hourOfDay, minute, second); mIs24HourMode = is24HourMode; mInKbMode = false; mTitle = ""; mThemeDark = false; mThemeDarkChanged = false; mAccentColor = -1; mVibrate = true; mDismissOnPause = false; mEnableSeconds = false; mEnableMinutes = true; mOkResid = R.string.mdtp_ok; mOkColor = -1; mCancelResid = R.string.mdtp_cancel; mCancelColor = -1; mVersion = Build.VERSION.SDK_INT < Build.VERSION_CODES.M ? Version.VERSION_1 : Version.VERSION_2; }
Example #6
Source File: CircleView.java From Blackbulb with GNU General Public License v3.0 | 6 votes |
public void initialize(Context context, TimePickerController controller) { if (mIsInitialized) { Log.e(TAG, "CircleView may only be initialized once."); return; } Resources res = context.getResources(); int colorRes = controller.isThemeDark() ? R.color.mdtp_circle_background_dark_theme : R.color.mdtp_circle_color; mCircleColor = context.getResources().getColor(colorRes); mDotColor = controller.getAccentColor(); mPaint.setAntiAlias(true); mIs24HourMode = controller.is24HourMode(); if (mIs24HourMode || controller.getVersion() != TimePickerDialog.Version.VERSION_1) { mCircleRadiusMultiplier = Float.parseFloat( res.getString(R.string.mdtp_circle_radius_multiplier_24HourMode)); } else { mCircleRadiusMultiplier = Float.parseFloat( res.getString(R.string.mdtp_circle_radius_multiplier)); mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier)); } mIsInitialized = true; }
Example #7
Source File: CircleView.java From MaterialDateTimePicker with Apache License 2.0 | 6 votes |
public void initialize(Context context, TimePickerController controller) { if (mIsInitialized) { Log.e(TAG, "CircleView may only be initialized once."); return; } Resources res = context.getResources(); int colorRes = controller.isThemeDark() ? R.color.mdtp_circle_background_dark_theme : R.color.mdtp_circle_color; mCircleColor = ContextCompat.getColor(context, colorRes); mDotColor = controller.getAccentColor(); mPaint.setAntiAlias(true); mIs24HourMode = controller.is24HourMode(); if (mIs24HourMode || controller.getVersion() != TimePickerDialog.Version.VERSION_1) { mCircleRadiusMultiplier = Float.parseFloat( res.getString(R.string.mdtp_circle_radius_multiplier_24HourMode)); } else { mCircleRadiusMultiplier = Float.parseFloat( res.getString(R.string.mdtp_circle_radius_multiplier)); mAmPmCircleRadiusMultiplier = Float.parseFloat(res.getString(R.string.mdtp_ampm_circle_radius_multiplier)); } mIsInitialized = true; }
Example #8
Source File: YearPickerView.java From AssistantBySDK with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { TextViewWithCircularIndicator v; if (convertView != null) { v = (TextViewWithCircularIndicator) convertView; } else { v = (TextViewWithCircularIndicator) LayoutInflater.from(parent.getContext()) .inflate(R.layout.mdtp_year_label_text_view, parent, false); v.setAccentColor(mController.getAccentColor(), mController.isThemeDark()); } int year = mMinYear + position; boolean selected = mController.getSelectedDay().year == year; v.setText(String.valueOf(year)); v.drawIndicator(selected); v.requestLayout(); if (selected) { mSelectedView = v; } return v; }
Example #9
Source File: YearPickerView.java From AssistantBySDK with Apache License 2.0 | 6 votes |
public YearPickerView(Context context, DatePickerController controller) { super(context); mController = controller; mController.registerOnDateChangedListener(this); ViewGroup.LayoutParams frame = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); setLayoutParams(frame); Resources res = context.getResources(); mViewSize = res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height); mChildSize = res.getDimensionPixelOffset(R.dimen.mdtp_year_label_height); setVerticalFadingEdgeEnabled(true); setFadingEdgeLength(mChildSize / 3); init(); setOnItemClickListener(this); setSelector(new StateListDrawable()); setDividerHeight(0); onDateChanged(); }
Example #10
Source File: YearPickerView.java From MaterialDateTimePicker with Apache License 2.0 | 6 votes |
public YearPickerView(Context context, DatePickerController controller) { super(context); mController = controller; mController.registerOnDateChangedListener(this); ViewGroup.LayoutParams frame = new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); setLayoutParams(frame); Resources res = context.getResources(); mViewSize = mController.getVersion() == DatePickerDialog.Version.VERSION_1 ? res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height) : res.getDimensionPixelOffset(R.dimen.mdtp_date_picker_view_animator_height_v2); mChildSize = res.getDimensionPixelOffset(R.dimen.mdtp_year_label_height); setVerticalFadingEdgeEnabled(true); setFadingEdgeLength(mChildSize / 3); init(); setOnItemClickListener(this); setSelector(new StateListDrawable()); setDividerHeight(0); onDateChanged(); }
Example #11
Source File: YearPickerView.java From MaterialDateTimePicker with Apache License 2.0 | 6 votes |
@Override public View getView(int position, View convertView, ViewGroup parent) { TextViewWithCircularIndicator v; if (convertView != null) { v = (TextViewWithCircularIndicator) convertView; } else { v = (TextViewWithCircularIndicator) LayoutInflater.from(parent.getContext()) .inflate(R.layout.mdtp_year_label_text_view, parent, false); v.setAccentColor(mController.getAccentColor(), mController.isThemeDark()); } int year = mMinYear + position; boolean selected = mController.getSelectedDay().year == year; v.setText(String.format(mController.getLocale(),"%d", year)); v.drawIndicator(selected); v.requestLayout(); if (selected) { mSelectedView = v; } return v; }
Example #12
Source File: TimePickerDialog.java From AssistantBySDK with Apache License 2.0 | 6 votes |
public void initialize(OnTimeSetListener callback, int hourOfDay, int minute, int second, boolean is24HourMode) { mCallback = callback; mInitialTime = new Timepoint(hourOfDay, minute, second); mIs24HourMode = is24HourMode; mInKbMode = false; mTitle = ""; mThemeDark = false; mThemeDarkChanged = false; mAccentColor = -1; mVibrate = true; mDismissOnPause = false; mEnableSeconds = false; mEnableMinutes = true; mOkResid = R.string.mdtp_ok; mOkColor = -1; mCancelResid = R.string.mdtp_cancel; mCancelColor = -1; mVersion = Build.VERSION.SDK_INT < 23 ? Version.VERSION_1 : Version.VERSION_2; }
Example #13
Source File: MonthView.java From MaterialDateTimePicker with Apache License 2.0 | 5 votes |
@NonNull private String getMonthAndYearString() { Locale locale = mController.getLocale(); String pattern = "MMMM yyyy"; if (Build.VERSION.SDK_INT < 18) pattern = getContext().getResources().getString(R.string.mdtp_date_v1_monthyear); else pattern = DateFormat.getBestDateTimePattern(locale, pattern); SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); formatter.setTimeZone(mController.getTimeZone()); formatter.applyLocalizedPattern(pattern); mStringBuilder.setLength(0); return formatter.format(mCalendar.getTime()); }
Example #14
Source File: TimePickerDialog.java From AlarmOn with Apache License 2.0 | 5 votes |
public void initialize(int hourOfDay, int minute, int second, boolean is24HourMode) { mInitialTime = new Timepoint(hourOfDay, minute, second); mIs24HourMode = is24HourMode; mInKbMode = false; mTitle = ""; mThemeDark = false; mThemeDarkChanged = false; mAccentColor = -1; mVibrate = true; mDismissOnPause = false; mEnableSeconds = false; mOkResid = R.string.mdtp_ok; mCancelResid = R.string.mdtp_cancel; }
Example #15
Source File: DatePickerDialog.java From MaterialDateTimePicker with Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { tryVibrate(); if (v.getId() == R.id.mdtp_date_picker_year) { setCurrentView(YEAR_VIEW); } else if (v.getId() == R.id.mdtp_date_picker_month_and_day) { setCurrentView(MONTH_AND_DAY_VIEW); } }
Example #16
Source File: DayPickerGroup.java From MaterialDateTimePicker with Apache License 2.0 | 5 votes |
private void init() { dayPickerView = new SimpleDayPickerView(getContext(), controller); addView(dayPickerView); final LayoutInflater inflater = LayoutInflater.from(getContext()); final ViewGroup content = (ViewGroup) inflater.inflate(R.layout.mdtp_daypicker_group, this, false); // Transfer all children from the content to this while (content.getChildCount() > 0) { final View view = content.getChildAt(0); content.removeViewAt(0); addView(view); } prevButton = findViewById(R.id.mdtp_previous_month_arrow); nextButton = findViewById(R.id.mdtp_next_month_arrow); if (controller.getVersion() == DatePickerDialog.Version.VERSION_1) { int size = Utils.dpToPx(16f, getResources()); prevButton.setMinimumHeight(size); prevButton.setMinimumWidth(size); nextButton.setMinimumHeight(size); nextButton.setMinimumWidth(size); } if (controller.isThemeDark()) { int color = ContextCompat.getColor(getContext(), R.color.mdtp_date_picker_text_normal_dark_theme); prevButton.setColorFilter(color); nextButton.setColorFilter(color); } prevButton.setOnClickListener(this); nextButton.setOnClickListener(this); dayPickerView.setOnPageListener(this); }
Example #17
Source File: TextViewWithCircularIndicator.java From AlarmOn with Apache License 2.0 | 5 votes |
/** * Programmatically set the color state list (see mdtp_date_picker_year_selector) * @param accentColor pressed state text color * @param darkMode current theme mode * @return ColorStateList with pressed state */ private ColorStateList createTextColor(int accentColor, boolean darkMode) { int[][] states = new int[][]{ new int[]{android.R.attr.state_pressed}, // pressed new int[]{android.R.attr.state_selected}, // selected new int[]{} }; int[] colors = new int[]{ accentColor, Color.WHITE, darkMode ? Color.WHITE : Color.BLACK }; return new ColorStateList(states, colors); }
Example #18
Source File: TextViewWithCircularIndicator.java From AlarmOn with Apache License 2.0 | 5 votes |
public TextViewWithCircularIndicator(Context context, AttributeSet attrs) { super(context, attrs); mCircleColor = ContextCompat.getColor(context, R.color.mdtp_accent_color); mItemIsSelectedText = context.getResources().getString(R.string.mdtp_item_is_selected); init(); }
Example #19
Source File: DatePickerDialog.java From AlarmOn with Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { tryVibrate(); if (v.getId() == R.id.date_picker_year) { setCurrentView(YEAR_VIEW); } else if (v.getId() == R.id.date_picker_month_and_day) { setCurrentView(MONTH_AND_DAY_VIEW); } }
Example #20
Source File: YearPickerView.java From AlarmOn with Apache License 2.0 | 5 votes |
private void init(Context context) { ArrayList<String> years = new ArrayList<>(); for (int year = mController.getMinYear(); year <= mController.getMaxYear(); year++) { years.add(String.format("%d", year)); } mAdapter = new YearAdapter(context, R.layout.mdtp_year_label_text_view, years); setAdapter(mAdapter); }
Example #21
Source File: DayPickerGroup.java From MaterialDateTimePicker with Apache License 2.0 | 5 votes |
@Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { final ImageButton leftButton; final ImageButton rightButton; if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL) { leftButton = nextButton; rightButton = prevButton; } else { leftButton = prevButton; rightButton = nextButton; } final int topMargin = controller.getVersion() == DatePickerDialog.Version.VERSION_1 ? 0 : getContext().getResources().getDimensionPixelSize(R.dimen.mdtp_date_picker_view_animator_padding_v2); final int width = right - left; final int height = bottom - top; dayPickerView.layout(0, topMargin, width, height); final SimpleMonthView monthView = (SimpleMonthView) dayPickerView.getChildAt(0); final int monthHeight = monthView.getMonthHeight(); final int cellWidth = monthView.getCellWidth(); final int edgePadding = monthView.getEdgePadding(); // Vertically center the previous/next buttons within the month // header, horizontally center within the day cell. final int leftDW = leftButton.getMeasuredWidth(); final int leftDH = leftButton.getMeasuredHeight(); final int leftIconTop = topMargin + monthView.getPaddingTop() + (monthHeight - leftDH) / 2; final int leftIconLeft = edgePadding + (cellWidth - leftDW) / 2; leftButton.layout(leftIconLeft, leftIconTop, leftIconLeft + leftDW, leftIconTop + leftDH); final int rightDW = rightButton.getMeasuredWidth(); final int rightDH = rightButton.getMeasuredHeight(); final int rightIconTop = topMargin + monthView.getPaddingTop() + (monthHeight - rightDH) / 2; final int rightIconRight = width - edgePadding - (cellWidth - rightDW) / 2 - 2; rightButton.layout(rightIconRight - rightDW, rightIconTop, rightIconRight, rightIconTop + rightDH); }
Example #22
Source File: TextViewWithCircularIndicator.java From MaterialDateTimePicker with Apache License 2.0 | 5 votes |
public TextViewWithCircularIndicator(Context context, AttributeSet attrs) { super(context, attrs); mCircleColor = ContextCompat.getColor(context, R.color.mdtp_accent_color); mItemIsSelectedText = context.getResources().getString(R.string.mdtp_item_is_selected); init(); }
Example #23
Source File: MonthView.java From AlarmOn with Apache License 2.0 | 5 votes |
/** * Generates a description for a given time object. Since this * description will be spoken, the components are ordered by descending * specificity as DAY MONTH YEAR. * * @param day The day to generate a description for * @return A description of the time object */ protected CharSequence getItemDescription(int day) { mTempCalendar.set(mYear, mMonth, day); final CharSequence date = DateFormat.format(DATE_FORMAT, mTempCalendar.getTimeInMillis()); if (day == mSelectedDay) { return getContext().getString(R.string.mdtp_item_is_selected, date); } return date; }
Example #24
Source File: MonthView.java From AlarmOn with Apache License 2.0 | 5 votes |
@NonNull private String getMonthAndYearString() { Locale locale = Locale.getDefault(); String pattern = "MMMM yyyy"; if(Build.VERSION.SDK_INT < 18) pattern = getContext().getResources().getString(R.string.mdtp_date_v1_monthyear); else pattern = DateFormat.getBestDateTimePattern(locale, pattern); SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); formatter.applyLocalizedPattern(pattern); mStringBuilder.setLength(0); return formatter.format(mCalendar.getTime()); }
Example #25
Source File: TextViewWithCircularIndicator.java From MaterialDateTimePicker with Apache License 2.0 | 5 votes |
/** * Programmatically set the color state list (see mdtp_date_picker_year_selector) * @param accentColor pressed state text color * @param darkMode current theme mode * @return ColorStateList with pressed state */ private ColorStateList createTextColor(int accentColor, boolean darkMode) { int[][] states = new int[][]{ new int[]{android.R.attr.state_pressed}, // pressed new int[]{android.R.attr.state_selected}, // selected new int[]{} }; int[] colors = new int[]{ accentColor, Color.WHITE, darkMode ? Color.WHITE : Color.BLACK }; return new ColorStateList(states, colors); }
Example #26
Source File: MonthView.java From AssistantBySDK with Apache License 2.0 | 5 votes |
@NonNull private String getMonthAndYearString() { Locale locale = Locale.getDefault(); String pattern = "MMMM yyyy"; if(Build.VERSION.SDK_INT < 18) pattern = getContext().getResources().getString(R.string.mdtp_date_v1_monthyear); else pattern = DateFormat.getBestDateTimePattern(locale, pattern); SimpleDateFormat formatter = new SimpleDateFormat(pattern, locale); formatter.applyLocalizedPattern(pattern); mStringBuilder.setLength(0); return formatter.format(mCalendar.getTime()); }
Example #27
Source File: MonthView.java From AssistantBySDK with Apache License 2.0 | 5 votes |
/** * Generates a description for a given time object. Since this * description will be spoken, the components are ordered by descending * specificity as DAY MONTH YEAR. * * @param day The day to generate a description for * @return A description of the time object */ protected CharSequence getItemDescription(int day) { mTempCalendar.set(mYear, mMonth, day); final CharSequence date = DateFormat.format(DATE_FORMAT, mTempCalendar.getTimeInMillis()); if (day == mSelectedDay) { return getContext().getString(R.string.mdtp_item_is_selected, date); } return date; }
Example #28
Source File: DatePickerDialog.java From AssistantBySDK with Apache License 2.0 | 5 votes |
@Override public void onClick(View v) { tryVibrate(); if (v.getId() == R.id.date_picker_year) { setCurrentView(YEAR_VIEW); } else if (v.getId() == R.id.date_picker_month_and_day) { setCurrentView(MONTH_AND_DAY_VIEW); } }
Example #29
Source File: TextViewWithCircularIndicator.java From AssistantBySDK with Apache License 2.0 | 5 votes |
/** * Programmatically set the color state list (see mdtp_date_picker_year_selector) * @param accentColor pressed state text color * @param darkMode current theme mode * @return ColorStateList with pressed state */ private ColorStateList createTextColor(int accentColor, boolean darkMode) { int[][] states = new int[][]{ new int[]{android.R.attr.state_pressed}, // pressed new int[]{android.R.attr.state_selected}, // selected new int[]{} }; int[] colors = new int[]{ accentColor, Color.WHITE, darkMode ? Color.WHITE : Color.BLACK }; return new ColorStateList(states, colors); }
Example #30
Source File: TextViewWithCircularIndicator.java From AssistantBySDK with Apache License 2.0 | 5 votes |
public TextViewWithCircularIndicator(Context context, AttributeSet attrs) { super(context, attrs); mCircleColor = getResources().getColor(R.color.mdtp_accent_color); mItemIsSelectedText = context.getResources().getString(R.string.mdtp_item_is_selected); init(); }