use of android.widget.DatePicker 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);
}
use of android.widget.DatePicker in project pictureapp by EyeSeeTea.
the class NewReceiptBalanceFragment method initViews.
private void initViews(View view) {
date = (TextView) view.findViewById(R.id.new_receipt_balance_date);
rdt = (EditText) view.findViewById(R.id.new_receipt_balance_rdt);
act6 = (EditText) view.findViewById(R.id.new_receipt_balance_act6);
act12 = (EditText) view.findViewById(R.id.new_receipt_balance_act12);
act18 = (EditText) view.findViewById(R.id.new_receipt_balance_act18);
act24 = (EditText) view.findViewById(R.id.new_receipt_balance_act24);
pq = (EditText) view.findViewById(R.id.new_receipt_balance_pq);
cq = (EditText) view.findViewById(R.id.new_receipt_balance_cq);
putTodayDate();
view.findViewById(R.id.new_receipt_balance_back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
backPressed();
}
});
view.findViewById(R.id.new_receipt_balance_submit).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
submitPressed();
}
});
final DatePickerFragment datePickerFragment = new DatePickerFragment();
datePickerFragment.setOnDateSetListener(new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
NumberFormat formatter = new DecimalFormat("00");
date.setText(year + "/" + formatter.format(monthOfYear) + "/" + formatter.format(dayOfMonth));
}
});
date.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
datePickerFragment.show(getFragmentManager(), TAG);
}
});
}
use of android.widget.DatePicker in project AdMoney by ErnestoGonAr.
the class Reporte_Egresos method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
initData();
} catch (NullPointerException e) {
Toast toast = Toast.makeText(this, "No hay Egresos", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
return;
}
setContentView(R.layout.activity_reporte__egresos);
pieChart = (PieChart) findViewById(R.id.grafico_egresos);
pieChart.setRotationEnabled(true);
pieChart.setHoleRadius(30f);
pieChart.setCenterTextSize(10);
pieChart.setEntryLabelTextSize(4);
pieChart.setTransparentCircleAlpha(0);
Description d = pieChart.getDescription();
d.setText("");
pieChart.setDescription(d);
pieChart.getLegend().setOrientation(Legend.LegendOrientation.VERTICAL);
pieChart.getLegend().setTextSize(12);
pieChart.getLegend().setPosition(Legend.LegendPosition.LEFT_OF_CHART);
if (xData.length == 0)
return;
addData();
pieChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
@Override
public void onValueSelected(Entry e, Highlight h) {
Log.d(TAG, "onValueSelected: Value selected from chart");
Log.d(TAG, e.toString());
Log.d(TAG, h.toString());
int pos1 = e.toString().indexOf("Entry, x: 0.0 y: ");
String res = e.toString().substring(pos1 + 17);
for (int i = 0; i < yData.length; i++) {
if (yData[i] == Float.parseFloat(res)) {
pos1 = i;
break;
}
}
String categoria = xData[pos1];
Toast.makeText(Reporte_Egresos.this, "Ha gastado $" + res + " en " + categoria, Toast.LENGTH_LONG).show();
}
@Override
public void onNothingSelected() {
}
});
spinner = (Spinner) findViewById(R.id.spinner_r_egresos);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
calendar.setText("Selecciona una fecha");
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
año = 2017;
mes = 5;
diad = 17;
calendar = (EditText) findViewById(R.id.fecha_r_egresos);
calendar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
//To show current date in the datepicker
final Calendar mcurrentDate = Calendar.getInstance();
mYear = mcurrentDate.get(Calendar.YEAR);
mMonth = mcurrentDate.get(Calendar.MONTH);
mDay = mcurrentDate.get(Calendar.DAY_OF_MONTH);
DatePickerDialog mDatePicker = new DatePickerDialog(Reporte_Egresos.this, new DatePickerDialog.OnDateSetListener() {
public void onDateSet(DatePicker datepicker, int selectedyear, int selectedmonth, int selectedday) {
// TODO Auto-generated method stub
año = selectedyear;
mes = selectedmonth + 1;
diad = selectedday;
calendar.setText(selectedyear + "-" + (selectedmonth + 1) + "-" + selectedday);
}
}, mYear, mMonth, mDay);
mDatePicker.setTitle("Selecciona fecha");
mDatePicker.show();
}
});
consultar = (Button) findViewById(R.id.consultar_e);
consultar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (calendar.getText().toString().equals("Selecciona una fecha")) {
calendar.requestFocus();
calendar.callOnClick();
return;
}
String[][] data;
switch(spinner.getSelectedItemPosition()) {
case 1:
String dia = calendar.getText().toString();
data = bd.obtenerEgresos(diad + "", mes + "", año + "");
if (data == null) {
Toast toast = Toast.makeText(getApplicationContext(), "No hay registros para esta fecha", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
pieChart.setVisibility(View.INVISIBLE);
break;
}
pieChart.clear();
initData(data);
addData();
pieChart.setVisibility(View.VISIBLE);
break;
case 2:
data = bd.obtenerEgresos(mes + "", año + "");
if (data == null) {
Toast toast = Toast.makeText(getApplicationContext(), "No hay registros para esta fecha", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
pieChart.setVisibility(View.INVISIBLE);
break;
}
pieChart.clear();
initData(data);
addData();
pieChart.setVisibility(View.VISIBLE);
break;
case 3:
data = bd.obtenerEgresos(año + "");
if (data == null) {
Toast toast = Toast.makeText(getApplicationContext(), "No hay registros para esta fecha", Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
toast.show();
pieChart.setVisibility(View.INVISIBLE);
break;
}
pieChart.clear();
initData(data);
addData();
pieChart.setVisibility(View.VISIBLE);
break;
default:
pieChart.clear();
initData();
addData();
pieChart.setVisibility(View.VISIBLE);
break;
}
}
});
}
use of android.widget.DatePicker 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);
}
}
});
}
use of android.widget.DatePicker 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;
}
Aggregations