Methods Summary |
---|
void | addTask(Task t)Adds a new task to this group.
mTaskKeys.add(t.key);
if (t.key.lastActiveTime > latestActiveTimeInGroup) {
latestActiveTimeInGroup = t.key.lastActiveTime;
}
t.setGroup(this);
updateTaskIndices();
|
public boolean | containsTask(Task t)Returns whether a task is in this grouping.
return mTaskKeyIndices.containsKey(t.key);
|
public Task.TaskKey | getNextTaskInGroup(Task t)Returns the key of the next task in the group.
int i = indexOf(t);
if ((i + 1) < getTaskCount()) {
return mTaskKeys.get(i + 1);
}
return null;
|
public Task.TaskKey | getPrevTaskInGroup(Task t)Returns the key of the previous task in the group.
int i = indexOf(t);
if ((i - 1) >= 0) {
return mTaskKeys.get(i - 1);
}
return null;
|
public int | getTaskCount()Returns the number of tasks in this group. return mTaskKeys.size();
|
public int | indexOf(Task t)Finds the index of a given task in a group.
return mTaskKeyIndices.get(t.key);
|
public boolean | isFrontMostTask(Task t)Gets the front task
return (t.key == mFrontMostTaskKey);
|
public boolean | isTaskAboveTask(Task t, Task below)Returns whether one task is above another in the group. If they are not in the same group,
this returns false.
return mTaskKeyIndices.containsKey(t.key) && mTaskKeyIndices.containsKey(below.key) &&
mTaskKeyIndices.get(t.key) > mTaskKeyIndices.get(below.key);
|
void | removeTask(Task t)Removes a task from this group.
mTaskKeys.remove(t.key);
latestActiveTimeInGroup = 0;
int taskCount = mTaskKeys.size();
for (int i = 0; i < taskCount; i++) {
long lastActiveTime = mTaskKeys.get(i).lastActiveTime;
if (lastActiveTime > latestActiveTimeInGroup) {
latestActiveTimeInGroup = lastActiveTime;
}
}
t.setGroup(null);
updateTaskIndices();
|
private void | updateTaskIndices()Updates the mapping of tasks to indices.
if (mTaskKeys.isEmpty()) {
mFrontMostTaskKey = null;
mTaskKeyIndices.clear();
return;
}
mFrontMostTaskKey = mTaskKeys.get(mTaskKeys.size() - 1);
mTaskKeyIndices.clear();
int taskCount = mTaskKeys.size();
for (int i = 0; i < taskCount; i++) {
Task.TaskKey k = mTaskKeys.get(i);
mTaskKeyIndices.put(k, i);
}
|