@@ -77,9 +77,10 @@ public class RecentsPanelView extends FrameLayout implements OnItemClickListener
7777
7878 private boolean mShowing ;
7979 private boolean mWaitingToShow ;
80- private int mNumItemsWaitingForThumbnailsAndIcons ;
8180 private ViewHolder mItemToAnimateInWhenWindowAnimationIsFinished ;
81+ private boolean mAnimateIconOfFirstTask ;
8282 private boolean mWaitingForWindowAnimation ;
83+ private long mWindowAnimationStartTime ;
8384
8485 private RecentTasksLoader mRecentTasksLoader ;
8586 private ArrayList <TaskDescription > mRecentTaskDescriptions ;
@@ -174,10 +175,9 @@ public View getView(int position, View convertView, ViewGroup parent) {
174175 if (td .isLoaded ()) {
175176 updateThumbnail (holder , td .getThumbnail (), true , false );
176177 updateIcon (holder , td .getIcon (), true , false );
177- mNumItemsWaitingForThumbnailsAndIcons --;
178178 }
179179 if (index == 0 ) {
180- if (mWaitingForWindowAnimation ) {
180+ if (mAnimateIconOfFirstTask ) {
181181 if (mItemToAnimateInWhenWindowAnimationIsFinished != null ) {
182182 holder .iconView .setAlpha (1f );
183183 holder .iconView .setTranslationX (0f );
@@ -206,6 +206,9 @@ public View getView(int position, View convertView, ViewGroup parent) {
206206 holder .iconView .setAlpha (0f );
207207 holder .iconView .setTranslationY (translation );
208208 }
209+ if (!mWaitingForWindowAnimation ) {
210+ animateInIconOfFirstTask ();
211+ }
209212 }
210213 }
211214
@@ -220,7 +223,9 @@ public void recycleView(View v) {
220223 updateThumbnail (holder , mRecentTasksLoader .getDefaultThumbnail (), false , false );
221224 holder .iconView .setImageBitmap (mRecentTasksLoader .getDefaultIcon ());
222225 holder .iconView .setVisibility (INVISIBLE );
226+ holder .iconView .animate ().cancel ();
223227 holder .labelView .setText (null );
228+ holder .labelView .animate ().cancel ();
224229 holder .thumbnailView .setContentDescription (null );
225230 holder .thumbnailView .setTag (null );
226231 holder .thumbnailView .setOnLongClickListener (null );
@@ -235,6 +240,7 @@ public void recycleView(View v) {
235240 holder .calloutLine .setAlpha (1f );
236241 holder .calloutLine .setTranslationX (0f );
237242 holder .calloutLine .setTranslationY (0f );
243+ holder .calloutLine .animate ().cancel ();
238244 }
239245 holder .taskDescription = null ;
240246 holder .loadedThumbnailAndIcon = false ;
@@ -291,8 +297,9 @@ public void show(boolean show) {
291297 }
292298
293299 public void show (boolean show , ArrayList <TaskDescription > recentTaskDescriptions ,
294- boolean firstScreenful , boolean waitingForWindowAnimation ) {
295- mWaitingForWindowAnimation = waitingForWindowAnimation ;
300+ boolean firstScreenful , boolean animateIconOfFirstTask ) {
301+ mAnimateIconOfFirstTask = animateIconOfFirstTask ;
302+ mWaitingForWindowAnimation = animateIconOfFirstTask ;
296303 if (show ) {
297304 mWaitingToShow = true ;
298305 refreshRecentTasksList (recentTaskDescriptions , firstScreenful );
@@ -527,7 +534,6 @@ void onTaskThumbnailLoaded(TaskDescription td) {
527534 updateIcon (h , td .getIcon (), true , animateShow );
528535 updateThumbnail (h , td .getThumbnail (), true , animateShow );
529536 h .loadedThumbnailAndIcon = true ;
530- mNumItemsWaitingForThumbnailsAndIcons --;
531537 }
532538 }
533539 }
@@ -536,9 +542,14 @@ void onTaskThumbnailLoaded(TaskDescription td) {
536542 showIfReady ();
537543 }
538544
539- public void onWindowAnimationStart () {
540- if (mItemToAnimateInWhenWindowAnimationIsFinished != null ) {
541- final int startDelay = 150 ;
545+ private void animateInIconOfFirstTask () {
546+ if (mItemToAnimateInWhenWindowAnimationIsFinished != null &&
547+ !mRecentTasksLoader .isFirstScreenful ()) {
548+ int timeSinceWindowAnimation =
549+ (int ) (System .currentTimeMillis () - mWindowAnimationStartTime );
550+ final int minStartDelay = 150 ;
551+ final int startDelay = Math .max (0 , Math .min (
552+ minStartDelay - timeSinceWindowAnimation , minStartDelay ));
542553 final int duration = 250 ;
543554 final ViewHolder holder = mItemToAnimateInWhenWindowAnimationIsFinished ;
544555 final TimeInterpolator cubic = new DecelerateInterpolator (1.5f );
@@ -550,10 +561,16 @@ public void onWindowAnimationStart() {
550561 }
551562 }
552563 mItemToAnimateInWhenWindowAnimationIsFinished = null ;
553- mWaitingForWindowAnimation = false ;
564+ mAnimateIconOfFirstTask = false ;
554565 }
555566 }
556567
568+ public void onWindowAnimationStart () {
569+ mWaitingForWindowAnimation = false ;
570+ mWindowAnimationStartTime = System .currentTimeMillis ();
571+ animateInIconOfFirstTask ();
572+ }
573+
557574 public void clearRecentTasksList () {
558575 // Clear memory used by screenshots
559576 if (mRecentTaskDescriptions != null ) {
@@ -590,9 +607,6 @@ private void refreshRecentTasksList(
590607 }
591608
592609 public void onTasksLoaded (ArrayList <TaskDescription > tasks , boolean firstScreenful ) {
593- mNumItemsWaitingForThumbnailsAndIcons = firstScreenful
594- ? tasks .size () : mRecentTaskDescriptions == null
595- ? 0 : mRecentTaskDescriptions .size ();
596610 if (mRecentTaskDescriptions == null ) {
597611 mRecentTaskDescriptions = new ArrayList <TaskDescription >(tasks );
598612 } else {
0 commit comments