Search in sources :

Example 16 with CalendarDatePickerDialogFragment

use of com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment in project android-betterpickers by code-troopers.

the class SampleCalendarDateRange method onResume.

@Override
public void onResume() {
    // Example of reattaching to the fragment
    super.onResume();
    CalendarDatePickerDialogFragment calendarDatePickerDialogFragment = (CalendarDatePickerDialogFragment) getSupportFragmentManager().findFragmentByTag(FRAG_TAG_DATE_PICKER);
    if (calendarDatePickerDialogFragment != null) {
        calendarDatePickerDialogFragment.setOnDateSetListener(this);
    }
}
Also used : CalendarDatePickerDialogFragment(com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment)

Example 17 with CalendarDatePickerDialogFragment

use of com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment in project android-betterpickers by code-troopers.

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

        @Override
        public void onClick(View v) {
            DateTime now = DateTime.now();
            MonthAdapter.CalendarDay minDate = new MonthAdapter.CalendarDay(now.getYear(), now.getMonthOfYear() - 2, now.getDayOfMonth());
            MonthAdapter.CalendarDay maxDate = new MonthAdapter.CalendarDay(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth());
            CalendarDatePickerDialogFragment cdp = new CalendarDatePickerDialogFragment().setDateRange(minDate, maxDate).setOnDateSetListener(SampleCalendarDateRange.this);
            cdp.show(getSupportFragmentManager(), FRAG_TAG_DATE_PICKER);
        }
    });
}
Also used : CalendarDatePickerDialogFragment(com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment) Button(android.widget.Button) MonthAdapter(com.codetroopers.betterpickers.calendardatepicker.MonthAdapter) TextView(android.widget.TextView) View(android.view.View) DateTime(org.joda.time.DateTime)

Example 18 with CalendarDatePickerDialogFragment

use of com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment in project android-betterpickers by code-troopers.

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

        @Override
        public void onClick(View v) {
            DateTime now = DateTime.now();
            MonthAdapter.CalendarDay minDate = new MonthAdapter.CalendarDay(now.getYear(), now.getMonthOfYear() - 2, now.getDayOfMonth());
            MonthAdapter.CalendarDay maxDate = new MonthAdapter.CalendarDay(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth());
            // Initialize disabled days list
            // Disabled days are located at a formatted location in the format "yyyyMMdd"
            SparseArray<MonthAdapter.CalendarDay> disabledDays = new SparseArray<>();
            Calendar startCal = Calendar.getInstance();
            startCal.setTimeInMillis(minDate.getDateInMillis());
            Calendar endCal = Calendar.getInstance();
            endCal.setTimeInMillis(maxDate.getDateInMillis());
            // Add all weekend days within range to disabled days
            while (startCal.before(endCal)) {
                if (startCal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || startCal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY) {
                    int key = Utils.formatDisabledDayForKey(startCal.get(Calendar.YEAR), startCal.get(Calendar.MONTH), startCal.get(Calendar.DAY_OF_MONTH));
                    disabledDays.put(key, new MonthAdapter.CalendarDay(startCal));
                }
                startCal.add(Calendar.DATE, 1);
            }
            CalendarDatePickerDialogFragment cdp = new CalendarDatePickerDialogFragment().setDateRange(minDate, maxDate).setDisabledDays(disabledDays).setOnDateSetListener(SampleCalendarDateRangeAndDisabledDays.this);
            cdp.show(getSupportFragmentManager(), FRAG_TAG_DATE_PICKER);
        }
    });
}
Also used : SparseArray(android.util.SparseArray) CalendarDatePickerDialogFragment(com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment) Button(android.widget.Button) MonthAdapter(com.codetroopers.betterpickers.calendardatepicker.MonthAdapter) Calendar(java.util.Calendar) TextView(android.widget.TextView) View(android.view.View) DateTime(org.joda.time.DateTime)

Example 19 with CalendarDatePickerDialogFragment

use of com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment in project android-betterpickers by code-troopers.

the class SampleCalendarDateRangeAndDisabledDays method onResume.

@Override
public void onResume() {
    // Example of reattaching to the fragment
    super.onResume();
    CalendarDatePickerDialogFragment calendarDatePickerDialogFragment = (CalendarDatePickerDialogFragment) getSupportFragmentManager().findFragmentByTag(FRAG_TAG_DATE_PICKER);
    if (calendarDatePickerDialogFragment != null) {
        calendarDatePickerDialogFragment.setOnDateSetListener(this);
    }
}
Also used : CalendarDatePickerDialogFragment(com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment)

Example 20 with CalendarDatePickerDialogFragment

use of com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment in project android-betterpickers by code-troopers.

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

        @Override
        public void onClick(View v) {
            DateTime now = DateTime.now();
            MonthAdapter.CalendarDay maxDate = new MonthAdapter.CalendarDay(now.getYear(), now.getMonthOfYear(), now.getDayOfMonth());
            CalendarDatePickerDialogFragment cdp = new CalendarDatePickerDialogFragment().setDateRange(null, maxDate).setOnDateSetListener(SampleCalendarDateRangeMax.this);
            cdp.show(getSupportFragmentManager(), FRAG_TAG_DATE_PICKER);
        }
    });
}
Also used : CalendarDatePickerDialogFragment(com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment) Button(android.widget.Button) MonthAdapter(com.codetroopers.betterpickers.calendardatepicker.MonthAdapter) TextView(android.widget.TextView) View(android.view.View) DateTime(org.joda.time.DateTime)

Aggregations

CalendarDatePickerDialogFragment (com.codetroopers.betterpickers.calendardatepicker.CalendarDatePickerDialogFragment)26 View (android.view.View)14 TextView (android.widget.TextView)13 Button (android.widget.Button)11 MonthAdapter (com.codetroopers.betterpickers.calendardatepicker.MonthAdapter)5 DateTime (org.joda.time.DateTime)5 RadialTimePickerDialogFragment (com.codetroopers.betterpickers.radialtimepicker.RadialTimePickerDialogFragment)3 Calendar (java.util.Calendar)3 AdapterView (android.widget.AdapterView)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 SparseArray (android.util.SparseArray)1 OnDialogDismissListener (com.codetroopers.betterpickers.OnDialogDismissListener)1 NumberPickerBuilder (com.codetroopers.betterpickers.numberpicker.NumberPickerBuilder)1 BigDecimal (java.math.BigDecimal)1