Example usage for android.text.format Time after

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

Introduction

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

Prototype

public boolean after(Time that) 

Source Link

Document

Returns true if the time represented by this Time object occurs after the given time.

Usage

From source file:it.sasabz.android.sasabus.fragments.OrarioFragment.java

/**
 * This method gets the next departure time and returns the
 * index of this element//  ww w  .  j av  a2 s .  co  m
 * @param c is the cursor to the list_view
 * @return the index of the next departure time
 */
private int getNextTimePosition(Vector<Passaggio> list) {
    int count = list.size();
    if (count == 0) {
        return -1;
    } else if (count == 1) {
        return 0;
    } else {
        int i = 0;
        boolean found = false;
        while (i <= count - 2 && !found) {
            Time currentTime = new Time();
            Time sasaTime = new Time();
            Time sasaTimeNext = new Time();
            currentTime.setToNow();
            sasaTime = list.get(i).getOrario();
            sasaTimeNext = list.get(i + 1).getOrario();

            if (sasaTime.after(currentTime) || sasaTime.equals(currentTime) || sasaTime.before(currentTime)
                    && (sasaTimeNext.equals(currentTime) || sasaTimeNext.after(currentTime))) {
                found = true;
            } else {
                i++;
            }
        }
        return i;
    }
}

From source file:it.sasabz.android.sasabus.fragments.WayFragment.java

/**
 * This method gets the next departure time and returns the
 * index of this element/*from ww  w  .  j  av  a2s .  com*/
 * @param c is the cursor to the list_view
 * @return the index of the next departure time
 */
private int getNextTimePosition(Vector<Passaggio> list) {
    int count = 0;
    if (list != null) {
        count = list.size();
    }
    if (count == 0) {
        return -1;
    } else if (count == 1) {
        return 0;
    } else {
        int i = 0;
        boolean found = false;
        while (i <= count - 2 && !found) {
            Time currentTime = new Time();
            Time sasaTime = new Time();
            Time sasaTimeNext = new Time();
            currentTime.setToNow();
            sasaTime = list.get(i).getOrario();
            sasaTimeNext = list.get(i + 1).getOrario();

            if (sasaTime.after(currentTime) || sasaTime.equals(currentTime) || sasaTime.before(currentTime)
                    && (sasaTimeNext.equals(currentTime) || sasaTimeNext.after(currentTime))) {
                found = true;
            } else {
                i++;
            }
        }
        return i;
    }
}

From source file:org.cinedroid.tasks.impl.RetrievePerformancesTask.java

/**
 * Removes any times which have passed from the list
 * /*from w  ww .  j  av  a2 s.  c  o  m*/
 * @param results
 */
private void filterPastDates(final FilmDate filmDate) {
    Time currentTime = new Time();
    currentTime.setToNow();

    Time performanceDate = new Time();
    String date = filmDate.getDate();
    performanceDate.parse(date);

    // Check if the performance date is before the current time. This will only be true in the situation that the filmDate represents
    // the current day, as the cineworld api does not return dates which have passed. If the object is the current date, the film
    // performances need filtering.
    if (currentTime.after(performanceDate)) {
        for (Iterator<FilmPerformance> i = filmDate.getPerformances().iterator(); i.hasNext();) {
            String time = i.next().getTime().replace(":", ""); // Get the time with the : removed.
            performanceDate.parse(String.format("%sT%s00", date, time));
            Log.d(TAG, String.format("Checking %s", performanceDate.format("%d %b %H:%M")));
            if (currentTime.after(performanceDate)) {
                Log.d(TAG, String.format("Removed %s", performanceDate.format("%d %b %H:%M")));
                i.remove();
            }
        }
    }
    Log.d(TAG, String.format("Current Time %s", currentTime.toString()));
}

From source file:ru.otdelit.astrid.opencrx.sync.OpencrxSyncProvider.java

private boolean isTaskChangedAfter(OpencrxTaskContainer task, OpencrxTaskContainer task2) {
    Time modTime = new Time();
    modTime.set(task.task.getValue(Task.MODIFICATION_DATE));

    Time time = new Time();
    time.set(task2.task.getValue(Task.MODIFICATION_DATE));

    return modTime.after(time);
}