Search in sources :

Example 1 with ObservableField

use of android.databinding.ObservableField in project open-event-orga-app by fossasia.

the class DateBindings method bindDate.

@BindingAdapter("date")
public static void bindDate(Button button, ObservableField<String> date) {
    String format = DateUtils.FORMAT_DATE_COMPLETE;
    bindTemporal(button, date, format, zonedDateTime -> new DatePickerDialog(button.getContext(), (picker, year, month, dayOfMonth) -> setPickedDate(LocalDateTime.of(LocalDate.of(year, month + 1, dayOfMonth), zonedDateTime.toLocalTime()), button, format, date), zonedDateTime.getYear(), zonedDateTime.getMonthValue() - 1, zonedDateTime.getDayOfMonth()));
}
Also used : BindingAdapter(android.databinding.BindingAdapter) TimePickerDialog(android.app.TimePickerDialog) LocalTime(org.threeten.bp.LocalTime) LocalDate(org.threeten.bp.LocalDate) ZonedDateTime(org.threeten.bp.ZonedDateTime) Timber(timber.log.Timber) AlertDialog(android.app.AlertDialog) DatePickerDialog(android.app.DatePickerDialog) DateUtils(org.fossasia.openevent.app.utils.DateUtils) Function(org.fossasia.openevent.app.common.Function) LocalDateTime(org.threeten.bp.LocalDateTime) Button(android.widget.Button) DateTimeParseException(org.threeten.bp.format.DateTimeParseException) ObservableField(android.databinding.ObservableField) DatePickerDialog(android.app.DatePickerDialog) BindingAdapter(android.databinding.BindingAdapter)

Example 2 with ObservableField

use of android.databinding.ObservableField in project open-event-orga-app by fossasia.

the class DateBindings method bindTime.

@BindingAdapter("time")
public static void bindTime(Button button, ObservableField<String> time) {
    String format = DateUtils.FORMAT_24H;
    bindTemporal(button, time, format, zonedDateTime -> new TimePickerDialog(button.getContext(), (picker, hourOfDay, minute) -> setPickedDate(LocalDateTime.of(zonedDateTime.toLocalDate(), LocalTime.of(hourOfDay, minute)), button, format, time), zonedDateTime.getHour(), zonedDateTime.getMinute(), true));
}
Also used : BindingAdapter(android.databinding.BindingAdapter) TimePickerDialog(android.app.TimePickerDialog) LocalTime(org.threeten.bp.LocalTime) LocalDate(org.threeten.bp.LocalDate) ZonedDateTime(org.threeten.bp.ZonedDateTime) Timber(timber.log.Timber) AlertDialog(android.app.AlertDialog) DatePickerDialog(android.app.DatePickerDialog) DateUtils(org.fossasia.openevent.app.utils.DateUtils) Function(org.fossasia.openevent.app.common.Function) LocalDateTime(org.threeten.bp.LocalDateTime) Button(android.widget.Button) DateTimeParseException(org.threeten.bp.format.DateTimeParseException) ObservableField(android.databinding.ObservableField) TimePickerDialog(android.app.TimePickerDialog) BindingAdapter(android.databinding.BindingAdapter)

Aggregations

AlertDialog (android.app.AlertDialog)2 DatePickerDialog (android.app.DatePickerDialog)2 TimePickerDialog (android.app.TimePickerDialog)2 BindingAdapter (android.databinding.BindingAdapter)2 ObservableField (android.databinding.ObservableField)2 Button (android.widget.Button)2 Function (org.fossasia.openevent.app.common.Function)2 DateUtils (org.fossasia.openevent.app.utils.DateUtils)2 LocalDate (org.threeten.bp.LocalDate)2 LocalDateTime (org.threeten.bp.LocalDateTime)2 LocalTime (org.threeten.bp.LocalTime)2 ZonedDateTime (org.threeten.bp.ZonedDateTime)2 DateTimeParseException (org.threeten.bp.format.DateTimeParseException)2 Timber (timber.log.Timber)2