Stop listening root change events when the activity is destroyed.

BUG=26454244

Change-Id: I4be98f21843d6d501dd9c6fc343e905e107fc1c1
diff --git a/src/com/android/documentsui/BaseActivity.java b/src/com/android/documentsui/BaseActivity.java
index 180a48e..dfeef50 100644
--- a/src/com/android/documentsui/BaseActivity.java
+++ b/src/com/android/documentsui/BaseActivity.java
@@ -176,6 +176,12 @@
         return true;
     }
 
+    @Override
+    protected void onDestroy() {
+        mRoots.setOnCacheUpdateListener(null);
+        super.onDestroy();
+    }
+
     State buildDefaultState() {
         State state = new State();
 
@@ -518,7 +524,7 @@
 
         @Override
         protected void onPostExecute(DocumentInfo result) {
-            if (result != null) {
+            if (result != null && !isDestroyed()) {
                 openContainerDocument(result);
             }
         }