Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 89bb755a authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Ensuring that we unload all resources after a transition."

parents 5e6421bd 653b0d6a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@
    <integer name="heads_up_sensitivity_delay">700</integer>

    <!-- The duration in seconds to wait before the dismiss buttons are shown. -->
    <integer name="recents_task_bar_dismiss_delay_seconds">3</integer>
    <integer name="recents_task_bar_dismiss_delay_seconds">1</integer>
    <!-- The min animation duration for animating views that are currently visible. -->
    <integer name="recents_filter_animate_current_views_duration">250</integer>
    <!-- The min animation duration for animating views that are newly visible. -->
+12 −2
Original line number Diff line number Diff line
@@ -577,23 +577,33 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
    public void onEnterAnimationTriggered() {
        // Fade in the scrims
        if (mConfig.hasStatusBarScrim() && mConfig.shouldAnimateStatusBarScrim()) {
            mStatusBarScrimView.setVisibility(View.VISIBLE);
            mStatusBarScrimView.setTranslationY(-mStatusBarScrimView.getMeasuredHeight());
            mStatusBarScrimView.animate()
                    .translationY(0)
                    .setStartDelay(mConfig.taskBarEnterAnimDelay)
                    .setDuration(mConfig.navBarScrimEnterDuration)
                    .setInterpolator(mConfig.quintOutInterpolator)
                    .withStartAction(new Runnable() {
                        @Override
                        public void run() {
                            mStatusBarScrimView.setVisibility(View.VISIBLE);
                        }
                    })
                    .start();
        }
        if (mConfig.hasNavBarScrim() && mConfig.shouldAnimateNavBarScrim()) {
            mNavBarScrimView.setVisibility(View.VISIBLE);
            mNavBarScrimView.setTranslationY(mNavBarScrimView.getMeasuredHeight());
            mNavBarScrimView.animate()
                    .translationY(0)
                    .setStartDelay(mConfig.taskBarEnterAnimDelay)
                    .setDuration(mConfig.navBarScrimEnterDuration)
                    .setInterpolator(mConfig.quintOutInterpolator)
                    .withStartAction(new Runnable() {
                        @Override
                        public void run() {
                            mNavBarScrimView.setVisibility(View.VISIBLE);
                        }
                    })
                    .start();
        }
    }
+21 −8
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package com.android.systemui.recents;

import android.content.Context;

import java.util.ArrayList;

/**
 * A ref counted trigger that does some logic when the count is first incremented, or last
 * decremented.  Not thread safe as it's not currently needed.
@@ -26,8 +28,8 @@ public class ReferenceCountedTrigger {

    Context mContext;
    int mCount;
    Runnable mFirstIncRunnable;
    Runnable mLastDecRunnable;
    ArrayList<Runnable> mFirstIncRunnables = new ArrayList<Runnable>();
    ArrayList<Runnable> mLastDecRunnables = new ArrayList<Runnable>();
    Runnable mErrorRunnable;

    // Convenience runnables
@@ -47,15 +49,18 @@ public class ReferenceCountedTrigger {
    public ReferenceCountedTrigger(Context context, Runnable firstIncRunnable,
                                   Runnable lastDecRunnable, Runnable errorRunanable) {
        mContext = context;
        mFirstIncRunnable = firstIncRunnable;
        mLastDecRunnable = lastDecRunnable;
        if (firstIncRunnable != null) mFirstIncRunnables.add(firstIncRunnable);
        if (lastDecRunnable != null) mLastDecRunnables.add(lastDecRunnable);
        mErrorRunnable = errorRunanable;
    }

    /** Increments the ref count */
    public void increment() {
        if (mCount == 0 && mFirstIncRunnable != null) {
            mFirstIncRunnable.run();
        if (mCount == 0 && !mFirstIncRunnables.isEmpty()) {
            int numRunnables = mFirstIncRunnables.size();
            for (int i = 0; i < numRunnables; i++) {
                mFirstIncRunnables.get(i).run();
            }
        }
        mCount++;
    }
@@ -65,11 +70,19 @@ public class ReferenceCountedTrigger {
        return mIncrementRunnable;
    }

    /** Adds a runnable to the last-decrement runnables list. */
    public void addLastDecrementRunnable(Runnable r) {
        mLastDecRunnables.add(r);
    }

    /** Decrements the ref count */
    public void decrement() {
        mCount--;
        if (mCount == 0 && mLastDecRunnable != null) {
            mLastDecRunnable.run();
        if (mCount == 0 && !mLastDecRunnables.isEmpty()) {
            int numRunnables = mLastDecRunnables.size();
            for (int i = 0; i < numRunnables; i++) {
                mLastDecRunnables.get(i).run();
            }
        } else if (mCount < 0) {
            if (mErrorRunnable != null) {
                mErrorRunnable.run();
+19 −10
Original line number Diff line number Diff line
@@ -100,6 +100,16 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
    Rect mTmpRect2 = new Rect();
    LayoutInflater mInflater;

    Runnable mReturnAllViewsToPoolRunnable = new Runnable() {
        @Override
        public void run() {
            int childCount = getChildCount();
            for (int i = childCount - 1; i >= 0; i--) {
                mViewPool.returnViewToPool((TaskView) getChildAt(i));
            }
        }
    };

    public TaskStackView(Context context, TaskStack stack) {
        super(context);
        mConfig = RecentsConfiguration.getInstance();
@@ -904,6 +914,9 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
            TaskView tv = (TaskView) getChildAt(i);
            tv.startExitToHomeAnimation(ctx);
        }

        // Add a runnable to the post animation ref counter to clear all the views
        ctx.postAnimationTrigger.addLastDecrementRunnable(mReturnAllViewsToPoolRunnable);
    }

    @Override
@@ -936,15 +949,14 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
    public void onStackTaskRemoved(TaskStack stack, Task t) {
        // Remove the view associated with this task, we can't rely on updateTransforms
        // to work here because the task is no longer in the list
        int childCount = getChildCount();
        for (int i = childCount - 1; i >= 0; i--) {
            TaskView tv = (TaskView) getChildAt(i);
            if (tv.getTask() == t) {
        TaskView tv = getChildViewForTask(t);
        if (tv != null) {
            mViewPool.returnViewToPool(tv);
                break;
            }
        }

        // Notify the callback that we've removed the task and it can clean up after it
        mCb.onTaskRemoved(t);

        // Update the min/max scroll and animate other task views into their new positions
        updateMinMaxScroll(true);
        int movement = (int) (Constants.Values.TaskStackView.StackOverlapPct * mTaskRect.height());
@@ -1193,7 +1205,6 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        // Request that this tasks's data be filled
        RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
        loader.loadTaskData(task);

        // Find the index where this task should be placed in the children
        int insertIndex = -1;
        int childCount = getChildCount();
@@ -1275,8 +1286,6 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
        Task task = tv.getTask();
        // Remove the task from the view
        mStack.removeTask(task);
        // Notify the callback that we've removed the task and it can clean up after it
        mCb.onTaskRemoved(task);
    }

    /**** View.OnClickListener Implementation ****/