@Override public void onDateSet(DatePickerDialog view, int year, int monthOfYear, int dayOfMonth) { DateTime date = new DateTime().withDate(year, monthOfYear + 1, dayOfMonth); DateTimeFormatter dateFormatter = DateTimeFormat.forPattern("E, MMMM d"); inviteDate.setText(dateFormatter.print(date)); creator.getInvite().date = date.getMillis(); }
@Override public void onTimeSet(RadialPickerLayout view, int hourOfDay, int minute) { DateTime time = new DateTime().withHourOfDay(hourOfDay).withMinuteOfHour(minute); DateTimeFormatter timeFormatter = DateTimeFormat.forPattern("h:mm a"); inviteTime.setText(timeFormatter.print(time)); creator.getInvite().time = time.getMillis(); }
private boolean validate() { if (creator.getInvite() == null) { return false; } else { if (creator.getInvite().date == 0l) { String message = ""; if (creator.getInvite().time == 0l || TextUtils.isEmpty(inviteTitle.getText())) { message = getString(R.string.all_fields_error); } else { message = String.format(getString(R.string.one_field_error), "date"); } Snackbar.make(inviteDetailsCard, message, Snackbar.LENGTH_LONG).show(); return false; } if (creator.getInvite().time == 0l) { String message = ""; if (creator.getInvite().date == 0l || TextUtils.isEmpty(inviteTitle.getText())) { message = getString(R.string.all_fields_error); } else { message = String.format(getString(R.string.one_field_error), "time"); } Snackbar.make(inviteDetailsCard, message, Snackbar.LENGTH_LONG).show(); return false; } if (TextUtils.isEmpty(inviteTitle.getText())) { String message = ""; if (creator.getInvite().time == 0l || creator.getInvite().date == 0l) { message = getString(R.string.all_fields_error); } else { message = String.format(getString(R.string.one_field_error), "title"); } Snackbar.make(inviteDetailsCard, message, Snackbar.LENGTH_LONG).show(); return false; } DateTime time = new DateTime().withMillis(creator.getInvite().time); DateTime date = new DateTime().withMillis(creator.getInvite().date); DateTime when = new DateTime() .withYear(date.getYear()) .withMonthOfYear(date.getMonthOfYear()) .withDayOfMonth(date.getDayOfMonth()) .withHourOfDay(time.getHourOfDay()) .withMinuteOfHour(time.getMinuteOfHour()); if (when.isBeforeNow()) { Snackbar.make(inviteDetailsCard, getString(R.string.wrong_datetime), Snackbar.LENGTH_LONG) .show(); return false; } } return true; }
@Override public void render() { if (creator.getInvite() != null) { if (creator.getInvite().location != null && !TextUtils.isEmpty(creator.getInvite().location.address)) { inviteLocation.setText(creator.getInvite().getFormattedAddress()); } else { inviteLocation.setText(""); } if (!TextUtils.isEmpty(creator.getInvite().title)) { inviteTitle.setText(creator.getInvite().title); } else { inviteTitle.setText(""); } if (creator.getInvite().reminder != -1) { reminderSpinner.setSelection(reminderAdapter.getPosition(creator.getInvite().reminder)); } else { reminderSpinner.setSelection(0); } if (creator.getInvite().date != 0l) { inviteDate.setText(creator.getInvite().getFormattedDate()); } else { inviteDate.setText(getString(R.string.enter_date)); } if (creator.getInvite().time != 0l) { inviteTime.setText(creator.getInvite().getFormattedTime()); } else { inviteTime.setText(getString(R.string.enter_time)); } } else { // inviteDate.setText(getString(R.string.enter_date)); // inviteTime.setText(getString(R.string.enter_time)); // reminderSpinner.setSelection(0); // inviteLocation.setText(""); // inviteTitle.setText(""); getActivity().finish(); } }