Search in sources :

Example 11 with RadialTimePickerDialogFragment

use of com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment in project Remindy by abicelis.

the class EditOneTimeReminderFragment method setupDateAndTimePickers.

private void setupDateAndTimePickers() {
    final Calendar mToday = Calendar.getInstance();
    final Calendar mTomorrow = Calendar.getInstance();
    mTomorrow.add(Calendar.DAY_OF_MONTH, 1);
    mDate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mDatePicker = new CalendarDatePickerDialogFragment().setOnDateSetListener(new CalendarDatePickerDialogFragment.OnDateSetListener() {

                @Override
                public void onDateSet(CalendarDatePickerDialogFragment dialog, int year, int monthOfYear, int dayOfMonth) {
                    if (mReminder.getDate() == null) {
                        mReminder.setDate(CalendarUtil.getNewInstanceZeroedCalendar());
                    }
                    mReminder.getDate().set(year, monthOfYear, dayOfMonth);
                    mDate.setText(mDateFormat.formatCalendar(mReminder.getDate()));
                }
            }).setPreselectedDate(mToday.get(Calendar.YEAR), mToday.get(Calendar.MONTH), mToday.get(Calendar.DAY_OF_MONTH)).setDateRange(new MonthAdapter.CalendarDay(mToday), null).setDoneText(getResources().getString(R.string.datepicker_ok)).setCancelText(getResources().getString(R.string.datepicker_cancel));
            mDatePicker.show(getFragmentManager(), "mDate");
        }
    });
    mTime.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            RadialTimePickerDialogFragment rtpd = new RadialTimePickerDialogFragment().setOnTimeSetListener(new RadialTimePickerDialogFragment.OnTimeSetListener() {

                @Override
                public void onTimeSet(RadialTimePickerDialogFragment dialog, int hourOfDay, int minute) {
                    if (mReminder.getTime() == null) {
                        mReminder.setTime(new Time());
                        mReminder.getTime().setDisplayTimeFormat(SharedPreferenceUtil.getTimeFormat(getActivity()));
                    }
                    mReminder.getTime().setHour(hourOfDay);
                    mReminder.getTime().setMinute(minute);
                    mTime.setText(mReminder.getTime().toString());
                }
            }).setStartTime(12, 0).setDoneText(getResources().getString(R.string.datepicker_ok)).setCancelText(getResources().getString(R.string.datepicker_cancel));
            if (SharedPreferenceUtil.getTimeFormat(getActivity()).equals(TimeFormat.FORMAT_12H))
                rtpd.setForced12hFormat();
            else
                rtpd.setForced24hFormat();
            rtpd.show(getFragmentManager(), "mTime");
        }
    });
}
Also used : CalendarDatePickerDialogFragment(com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment) Calendar(java.util.Calendar) MonthAdapter(com.codetroopers.betterpickers.calendardatepicker.MonthAdapter) Time(ve.com.abicelis.remindy.model.Time) RadialTimePickerDialogFragment(com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment) View(android.view.View)

Example 12 with RadialTimePickerDialogFragment

use of com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment in project Remindy by abicelis.

the class EditRepeatingReminderFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.fragment_edit_repeating_reminder, container, false);
    mDate = (EditText) rootView.findViewById(R.id.fragment_edit_repeating_reminder_date);
    mTime = (EditText) rootView.findViewById(R.id.fragment_edit_repeating_reminder_time);
    mRepeatType = (Spinner) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_type);
    mTransitionsContainer = (LinearLayout) rootView.findViewById(R.id.fragment_edit_repeating_reminder_transitions_container);
    mRepeatContainer = (LinearLayout) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_container);
    mRepeatInterval = (EditText) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_interval);
    mRepeatTypeTitle = (TextView) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_type_title);
    mRepeatEndForEventsContainer = (LinearLayout) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_end_for_events_container);
    mRepeatEndUntilContainer = (LinearLayout) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_end_until_container);
    mRepeatEndForXEvents = (EditText) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_for_x_events);
    mRepeatEndType = (Spinner) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_end_type);
    mRepeatUntilDate = (EditText) rootView.findViewById(R.id.fragment_edit_repeating_reminder_repeat_until);
    mRepeatInterval.addTextChangedListener(new TextWatcher() {

        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void afterTextChanged(Editable editable) {
            try {
                mReminder.setRepeatInterval(Integer.parseInt(mRepeatInterval.getText().toString()));
            } catch (NumberFormatException e) {
                mReminder.setRepeatInterval(-1);
            }
        }
    });
    mDatePicker = new CalendarDatePickerDialogFragment();
    mRepeatUntilDatePicker = new CalendarDatePickerDialogFragment();
    mTimePicker = new RadialTimePickerDialogFragment();
    setupSpinners();
    setupDateAndTimePickers();
    setReminderValues();
    return rootView;
}
Also used : CalendarDatePickerDialogFragment(com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment) TextWatcher(android.text.TextWatcher) Editable(android.text.Editable) RadialTimePickerDialogFragment(com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) Nullable(android.support.annotation.Nullable)

Example 13 with RadialTimePickerDialogFragment

use of com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment in project Remindy by abicelis.

the class EditRepeatingReminderFragment method setupDateAndTimePickers.

private void setupDateAndTimePickers() {
    final Calendar mToday = Calendar.getInstance();
    mDate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mDatePicker.setOnDateSetListener(new CalendarDatePickerDialogFragment.OnDateSetListener() {

                @Override
                public void onDateSet(CalendarDatePickerDialogFragment dialog, int year, int monthOfYear, int dayOfMonth) {
                    if (mReminder.getDate() == null) {
                        mReminder.setDate(CalendarUtil.getNewInstanceZeroedCalendar());
                    }
                    mReminder.getDate().set(year, monthOfYear, dayOfMonth);
                    mDate.setText(mDateFormat.formatCalendar(mReminder.getDate()));
                    trySetRepeatUntilDateValidDates();
                }
            }).setDateRange(new MonthAdapter.CalendarDay(mToday), null).setDoneText(getResources().getString(R.string.datepicker_ok)).setCancelText(getResources().getString(R.string.datepicker_cancel));
            mDatePicker.show(getFragmentManager(), "mDate");
        }
    });
    mRepeatUntilDate.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mRepeatUntilDatePicker.setOnDateSetListener(new CalendarDatePickerDialogFragment.OnDateSetListener() {

                @Override
                public void onDateSet(CalendarDatePickerDialogFragment dialog, int year, int monthOfYear, int dayOfMonth) {
                    if (mReminder.getRepeatEndDate() == null) {
                        mReminder.setRepeatEndDate(CalendarUtil.getNewInstanceZeroedCalendar());
                    }
                    mReminder.getRepeatEndDate().set(year, monthOfYear, dayOfMonth);
                    mRepeatUntilDate.setText(mDateFormat.formatCalendar(mReminder.getRepeatEndDate()));
                }
            }).setDoneText(getResources().getString(R.string.datepicker_ok)).setCancelText(getResources().getString(R.string.datepicker_cancel));
            mRepeatUntilDatePicker.show(getFragmentManager(), "mRepeatUntilDate");
        }
    });
    mTime.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            mTimePicker = new RadialTimePickerDialogFragment().setOnTimeSetListener(new RadialTimePickerDialogFragment.OnTimeSetListener() {

                @Override
                public void onTimeSet(RadialTimePickerDialogFragment dialog, int hourOfDay, int minute) {
                    if (mReminder.getTime() == null) {
                        mReminder.setTime(new Time());
                        mReminder.getTime().setDisplayTimeFormat(SharedPreferenceUtil.getTimeFormat(getActivity()));
                    }
                    mReminder.getTime().setHour(hourOfDay);
                    mReminder.getTime().setMinute(minute);
                    mTime.setText(mReminder.getTime().toString());
                }
            }).setDoneText(getResources().getString(R.string.datepicker_ok)).setCancelText(getResources().getString(R.string.datepicker_cancel));
            if (SharedPreferenceUtil.getTimeFormat(getActivity()).equals(TimeFormat.FORMAT_12H))
                mTimePicker.setForced12hFormat();
            else
                mTimePicker.setForced24hFormat();
            mTimePicker.show(getFragmentManager(), "mTime");
        }
    });
    mRepeatInterval.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new NumberPickerBuilder().setReference(0).setFragmentManager(getChildFragmentManager()).setTargetFragment(EditRepeatingReminderFragment.this).setStyleResId(R.style.BetterPickersDialogFragment_Light).setMaxNumber(new BigDecimal(99)).setMinNumber(new BigDecimal(1)).setDecimalVisibility(View.GONE).setPlusMinusVisibility(View.GONE).setOnDismissListener(new OnDialogDismissListener() {

                @Override
                public void onDialogDismiss(DialogInterface dialoginterface) {
                    trySetRepeatUntilDateValidDates();
                }
            }).show();
        }
    });
    mRepeatEndForXEvents.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new NumberPickerBuilder().setReference(1).setFragmentManager(getChildFragmentManager()).setTargetFragment(EditRepeatingReminderFragment.this).setStyleResId(R.style.BetterPickersDialogFragment_Light).setMaxNumber(new BigDecimal(99)).setMinNumber(new BigDecimal(1)).setDecimalVisibility(View.GONE).setPlusMinusVisibility(View.GONE).show();
        }
    });
}
Also used : OnDialogDismissListener(com.codetroopers.betterpickers.OnDialogDismissListener) DialogInterface(android.content.DialogInterface) Calendar(java.util.Calendar) Time(ve.com.abicelis.remindy.model.Time) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) NumberPickerBuilder(com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder) BigDecimal(java.math.BigDecimal) CalendarDatePickerDialogFragment(com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment) RadialTimePickerDialogFragment(com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment)

Example 14 with RadialTimePickerDialogFragment

use of com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment in project android-betterpickers by code-troopers.

the class SampleRadialTimeBasicUsage method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.text_and_button_colored);
    mResultTextView = (TextView) findViewById(R.id.text);
    Button button = (Button) findViewById(R.id.button);
    mResultTextView.setText(R.string.no_value);
    button.setText(R.string.radial_time_picker);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            RadialTimePickerDialogFragment rtpd = new RadialTimePickerDialogFragment().setOnTimeSetListener(SampleRadialTimeBasicUsage.this);
            rtpd.show(getSupportFragmentManager(), FRAG_TAG_TIME_PICKER);
        }
    });
}
Also used : Button(android.widget.Button) RadialTimePickerDialogFragment(com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment) TextView(android.widget.TextView) View(android.view.View)

Example 15 with RadialTimePickerDialogFragment

use of com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment in project android-betterpickers by code-troopers.

the class SampleRadialTimeForced12hFormat method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.text_and_button);
    mResultTextView = (TextView) findViewById(R.id.text);
    Button button = (Button) findViewById(R.id.button);
    mResultTextView.setText(R.string.no_value);
    button.setText(R.string.radial_time_picker);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            RadialTimePickerDialogFragment rtpd = new RadialTimePickerDialogFragment().setOnTimeSetListener(SampleRadialTimeForced12hFormat.this).setForced12hFormat();
            rtpd.show(getSupportFragmentManager(), FRAG_TAG_TIME_PICKER);
        }
    });
}
Also used : Button(android.widget.Button) RadialTimePickerDialogFragment(com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment) TextView(android.widget.TextView) View(android.view.View)

Aggregations

RadialTimePickerDialogFragment (com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment)21 View (android.view.View)12 TextView (android.widget.TextView)11 Button (android.widget.Button)9 CalendarDatePickerDialogFragment (com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment)3 AdapterView (android.widget.AdapterView)2 Calendar (java.util.Calendar)2 Time (ve.com.abicelis.remindy.model.Time)2 DialogInterface (android.content.DialogInterface)1 Nullable (android.support.annotation.Nullable)1 Editable (android.text.Editable)1 TextWatcher (android.text.TextWatcher)1 OnDialogDismissListener (com.codetroopers.betterpickers.OnDialogDismissListener)1 MonthAdapter (com.codetroopers.betterpickers.calendardatepicker.MonthAdapter)1 NumberPickerBuilder (com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder)1 BigDecimal (java.math.BigDecimal)1