Example usage for android.text.format Time clear

List of usage examples for android.text.format Time clear

Introduction

In this page you can find the example usage for android.text.format Time clear.

Prototype

public void clear(String timezoneId) 

Source Link

Document

Clears all values, setting the timezone to the given timezone.

Usage

From source file:com.granita.tasks.groupings.BaseTaskViewDescriptor.java

protected void setDueDate(TextView view, ImageView dueIcon, Time dueDate, boolean isClosed) {
    if (view != null && dueDate != null) {
        Time now = mNow;
        if (now == null) {
            now = mNow = new Time();
        }//from  w w  w  .j a  va2  s.  c o m
        if (!now.timezone.equals(TimeZone.getDefault().getID())) {
            now.clear(TimeZone.getDefault().getID());
        }

        if (Math.abs(now.toMillis(false) - System.currentTimeMillis()) > 5000) {
            now.setToNow();
            now.normalize(true);
        }

        dueDate.normalize(true);

        view.setText(new DateFormatter(view.getContext()).format(dueDate, now, DateFormatContext.LIST_VIEW));
        if (dueIcon != null) {
            dueIcon.setVisibility(View.VISIBLE);
        }

        // highlight overdue dates & times, handle allDay tasks separately
        if ((!dueDate.allDay && dueDate.before(now) || dueDate.allDay
                && (dueDate.year < now.year || dueDate.yearDay <= now.yearDay && dueDate.year == now.year))
                && !isClosed) {
            view.setTextAppearance(view.getContext(), R.style.task_list_overdue_text);
        } else {
            view.setTextAppearance(view.getContext(), R.style.task_list_due_text);
        }
    } else if (view != null) {
        view.setText("");
        if (dueIcon != null) {
            dueIcon.setVisibility(View.GONE);
        }
    }
}