@@ -75,6 +75,7 @@ public class RecentsPanelView extends RelativeLayout implements OnItemClickListe
7575
7676 private RecentTasksLoader mRecentTasksLoader ;
7777 private ArrayList <TaskDescription > mRecentTaskDescriptions ;
78+ private Runnable mPreloadTasksRunnable ;
7879 private boolean mRecentTasksDirty = true ;
7980 private TaskDescriptionAdapter mListAdapter ;
8081 private int mThumbnailWidth ;
@@ -198,10 +199,16 @@ public void show(boolean show, boolean animate,
198199 } else {
199200 if (noApps ) {
200201 if (DEBUG ) Log .v (TAG , "Nothing to show" );
202+ // Need to set recent tasks to dirty so that next time we load, we
203+ // refresh the list of tasks
204+ mRecentTasksLoader .cancelLoadingThumbnails ();
205+ mRecentTasksDirty = true ;
201206 return ;
202207 }
203208 }
204209 } else {
210+ // Need to set recent tasks to dirty so that next time we load, we
211+ // refresh the list of tasks
205212 mRecentTasksLoader .cancelLoadingThumbnails ();
206213 mRecentTasksDirty = true ;
207214 }
@@ -361,6 +368,13 @@ public void onClick(View v) {
361368 if (mRecentsScrim != null && mRecentsScrim .getBackground () instanceof BitmapDrawable ) {
362369 ((BitmapDrawable ) mRecentsScrim .getBackground ()).setTileModeY (TileMode .REPEAT );
363370 }
371+
372+ mPreloadTasksRunnable = new Runnable () {
373+ public void run () {
374+ setVisibility (INVISIBLE );
375+ refreshRecentTasksList ();
376+ }
377+ };
364378 }
365379
366380 private void createCustomAnimations (LayoutTransition transitioner ) {
@@ -446,14 +460,18 @@ public boolean onTouch(View v, MotionEvent ev) {
446460 if (!mShowing ) {
447461 int action = ev .getAction () & MotionEvent .ACTION_MASK ;
448462 if (action == MotionEvent .ACTION_DOWN ) {
449- // If we set our visibility to INVISIBLE here, we avoid an extra call to onLayout
450- // later when we become visible
451- setVisibility ( INVISIBLE );
452- refreshRecentTasksList ( );
463+ // If we set our visibility to INVISIBLE here, we avoid an extra call to
464+ // onLayout later when we become visible (because onLayout is always called
465+ // when going from GONE)
466+ post ( mPreloadTasksRunnable );
453467 } else if (action == MotionEvent .ACTION_CANCEL ) {
454468 setVisibility (GONE );
455469 clearRecentTasksList ();
470+ // Remove the preloader if we haven't called it yet
471+ removeCallbacks (mPreloadTasksRunnable );
456472 } else if (action == MotionEvent .ACTION_UP ) {
473+ // Remove the preloader if we haven't called it yet
474+ removeCallbacks (mPreloadTasksRunnable );
457475 if (!v .isPressed ()) {
458476 setVisibility (GONE );
459477 clearRecentTasksList ();
0 commit comments