Search in sources :

Example 1 with DatePickerDialog

use of com.wdullaer.materialdatetimepicker.date.DatePickerDialog in project android-client by GenesisVision.

the class DateRangeBottomSheetFragment method showDateFromPicker.

public void showDateFromPicker(Boolean showTo) {
    DateTime dateFrom = dateRange.getFrom();
    if (dateRange.getSelectedRange().equals(DateRange.DateRangeEnum.ALL_TIME)) {
        dateFrom = dateRange.getTo();
    }
    DatePickerDialog dpd = DatePickerDialog.newInstance((view, year, monthOfYear, dayOfMonth) -> {
        setFrom(new DateTime(year, monthOfYear + 1, dayOfMonth, 0, 0, 0));
        if (showTo) {
            showDateToPicker();
        }
    }, dateFrom.getYear(), dateFrom.getMonthOfYear() - 1, dateFrom.getDayOfMonth());
    dpd.setTitle(getString(R.string.from));
    dpd.setMaxDate(dateRange.getTo().toCalendar(Locale.getDefault()));
    if (getActivity() != null) {
        dpd.show(getActivity().getFragmentManager(), "DateFromPickerDialog");
    }
}
Also used : DatePickerDialog(com.wdullaer.materialdatetimepicker.date.DatePickerDialog) DateTime(org.joda.time.DateTime)

Example 2 with DatePickerDialog

use of com.wdullaer.materialdatetimepicker.date.DatePickerDialog in project mVax by mVax-app.

the class ReportsFragment method promptForDate.

private void promptForDate(int vaccineDatabaseId, int vaccinationDatabaseId) {
    mVaccineDatabaseId = vaccineDatabaseId;
    mVaccinationDatabaseId = vaccinationDatabaseId;
    Calendar cal = Calendar.getInstance();
    DatePickerDialog datePicker = DatePickerDialog.newInstance(ReportsFragment.this, cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
    int dukeBlue = ContextCompat.getColor(getContext(), R.color.dukeBlue);
    datePicker.setAccentColor(dukeBlue);
    datePicker.show(getActivity().getFragmentManager(), "reportDatePicker");
}
Also used : DatePickerDialog(com.wdullaer.materialdatetimepicker.date.DatePickerDialog) Calendar(java.util.Calendar)

Example 3 with DatePickerDialog

use of com.wdullaer.materialdatetimepicker.date.DatePickerDialog in project mVax by mVax-app.

the class DateDetail method getValueViewListener.

@Override
public void getValueViewListener(Activity activity, WatcherEditText valueView) {
    mValueView = valueView;
    Calendar cal = Calendar.getInstance();
    int day = cal.get(Calendar.DAY_OF_MONTH);
    int month = cal.get(Calendar.MONTH);
    int year = cal.get(Calendar.YEAR);
    if (getValue() != null) {
        final LocalDate date = new LocalDate(getValue());
        day = date.getDayOfMonth();
        month = date.getMonthOfYear() - 1;
        year = date.getYear();
    }
    DatePickerDialog datePicker = DatePickerDialog.newInstance(DateDetail.this, year, month, day);
    final int dukeBlue = ContextCompat.getColor(valueView.getContext(), R.color.dukeBlue);
    datePicker.setAccentColor(dukeBlue);
    datePicker.show(activity.getFragmentManager(), "datePicker");
}
Also used : DatePickerDialog(com.wdullaer.materialdatetimepicker.date.DatePickerDialog) Calendar(java.util.Calendar) LocalDate(org.joda.time.LocalDate)

Example 4 with DatePickerDialog

use of com.wdullaer.materialdatetimepicker.date.DatePickerDialog in project UltimateAndroid by cymcsg.

the class MaterialDataTimePickerActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.material_data_time_picker_activity_main);
    // Find our View instances
    timeTextView = (TextView) findViewById(R.id.time_textview);
    dateTextView = (TextView) findViewById(R.id.date_textview);
    Button timeButton = (Button) findViewById(R.id.time_button);
    Button dateButton = (Button) findViewById(R.id.date_button);
    mode24Hours = (CheckBox) findViewById(R.id.mode_24_hours);
    modeDarkTime = (CheckBox) findViewById(R.id.mode_dark_time);
    modeDarkDate = (CheckBox) findViewById(R.id.mode_dark_date);
    // Show a timepicker when the timeButton is clicked
    timeButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Calendar now = Calendar.getInstance();
            TimePickerDialog tpd = TimePickerDialog.newInstance(MaterialDataTimePickerActivity.this, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE), mode24Hours.isChecked());
            tpd.setThemeDark(modeDarkTime.isChecked());
            tpd.setOnCancelListener(new DialogInterface.OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialogInterface) {
                    Log.d("TimePicker", "Dialog was cancelled");
                }
            });
            tpd.show(getFragmentManager(), "Timepickerdialog");
        }
    });
    // Show a datepicker when the dateButton is clicked
    dateButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Calendar now = Calendar.getInstance();
            DatePickerDialog dpd = DatePickerDialog.newInstance(MaterialDataTimePickerActivity.this, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
            dpd.setThemeDark(modeDarkDate.isChecked());
            dpd.show(getFragmentManager(), "Datepickerdialog");
        }
    });
}
Also used : Button(android.widget.Button) DialogInterface(android.content.DialogInterface) DatePickerDialog(com.wdullaer.materialdatetimepicker.date.DatePickerDialog) Calendar(java.util.Calendar) TimePickerDialog(com.wdullaer.materialdatetimepicker.time.TimePickerDialog) TextView(android.widget.TextView) View(android.view.View)

Example 5 with DatePickerDialog

use of com.wdullaer.materialdatetimepicker.date.DatePickerDialog in project CoCoin by Nightonke.

the class AccountBookListViewActivity method onDateSet.

@Override
public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) {
    if (isFrom) {
        fromYear = year;
        fromMonth = monthOfYear + 1;
        fromDay = dayOfMonth;
        Calendar now = Calendar.getInstance();
        DatePickerDialog dpd = DatePickerDialog.newInstance(this, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
        dpd.setTitle(mContext.getResources().getString(R.string.set_right_calendar));
        dpd.show(((Activity) mContext).getFragmentManager(), "Datepickerdialog");
        isFrom = false;
    } else {
        from.set(fromYear, fromMonth - 1, fromDay, 0, 0, 0);
        from.add(Calendar.SECOND, 0);
        to.set(year, monthOfYear, dayOfMonth, 23, 59, 59);
        to.add(Calendar.SECOND, 0);
        if (to.before(from)) {
            CoCoinUtil.showToast(mContext, mContext.getResources().getString(R.string.from_invalid), SuperToast.Background.RED);
        } else {
            LEFT_CALENDAR = (Calendar) from.clone();
            RIGHT_CALENDAR = (Calendar) to.clone();
            setConditions();
        }
    }
}
Also used : DatePickerDialog(com.wdullaer.materialdatetimepicker.date.DatePickerDialog) Calendar(java.util.Calendar)

Aggregations

DatePickerDialog (com.wdullaer.materialdatetimepicker.date.DatePickerDialog)11 Calendar (java.util.Calendar)6 DateTime (org.joda.time.DateTime)3 View (android.view.View)2 Button (android.widget.Button)2 TextView (android.widget.TextView)2 DialogInterface (android.content.DialogInterface)1 Color (android.graphics.Color)1 Bundle (android.os.Bundle)1 Log (android.util.Log)1 LayoutInflater (android.view.LayoutInflater)1 ViewGroup (android.view.ViewGroup)1 CheckBox (android.widget.CheckBox)1 NonNull (androidx.annotation.NonNull)1 Fragment (androidx.fragment.app.Fragment)1 TimePickerDialog (com.wdullaer.materialdatetimepicker.time.TimePickerDialog)1 LocalDate (org.joda.time.LocalDate)1