use of com.android.systemui.recents.model.Task in project android_frameworks_base by DirtyUnicorns.
the class TaskStackHorizontalViewAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
Task task = mTaskList.get(position);
// Retrives from caches, loading only if necessary
Recents.getTaskLoader().loadTaskData(task);
holder.init(task);
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by DirtyUnicorns.
the class TaskStackView method setRelativeFocusedTask.
/**
* Sets the focused task relative to the currently focused task.
*
* @param forward whether to go to the next task in the stack (along the curve) or the previous
* @param stackTasksOnly if set, will ensure that the traversal only goes along stack tasks, and
* if the currently focused task is not a stack task, will set the focus
* to the first visible stack task
* @param animated determines whether to actually draw the highlight along with the change in
* focus.
* @param cancelWindowAnimations if set, will attempt to cancel window animations if a scroll
* happens.
* @param timerIndicatorDuration the duration to initialize the auto-advance timer indicator
*/
public void setRelativeFocusedTask(boolean forward, boolean stackTasksOnly, boolean animated, boolean cancelWindowAnimations, int timerIndicatorDuration) {
Task focusedTask = getFocusedTask();
int newIndex = mStack.indexOfStackTask(focusedTask);
if (focusedTask != null) {
if (stackTasksOnly) {
List<Task> tasks = mStack.getStackTasks();
if (focusedTask.isFreeformTask()) {
// Try and focus the front most stack task
TaskView tv = getFrontMostTaskView(stackTasksOnly);
if (tv != null) {
newIndex = mStack.indexOfStackTask(tv.getTask());
}
} else {
// Try the next task if it is a stack task
int tmpNewIndex = newIndex + (forward ? -1 : 1);
if (0 <= tmpNewIndex && tmpNewIndex < tasks.size()) {
Task t = tasks.get(tmpNewIndex);
if (!t.isFreeformTask()) {
newIndex = tmpNewIndex;
}
}
}
} else {
// No restrictions, lets just move to the new task (looping forward/backwards if
// necessary)
int taskCount = mStack.getTaskCount();
newIndex = (newIndex + (forward ? -1 : 1) + taskCount) % taskCount;
}
} else {
// We don't have a focused task
float stackScroll = mStackScroller.getStackScroll();
ArrayList<Task> tasks = mStack.getStackTasks();
int taskCount = tasks.size();
if (useGridLayout()) {
// For the grid layout, we directly set focus to the most recently used task
// no matter we're moving forwards or backwards.
newIndex = taskCount - 1;
} else {
// stack scroll.
if (forward) {
// Walk backwards and focus the next task smaller than the current stack scroll
for (newIndex = taskCount - 1; newIndex >= 0; newIndex--) {
float taskP = mLayoutAlgorithm.getStackScrollForTask(tasks.get(newIndex));
if (Float.compare(taskP, stackScroll) <= 0) {
break;
}
}
} else {
// Walk forwards and focus the next task larger than the current stack scroll
for (newIndex = 0; newIndex < taskCount; newIndex++) {
float taskP = mLayoutAlgorithm.getStackScrollForTask(tasks.get(newIndex));
if (Float.compare(taskP, stackScroll) >= 0) {
break;
}
}
}
}
}
if (newIndex != -1) {
boolean willScroll = setFocusedTask(newIndex, true, /* scrollToTask */
true, /* requestViewFocus */
timerIndicatorDuration);
if (willScroll && cancelWindowAnimations) {
// As we iterate to the next/previous task, cancel any current/lagging window
// transition animations
EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(null));
}
}
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by DirtyUnicorns.
the class TaskStackView method onBusEvent.
public final void onBusEvent(final DismissAllTaskViewsEvent event) {
// Keep track of the tasks which will have their data removed
ArrayList<Task> tasks = new ArrayList<>(mStack.getStackTasks());
ArrayList<TaskView> deletedTasks = new ArrayList<>();
ArrayList<TaskView> taskViews = new ArrayList<>(getTaskViews());
for (TaskView t : taskViews) {
if (Recents.sLockedTasks.contains(t.getTask())) {
deletedTasks.add(t);
}
}
taskViews.removeAll(deletedTasks);
mAnimationHelper.startDeleteAllTasksAnimation(taskViews, useGridLayout(), event.getAnimationTrigger());
event.addPostAnimationCallback(new Runnable() {
@Override
public void run() {
// Announce for accessibility
announceForAccessibility(getContext().getString(R.string.accessibility_recents_all_items_dismissed));
// Remove all tasks and delete the task data for all tasks
mStack.removeAllTasks();
for (int i = tasks.size() - 1; i >= 0; i--) {
Task t = tasks.get(i);
if (Recents.sLockedTasks.contains(t))
continue;
EventBus.getDefault().send(new DeleteTaskDataEvent(t));
}
MetricsLogger.action(getContext(), MetricsEvent.OVERVIEW_DISMISS_ALL);
}
});
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by DirtyUnicorns.
the class TaskStackView method onReturnViewToPool.
@Override
public void onReturnViewToPool(TaskView tv) {
final Task task = tv.getTask();
// Unbind the task from the task view
unbindTaskView(tv, task);
// Reset the view properties and view state
tv.clearAccessibilityFocus();
tv.resetViewProperties();
tv.setFocusedState(false, false);
tv.setClipViewInStack(false);
if (mScreenPinningEnabled) {
tv.hideActionButton(false, /* fadeOut */
0, /* duration */
false, /* scaleDown */
null);
}
// Detach the view from the hierarchy
detachViewFromParent(tv);
// Update the task views list after removing the task view
updateTaskViewsList();
}
use of com.android.systemui.recents.model.Task in project android_frameworks_base by DirtyUnicorns.
the class TaskStackView method findTaskViewInsertIndex.
/**
* Returns the insert index for the task in the current set of task views. If the given task
* is already in the task view list, then this method returns the insert index assuming it
* is first removed at the previous index.
*
* @param task the task we are finding the index for
* @param taskIndex the index of the task in the stack
*/
private int findTaskViewInsertIndex(Task task, int taskIndex) {
if (taskIndex != -1) {
List<TaskView> taskViews = getTaskViews();
boolean foundTaskView = false;
int taskViewCount = taskViews.size();
for (int i = 0; i < taskViewCount; i++) {
Task tvTask = taskViews.get(i).getTask();
if (tvTask == task) {
foundTaskView = true;
} else if (taskIndex < mStack.indexOfStackTask(tvTask)) {
if (foundTaskView) {
return i - 1;
} else {
return i;
}
}
}
}
return -1;
}
Aggregations