void save() { checkEditViewSet(); if (bill == null) bill = new Bill(); bill = editView.fillBill(bill); bill.setInitDate(initDate); bill.setEndDate(endDate); OperationResult result = repository.save(bill); if (result.isValid()) { editView.finishView(); } else { for (ValidationError validationError : result.getErrors()) editView.showError(validationError); } }
void onEndDate(Context ctx) { checkEditViewSet(); DateTime time = initDate; if (time == null) time = DateTime.now(); new DatePickerDialog( ctx, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { if (endDate == null) endDate = DateTime.now(); endDate = endDate .withYear(year) .withMonthOfYear(monthOfYear + 1) .withDayOfMonth(dayOfMonth); editView.onEndDateChanged(endDate); } }, time.getYear(), time.getMonthOfYear() - 1, time.getDayOfMonth()) .show(); }