Search in sources :

Example 16 with DatePickerDialog

use of android.app.DatePickerDialog in project MyDiary by erttyy8821.

the class DatePickerFragment method onCreateDialog.

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Calendar calendar;
    savedTime = getArguments().getLong("savedTime", -1);
    calendar = Calendar.getInstance();
    if (savedTime != -1) {
        calendar.setTimeInMillis(savedTime);
    }
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DAY_OF_MONTH);
    return new DatePickerDialog(getActivity(), ThemeManager.getInstance().getPickerStyle(), onDateSetListener, year, month, day);
}
Also used : DatePickerDialog(android.app.DatePickerDialog) Calendar(java.util.Calendar)

Example 17 with DatePickerDialog

use of android.app.DatePickerDialog in project AdMoney by ErnestoGonAr.

the class PagoRecurrenteActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.pagos_recurrentes);
    bd = new BDHandlerAM(this);
    guardar = (Button) findViewById(R.id.PRguardar);
    salir = (Button) findViewById(R.id.PRsalir);
    n = (EditText) findViewById(R.id.nombre_pago);
    cant = (EditText) findViewById(R.id.PRcantidad);
    sp = (Spinner) findViewById(R.id.spinner_repetir);
    frecuencia = sp.getSelectedItemPosition();
    fecha = (DatePicker) findViewById(R.id.datepicker);
    tx = (TextView) findViewById(R.id.textoFrecuencia);
    d = (EditText) findViewById(R.id.txtdia);
    fecha.setVisibility(View.GONE);
    d.setVisibility(View.GONE);
    d.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final Calendar mcurrentDate = Calendar.getInstance();
            mYear = mcurrentDate.get(Calendar.YEAR);
            mMonth = mcurrentDate.get(Calendar.MONTH);
            mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);
            final DatePickerDialog mDatePicker = new DatePickerDialog(PagoRecurrenteActivity.this, new DatePickerDialog.OnDateSetListener() {

                public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
                    // TODO Auto-generated method stub
                    SimpleDateFormat simpledateformat = new SimpleDateFormat("EEEE");
                    Date date = new Date(selectedyear, selectedmonth, selectedday - 1);
                    String dayOfWeek = simpledateformat.format(date);
                    fechaCadena = selectedyear + "-" + (selectedmonth + 1) + "-" + selectedday;
                    d.setText(dayOfWeek + "," + fechaCadena);
                }
            }, mYear, mMonth, mDay);
            mDatePicker.setTitle("Selecciona la fecha");
            mDatePicker.show();
            date = mDay + "-" + mMonth + "-" + mYear;
        }
    });
    d.setText(date);
    sp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            if (sp.getSelectedItemPosition() == 0) {
                fecha.setVisibility(View.VISIBLE);
                d.setVisibility(View.GONE);
            }
            if (sp.getSelectedItemPosition() == 1) {
                fecha.setVisibility(View.VISIBLE);
                d.setVisibility(View.GONE);
            }
            if (sp.getSelectedItemPosition() == 2) {
                d.setVisibility(View.VISIBLE);
                fecha.setVisibility(View.GONE);
            }
            if (sp.getSelectedItemPosition() == 3) {
                fecha.setVisibility(View.VISIBLE);
                d.setVisibility(View.GONE);
            }
            if (sp.getSelectedItemPosition() == 4) {
                fecha.setVisibility(View.VISIBLE);
                d.setVisibility(View.GONE);
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
    fechaCadena = fecha.getYear() + "-" + (fecha.getMonth() + 1) + "-" + fecha.getDayOfMonth();
    fecha.init(fecha.getYear(), fecha.getMonth(), fecha.getDayOfMonth(), new DatePicker.OnDateChangedListener() {

        @Override
        public void onDateChanged(DatePicker datePicker, int year, int month, int dayOfMonth) {
            fechaCadena = fecha.getYear() + "-" + (fecha.getMonth() + 1) + "-" + fecha.getDayOfMonth();
        }
    });
    salir.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            onBackPressed();
        }
    });
    guardar.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (validar()) {
                if (cant.getText().toString().equals("")) {
                    cant.setText("0.0");
                }
                try {
                    cantidad = Float.parseFloat(cant.getText().toString());
                    if (!validar2(cantidad)) {
                        return;
                    }
                } catch (NumberFormatException e) {
                }
                nombre = n.getText().toString();
                bd.insertarRecurrentes(nombre, cantidad, fechaCadena, frecuencia);
                int idr = bd.ultIdRec();
                new AgregarNotf().agregarNotf(getApplicationContext(), nombre, cantidad, fechaCadena, frecuencia, idr);
                Intent i = new Intent(PagoRecurrenteActivity.this, MainActivity.class);
                startActivity(i);
            }
        }
    });
}
Also used : DatePickerDialog(android.app.DatePickerDialog) Calendar(java.util.Calendar) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) CalendarView(android.widget.CalendarView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) Date(java.util.Date) AdapterView(android.widget.AdapterView) DatePicker(android.widget.DatePicker) SimpleDateFormat(java.text.SimpleDateFormat)

Example 18 with DatePickerDialog

use of android.app.DatePickerDialog in project material-calendarview by prolificinteractive.

the class DynamicSettersActivity method showDatePickerDialog.

public static void showDatePickerDialog(Context context, CalendarDay day, DatePickerDialog.OnDateSetListener callback) {
    if (day == null) {
        day = CalendarDay.today();
    }
    DatePickerDialog dialog = new DatePickerDialog(context, 0, callback, day.getYear(), day.getMonth(), day.getDay());
    dialog.show();
}
Also used : DatePickerDialog(android.app.DatePickerDialog)

Example 19 with DatePickerDialog

use of android.app.DatePickerDialog in project robolectric by robolectric.

the class ShadowDatePickerDialogTest method savesTheCallback.

@Test
public void savesTheCallback() {
    DatePickerDialog.OnDateSetListener expectedDateSetListener = new DatePickerDialog.OnDateSetListener() {

        @Override
        public void onDateSet(DatePicker datePicker, int i, int i1, int i2) {
        // ignored
        }
    };
    DatePickerDialog datePickerDialog = new DatePickerDialog(RuntimeEnvironment.application, expectedDateSetListener, 2012, 6, 7);
    ShadowDatePickerDialog shadowDatePickerDialog = shadowOf(datePickerDialog);
    assertThat(shadowDatePickerDialog.getOnDateSetListenerCallback()).isEqualTo(expectedDateSetListener);
}
Also used : DatePickerDialog(android.app.DatePickerDialog) DatePicker(android.widget.DatePicker) Test(org.junit.Test)

Example 20 with DatePickerDialog

use of android.app.DatePickerDialog in project diary by billthefarmer.

the class DatePickerFragment method onCreateDialog.

// onCreateDialog
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle bundle = getArguments();
    long time = bundle.getLong(Diary.DATE);
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(time);
    // Create a new instance of DatePickerDialog
    DatePickerDialog dialog = new DatePickerDialog(getActivity(), (DatePickerDialog.OnDateSetListener) getActivity(), calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DATE));
    // Set up the date picker
    if (Build.VERSION.SDK_INT < Diary.VERSION_NOUGAT) {
        DatePicker picker = dialog.getDatePicker();
        Configuration config = getResources().getConfiguration();
        switch(config.screenLayout & Configuration.SCREENLAYOUT_SIZE_MASK) {
            case Configuration.SCREENLAYOUT_SIZE_SMALL:
                picker.setCalendarViewShown(true);
                picker.setSpinnersShown(false);
                break;
            case Configuration.SCREENLAYOUT_SIZE_NORMAL:
                switch(config.orientation) {
                    case Configuration.ORIENTATION_PORTRAIT:
                        picker.setCalendarViewShown(true);
                        picker.setSpinnersShown(false);
                        break;
                    case Configuration.ORIENTATION_LANDSCAPE:
                        picker.setCalendarViewShown(true);
                        break;
                }
                break;
            default:
                picker.setCalendarViewShown(true);
                break;
        }
    }
    return dialog;
}
Also used : Configuration(android.content.res.Configuration) DatePickerDialog(android.app.DatePickerDialog) Bundle(android.os.Bundle) Calendar(java.util.Calendar) DatePicker(android.widget.DatePicker)

Aggregations

DatePickerDialog (android.app.DatePickerDialog)22 Calendar (java.util.Calendar)14 DatePicker (android.widget.DatePicker)11 TimePickerDialog (android.app.TimePickerDialog)5 View (android.view.View)5 DialogInterface (android.content.DialogInterface)4 Intent (android.content.Intent)3 AdapterView (android.widget.AdapterView)3 TextView (android.widget.TextView)3 SimpleDateFormat (java.text.SimpleDateFormat)3 AlertDialog (android.app.AlertDialog)2 OnDateSetListener (android.app.DatePickerDialog.OnDateSetListener)2 ImageView (android.widget.ImageView)2 Toast (android.widget.Toast)2 Description (com.github.mikephil.charting.components.Description)2 Entry (com.github.mikephil.charting.data.Entry)2 PieEntry (com.github.mikephil.charting.data.PieEntry)2 Highlight (com.github.mikephil.charting.highlight.Highlight)2 OnChartValueSelectedListener (com.github.mikephil.charting.listener.OnChartValueSelectedListener)2 Date (java.util.Date)2