FileDocCategorySizeDatePackage
TaskGrouping.javaAPI DocAndroid 5.1 API3312Thu Mar 12 22:22:42 GMT 2015com.android.systemui.recents.model

TaskGrouping

public class TaskGrouping extends Object
Represents a grouping of tasks witihin a stack.

Fields Summary
int
affiliation
long
latestActiveTimeInGroup
Task.TaskKey
mFrontMostTaskKey
ArrayList
mTaskKeys
HashMap
mTaskKeyIndices
Constructors Summary
public TaskGrouping(int affiliation)
Creates a group with a specified affiliation.


            
       
        this.affiliation = affiliation;
    
Methods Summary
voidaddTask(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 booleancontainsTask(Task t)
Returns whether a task is in this grouping.

        return mTaskKeyIndices.containsKey(t.key);
    
public Task.TaskKeygetNextTaskInGroup(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.TaskKeygetPrevTaskInGroup(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 intgetTaskCount()
Returns the number of tasks in this group.

 return mTaskKeys.size(); 
public intindexOf(Task t)
Finds the index of a given task in a group.

        return mTaskKeyIndices.get(t.key);
    
public booleanisFrontMostTask(Task t)
Gets the front task

        return (t.key == mFrontMostTaskKey);
    
public booleanisTaskAboveTask(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);
    
voidremoveTask(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 voidupdateTaskIndices()
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);
        }