Search in sources :

Example 6 with NumberPickerBuilder

use of com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder 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 7 with NumberPickerBuilder

use of com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder in project android-betterpickers by code-troopers.

the class SampleNumberThemeCustom 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.number_picker_set);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            NumberPickerBuilder npb = new NumberPickerBuilder().setFragmentManager(getSupportFragmentManager()).setStyleResId(R.style.MyCustomBetterPickerTheme);
            npb.show();
        }
    });
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) View(android.view.View) NumberPickerBuilder(com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder)

Example 8 with NumberPickerBuilder

use of com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder in project android-betterpickers by code-troopers.

the class SampleNumberThemeLight 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.number_picker_set);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            NumberPickerBuilder npb = new NumberPickerBuilder().setFragmentManager(getSupportFragmentManager()).setStyleResId(R.style.BetterPickersDialogFragment_Light);
            npb.show();
        }
    });
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) View(android.view.View) NumberPickerBuilder(com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder)

Example 9 with NumberPickerBuilder

use of com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder in project android-betterpickers by code-troopers.

the class SampleNumberDismissListener 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.number_picker_set);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            NumberPickerBuilder npb = new NumberPickerBuilder().setFragmentManager(getSupportFragmentManager()).setStyleResId(R.style.BetterPickersDialogFragment).addNumberPickerDialogHandler(SampleNumberDismissListener.this).setOnDismissListener(SampleNumberDismissListener.this);
            npb.show();
        }
    });
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) View(android.view.View) NumberPickerBuilder(com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder)

Example 10 with NumberPickerBuilder

use of com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder in project android-betterpickers by code-troopers.

the class SampleNumberMultipleHandlers 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.number_picker_set);
    button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            NumberPickerBuilder npb = new NumberPickerBuilder().setFragmentManager(getSupportFragmentManager()).setStyleResId(R.style.BetterPickersDialogFragment).addNumberPickerDialogHandler(new MyCustomHandler());
            npb.show();
        }
    });
}
Also used : Button(android.widget.Button) TextView(android.widget.TextView) View(android.view.View) NumberPickerBuilder(com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder)

Aggregations

View (android.view.View)10 TextView (android.widget.TextView)10 NumberPickerBuilder (com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder)10 Button (android.widget.Button)9 BigDecimal (java.math.BigDecimal)3 DialogInterface (android.content.DialogInterface)1 AdapterView (android.widget.AdapterView)1 OnDialogDismissListener (com.codetroopers.betterpickers.OnDialogDismissListener)1 CalendarDatePickerDialogFragment (com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment)1 RadialTimePickerDialogFragment (com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment)1 Calendar (java.util.Calendar)1 Time (ve.com.abicelis.remindy.model.Time)1