Fix some issues with taskbar

- Update Hotseat items in init() to ensure they are reloaded
- Don't update Recent items if we get the new tasks after cleanup()

Test: Fold and unfold, ensure Taskbar disappears/reappears without
crashing

Bug: 171917176
Change-Id: I1c2ae1022ae56cddece655b22db187684f691bf8
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java
index 4dc051a..082343e 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarHotseatController.java
@@ -57,6 +57,7 @@
 
     protected void init() {
         mLauncher.getDragController().addDragListener(mDragListener);
+        onHotseatUpdated();
     }
 
     protected void cleanup() {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentsController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentsController.java
index 9d4e000..4256d2b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentsController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarRecentsController.java
@@ -50,6 +50,8 @@
     // The current background requests to load the task icons
     private CancellableTask[] mIconLoadRequests = new CancellableTask[mNumRecentIcons];
 
+    private boolean mIsAlive;
+
     public TaskbarRecentsController(BaseQuickstepLauncher launcher,
             TaskbarController.TaskbarRecentsControllerCallbacks taskbarCallbacks) {
         mLauncher = launcher;
@@ -58,11 +60,13 @@
     }
 
     protected void init() {
+        mIsAlive = true;
         TaskStackChangeListeners.getInstance().registerTaskStackListener(mTaskStackChangeListener);
         reloadRecentTasksIfNeeded();
     }
 
     protected void cleanup() {
+        mIsAlive = false;
         TaskStackChangeListeners.getInstance().unregisterTaskStackListener(
                 mTaskStackChangeListener);
         cancelAllPendingIconLoadTasks();
@@ -84,7 +88,9 @@
     }
 
     private void onRecentTasksChanged(ArrayList<Task> tasks) {
-        mTaskbarCallbacks.updateRecentItems(tasks);
+        if (mIsAlive) {
+            mTaskbarCallbacks.updateRecentItems(tasks);
+        }
     }
 
     /**