OSDN Git Service

Fixing animation when dismissing certain tasks.
authorWinson Chung <winsonc@google.com>
Wed, 23 Jul 2014 00:02:16 +0000 (17:02 -0700)
committerWinson Chung <winsonc@google.com>
Wed, 23 Jul 2014 00:05:36 +0000 (00:05 +0000)
packages/SystemUI/src/com/android/systemui/recents/views/TaskStackView.java
packages/SystemUI/src/com/android/systemui/recents/views/TaskStackViewLayoutAlgorithm.java

index 1c8ae31..f135e32 100644 (file)
@@ -296,8 +296,8 @@ public class TaskStackView extends FrameLayout implements TaskStack.TaskStackCal
                         if (transform.t < 0) {
                             mTmpTransform = mStackAlgorithm.getStackTransform(tasks.get(0), stackScroll, mTmpTransform);
                         } else {
-                            mTmpTransform = mStackAlgorithm.getStackTransform(tasks.get(Math.min(tasks.size() - 1, visibleRange[0] + 1)),
-                                    stackScroll, mTmpTransform);
+                            int nextTaskStackScroll = mStackAlgorithm.getStackScrollForTaskIndex(task, 1);
+                            mStackAlgorithm.getStackTransform(nextTaskStackScroll, stackScroll, mTmpTransform);
                         }
                         tv.updateViewPropertiesToTaskTransform(mTmpTransform, 0);
                     }
index 3c89cd7..7f94a0a 100644 (file)
@@ -103,12 +103,16 @@ public class TaskStackViewLayoutAlgorithm {
             transformOut.reset();
             return transformOut;
         }
+        return getStackTransform(getStackScrollForTaskIndex(task), stackScroll, transformOut);
+    }
 
+    /** Update/get the transform */
+    public TaskViewTransform getStackTransform(int taskStackScroll, int stackScroll, TaskViewTransform transformOut) {
         // Map the items to an continuous position relative to the specified scroll
         int numPeekCards = StackPeekNumCards;
         float overlapHeight = StackOverlapPct * mTaskRect.height();
         float peekHeight = StackPeekHeightPct * mStackRect.height();
-        float t = (getStackScrollForTaskIndex(task) - stackScroll) / overlapHeight;
+        float t = (taskStackScroll - stackScroll) / overlapHeight;
         float boundedT = Math.max(t, -(numPeekCards + 1));
 
         // Set the scale relative to its position
@@ -116,8 +120,8 @@ public class TaskStackViewLayoutAlgorithm {
         float minScale = StackPeekMinScale;
         float scaleRange = 1f - minScale;
         float scaleInc = scaleRange / (numPeekCards + numFrontScaledCards);
-        float scale = Math.max(minScale, Math.min(1f, minScale + 
-            ((boundedT + (numPeekCards + 1)) * scaleInc)));
+        float scale = Math.max(minScale, Math.min(1f, minScale +
+                ((boundedT + (numPeekCards + 1)) * scaleInc)));
         float scaleYOffset = ((1f - scale) * mTaskRect.height()) / 2;
         // Account for the bar offsets being scaled?
         float scaleBarYOffset = (1f - scale) * mConfig.taskBarHeight;
@@ -169,6 +173,14 @@ public class TaskStackViewLayoutAlgorithm {
     }
 
     /**
+     * Returns the scroll to such that the task transform at that task + index will have t=0.
+     * (If the scroll is not bounded)
+     */
+    int getStackScrollForTaskIndex(Task t, int relativeIndexOffset) {
+        return mTaskOffsetMap.get(t.key) + (int) (relativeIndexOffset * getTaskOverlapHeight());
+    }
+
+    /**
      * Updates the cache of tasks to offsets.
      */
     void updateTaskOffsets(ArrayList<Task> tasks) {