Search in sources :

Example 21 with RecentsTaskLoadPlan

use of com.android.systemui.recents.model.RecentsTaskLoadPlan in project platform_frameworks_base by android.

the class RecentsTvActivity method updateRecentsTasks.

private void updateRecentsTasks() {
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan plan = RecentsImpl.consumeInstanceLoadPlan();
    if (plan == null) {
        plan = loader.createLoadPlan(this);
    }
    RecentsConfiguration config = Recents.getConfiguration();
    RecentsActivityLaunchState launchState = config.getLaunchState();
    if (!plan.hasTasks()) {
        loader.preloadTasks(plan, -1, !launchState.launchedFromHome);
    }
    int numVisibleTasks = TaskCardView.getNumberOfVisibleTasks(getApplicationContext());
    mLaunchedFromHome = launchState.launchedFromHome;
    TaskStack stack = plan.getTaskStack();
    RecentsTaskLoadPlan.Options loadOpts = new RecentsTaskLoadPlan.Options();
    loadOpts.runningTaskId = launchState.launchedToTaskId;
    loadOpts.numVisibleTasks = numVisibleTasks;
    loadOpts.numVisibleTaskThumbnails = numVisibleTasks;
    loader.loadTasks(this, plan, loadOpts);
    List stackTasks = stack.getStackTasks();
    Collections.reverse(stackTasks);
    if (mTaskStackViewAdapter == null) {
        mTaskStackViewAdapter = new TaskStackHorizontalViewAdapter(stackTasks);
        mTaskStackHorizontalGridView = mRecentsView.setTaskStackViewAdapter(mTaskStackViewAdapter);
        mHomeRecentsEnterExitAnimationHolder = new HomeRecentsEnterExitAnimationHolder(getApplicationContext(), mTaskStackHorizontalGridView);
    } else {
        mTaskStackViewAdapter.setNewStackTasks(stackTasks);
    }
    mRecentsView.init(stack);
    if (launchState.launchedToTaskId != -1) {
        ArrayList<Task> tasks = stack.getStackTasks();
        int taskCount = tasks.size();
        for (int i = 0; i < taskCount; i++) {
            Task t = tasks.get(i);
            if (t.key.id == launchState.launchedToTaskId) {
                t.isLaunchTarget = true;
                break;
            }
        }
    }
}
Also used : ActivityOptions(android.app.ActivityOptions) Task(com.android.systemui.recents.model.Task) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) HomeRecentsEnterExitAnimationHolder(com.android.systemui.recents.tv.animations.HomeRecentsEnterExitAnimationHolder) TaskStack(com.android.systemui.recents.model.TaskStack) RecentsActivityLaunchState(com.android.systemui.recents.RecentsActivityLaunchState) RecentsConfiguration(com.android.systemui.recents.RecentsConfiguration) TaskStackHorizontalViewAdapter(com.android.systemui.recents.tv.views.TaskStackHorizontalViewAdapter) ArrayList(java.util.ArrayList) List(java.util.List)

Example 22 with RecentsTaskLoadPlan

use of com.android.systemui.recents.model.RecentsTaskLoadPlan in project android_frameworks_base by AOSPA.

the class RecentsImpl method showRelativeAffiliatedTask.

/**
     * Transitions to the next affiliated task.
     */
public void showRelativeAffiliatedTask(boolean showNextTask) {
    SystemServicesProxy ssp = Recents.getSystemServices();
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
    loader.preloadTasks(plan, -1, false);
    TaskStack focusedStack = plan.getTaskStack();
    // Return early if there are no tasks in the focused stack
    if (focusedStack == null || focusedStack.getTaskCount() == 0)
        return;
    // Return early if there is no running task (can't determine affiliated tasks in this case)
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    if (runningTask == null)
        return;
    // Return early if the running task is in the home stack (optimization)
    if (SystemServicesProxy.isHomeStack(runningTask.stackId))
        return;
    // Find the task in the recents list
    ArrayList<Task> tasks = focusedStack.getStackTasks();
    Task toTask = null;
    ActivityOptions launchOpts = null;
    int taskCount = tasks.size();
    int numAffiliatedTasks = 0;
    for (int i = 0; i < taskCount; i++) {
        Task task = tasks.get(i);
        if (task.key.id == runningTask.id) {
            TaskGrouping group = task.group;
            Task.TaskKey toTaskKey;
            if (showNextTask) {
                toTaskKey = group.getNextTaskInGroup(task);
                launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_next_affiliated_task_target, R.anim.recents_launch_next_affiliated_task_source);
            } else {
                toTaskKey = group.getPrevTaskInGroup(task);
                launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_target, R.anim.recents_launch_prev_affiliated_task_source);
            }
            if (toTaskKey != null) {
                toTask = focusedStack.findTaskWithId(toTaskKey.id);
            }
            numAffiliatedTasks = group.getTaskCount();
            break;
        }
    }
    // Return early if there is no next task
    if (toTask == null) {
        if (numAffiliatedTasks > 1) {
            if (showNextTask) {
                ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext, R.anim.recents_launch_next_affiliated_task_bounce));
            } else {
                ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_bounce));
            }
        }
        return;
    }
    // Keep track of actually launched affiliated tasks
    MetricsLogger.count(mContext, "overview_affiliated_task_launch", 1);
    // Launch the task
    ssp.startActivityFromRecents(mContext, toTask.key, toTask.title, launchOpts);
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) TaskGrouping(com.android.systemui.recents.model.TaskGrouping) ActivityManager(android.app.ActivityManager) ActivityOptions(android.app.ActivityOptions)

Example 23 with RecentsTaskLoadPlan

use of com.android.systemui.recents.model.RecentsTaskLoadPlan in project android_frameworks_base by AOSPA.

the class RecentsImpl method showNextTask.

/**
     * Transitions to the next recent task in the stack.
     */
public void showNextTask() {
    SystemServicesProxy ssp = Recents.getSystemServices();
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
    loader.preloadTasks(plan, -1, false);
    TaskStack focusedStack = plan.getTaskStack();
    // Return early if there are no tasks in the focused stack
    if (focusedStack == null || focusedStack.getTaskCount() == 0)
        return;
    // Return early if there is no running task
    ActivityManager.RunningTaskInfo runningTask = ssp.getRunningTask();
    if (runningTask == null)
        return;
    // Find the task in the recents list
    boolean isRunningTaskInHomeStack = SystemServicesProxy.isHomeStack(runningTask.stackId);
    ArrayList<Task> tasks = focusedStack.getStackTasks();
    Task toTask = null;
    ActivityOptions launchOpts = null;
    int taskCount = tasks.size();
    for (int i = taskCount - 1; i >= 1; i--) {
        Task task = tasks.get(i);
        if (isRunningTaskInHomeStack) {
            toTask = tasks.get(i - 1);
            launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_next_affiliated_task_target, R.anim.recents_fast_toggle_app_home_exit);
            break;
        } else if (task.key.id == runningTask.id) {
            toTask = tasks.get(i - 1);
            launchOpts = ActivityOptions.makeCustomAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_target, R.anim.recents_launch_prev_affiliated_task_source);
            break;
        }
    }
    // Return early if there is no next task
    if (toTask == null) {
        ssp.startInPlaceAnimationOnFrontMostApplication(ActivityOptions.makeCustomInPlaceAnimation(mContext, R.anim.recents_launch_prev_affiliated_task_bounce));
        return;
    }
    // Launch the task
    ssp.startActivityFromRecents(mContext, toTask.key, toTask.title, launchOpts);
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) TaskStack(com.android.systemui.recents.model.TaskStack) Task(com.android.systemui.recents.model.Task) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader) ActivityManager(android.app.ActivityManager) ActivityOptions(android.app.ActivityOptions)

Example 24 with RecentsTaskLoadPlan

use of com.android.systemui.recents.model.RecentsTaskLoadPlan in project android_frameworks_base by AOSPA.

the class RecentsImpl method consumeInstanceLoadPlan.

/**
     * Returns the preloaded load plan and invalidates it.
     */
public static RecentsTaskLoadPlan consumeInstanceLoadPlan() {
    RecentsTaskLoadPlan plan = sInstanceLoadPlan;
    sInstanceLoadPlan = null;
    return plan;
}
Also used : RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan)

Example 25 with RecentsTaskLoadPlan

use of com.android.systemui.recents.model.RecentsTaskLoadPlan in project android_frameworks_base by AOSPA.

the class RecentsImpl method onBootCompleted.

public void onBootCompleted() {
    // When we start, preload the data associated with the previous recent tasks.
    // We can use a new plan since the caches will be the same.
    RecentsTaskLoader loader = Recents.getTaskLoader();
    RecentsTaskLoadPlan plan = loader.createLoadPlan(mContext);
    loader.preloadTasks(plan, -1, false);
    RecentsTaskLoadPlan.Options launchOpts = new RecentsTaskLoadPlan.Options();
    launchOpts.numVisibleTasks = loader.getIconCacheSize();
    launchOpts.numVisibleTaskThumbnails = loader.getThumbnailCacheSize();
    launchOpts.onlyLoadForCache = true;
    loader.loadTasks(mContext, plan, launchOpts);
}
Also used : ActivityOptions(android.app.ActivityOptions) RecentsTaskLoadPlan(com.android.systemui.recents.model.RecentsTaskLoadPlan) RecentsTaskLoader(com.android.systemui.recents.model.RecentsTaskLoader)

Aggregations

RecentsTaskLoadPlan (com.android.systemui.recents.model.RecentsTaskLoadPlan)35 ActivityOptions (android.app.ActivityOptions)30 RecentsTaskLoader (com.android.systemui.recents.model.RecentsTaskLoader)30 TaskStack (com.android.systemui.recents.model.TaskStack)25 Task (com.android.systemui.recents.model.Task)20 ActivityManager (android.app.ActivityManager)10 SystemServicesProxy (com.android.systemui.recents.misc.SystemServicesProxy)10 RecentsActivityLaunchState (com.android.systemui.recents.RecentsActivityLaunchState)5 RecentsConfiguration (com.android.systemui.recents.RecentsConfiguration)5 ConfigurationChangedEvent (com.android.systemui.recents.events.activity.ConfigurationChangedEvent)5 EnterRecentsWindowAnimationCompletedEvent (com.android.systemui.recents.events.activity.EnterRecentsWindowAnimationCompletedEvent)5 MultiWindowStateChangedEvent (com.android.systemui.recents.events.activity.MultiWindowStateChangedEvent)5 TaskGrouping (com.android.systemui.recents.model.TaskGrouping)5 HomeRecentsEnterExitAnimationHolder (com.android.systemui.recents.tv.animations.HomeRecentsEnterExitAnimationHolder)5 TaskStackHorizontalViewAdapter (com.android.systemui.recents.tv.views.TaskStackHorizontalViewAdapter)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5 AsyncTask (android.os.AsyncTask)2