示例#1
0
    @Override
    public int compare(Task t1, Task t2) {
      double o1 = t1.getOrder();
      double o2 = t2.getOrder();
      if (o1 <= 0) {
        return 1;
      }

      if (o2 <= 0) {
        return -1;
      }

      if (o1 > o2) {
        return 1;
      }

      if (o1 < o2) {
        return -1;
      }

      return 0;
    }
示例#2
0
  public List<Task> getTaskList() {
    // SortedSet<Task> tasks = new TreeSet<Task>(tc);
    List<Task> tasks = new ArrayList<Task>();
    Cursor lastWeekUpdatedTasks = fetchTask(WEEK);
    while (!lastWeekUpdatedTasks.isAfterLast()) {
      lastWeekUpdatedTasks.moveToNext();
      Task t = new Task(lastWeekUpdatedTasks.getString(1));
      t.setId(lastWeekUpdatedTasks.getLong(0));
      t.setLastTimeExecuted(lastWeekUpdatedTasks.getLong(2));

      int[] frequencyAndTimeSum = getNumAndDurationSumOfSessionsForTaskInRange(t.getId(), WEEK);

      t.setFrequency(frequencyAndTimeSum[0]);
      t.setTotalDuration(frequencyAndTimeSum[1]);
      t.setOrder(t.getFrequency() * t.getTotalDuration());

      tasks.add(t);
    }
    Collections.sort(tasks, tc);
    return tasks;
  }