Search in sources :

Example 1 with TaskStatus

use of de.symeda.sormas.api.task.TaskStatus in project SORMAS-Project by hzi-braunschweig.

the class TextViewBindingAdapters method setDueTimeAgoValue.

@BindingAdapter(value = { "dueTimeAgoValue", "textColor", "valueFormat", "defaultValue" }, requireAll = false)
public static void setDueTimeAgoValue(TextView textField, Task task, int textColor, String valueFormat, String defaultValue) {
    String val = defaultValue;
    if (task == null || task.getDueDate() == null) {
        textField.setText(val);
    } else {
        // val = DateHelper.formatLocalShortDate(task.getDueDate());
        val = TimeAgo.using(textField.getContext()).with(task.getDueDate());
        if (valueFormat != null && valueFormat.trim() != "") {
            textField.setText(String.format(valueFormat, val));
        } else {
            textField.setText(val);
        }
        Integer dueDateColor = null;
        TaskStatus kkk = task.getTaskStatus();
        if (task.getDueDate().compareTo(new Date()) <= 0 && !TaskStatus.DONE.equals(task.getTaskStatus())) {
            dueDateColor = textField.getContext().getResources().getColor(R.color.watchOut);
            // textField.setTypeface(textField.getTypeface(), Typeface.BOLD);
            textField.setTextColor(dueDateColor);
        } else {
            // dueDateColor = textField.getContext().getResources().getColor();
            // textField.setTypeface(textField.getTypeface(), Typeface.NORMAL);
            textField.setTextColor(textColor);
        }
    }
}
Also used : TaskStatus(de.symeda.sormas.api.task.TaskStatus) Date(java.util.Date) BindingAdapter(androidx.databinding.BindingAdapter)

Aggregations

BindingAdapter (androidx.databinding.BindingAdapter)1 TaskStatus (de.symeda.sormas.api.task.TaskStatus)1 Date (java.util.Date)1